diff --git a/pygem/bin/postproc/postproc_distribute_ice.py b/pygem/bin/postproc/postproc_distribute_ice.py index 688ef89b..8da582e0 100644 --- a/pygem/bin/postproc/postproc_distribute_ice.py +++ b/pygem/bin/postproc/postproc_distribute_ice.py @@ -76,8 +76,7 @@ def pygem_to_oggm(pygem_simpath, oggm_diag=None, debug=False): area_m2(time, dis_along_flowline): float64 thickness_m (time, dis_along_flowline): float64 """ - yr0, yr1 = pygem_simpath.split('_')[-3:-1] - pygem_ds = xr.open_dataset(pygem_simpath).sel(year=slice(yr0, yr1)) + pygem_ds = xr.open_dataset(pygem_simpath) time = pygem_ds.coords['year'].values.flatten().astype(float) distance_along_flowline = pygem_ds['bin_distance'].values.flatten().astype(float) area = pygem_ds['bin_area_annual'].values[0].astype(float).T diff --git a/pygem/bin/run/run_calibration.py b/pygem/bin/run/run_calibration.py index 20bae6f3..f81b8140 100755 --- a/pygem/bin/run/run_calibration.py +++ b/pygem/bin/run/run_calibration.py @@ -3061,7 +3061,7 @@ def run_objective( else: # LOG FAILURE - fail_fp = pygem_prms['root'] + '/Outputcal_fail/' + glacier_str.split('.')[0].zfill(2) + '/' + fail_fp = pygem_prms['root'] + '/Output/cal_fail/' + glacier_str.split('.')[0].zfill(2) + '/' if not os.path.exists(fail_fp): os.makedirs(fail_fp, exist_ok=True) txt_fn_fail = glacier_str + '-cal_fail.txt' diff --git a/pygem/bin/run/run_simulation.py b/pygem/bin/run/run_simulation.py index fafcaf26..2b0b9c68 100755 --- a/pygem/bin/run/run_simulation.py +++ b/pygem/bin/run/run_simulation.py @@ -50,6 +50,7 @@ from pygem.glacierdynamics import MassRedistributionCurveModel from pygem.massbalance import PyGEMMassBalance from pygem.oggm_compat import ( + get_spinup_flowlines, single_flowline_glacier_directory, single_flowline_glacier_directory_with_calving, ) @@ -661,7 +662,8 @@ def run(list_packed_vars): modelprms_fp = ( pygem_prms['root'] + '/Output/calibration/' + glacier_str.split('.')[0].zfill(2) + '/' ) + modelprms_fn - + elif os.path.isdir(modelprms_fp): + modelprms_fp = modelprms_fp + '/' + glacier_str + '-modelprms_dict.json' assert os.path.exists(modelprms_fp), 'Calibrated parameters do not exist.' with open(modelprms_fp, 'r') as f: modelprms_dict = json.load(f) @@ -804,11 +806,16 @@ def run(list_packed_vars): # spinup if args.spinup: try: - # see if model_flowlines from spinup exist - nfls = gdir.read_pickle( - 'model_flowlines', - filesuffix=f'_dynamic_spinup_pygem_mb_{args.sim_startyear}', - ) + if f'model_flowlines_dynamic_spinup_pygem_mb_{args.sim_startyear}.pkl' in os.listdir( + gdir.dir + ): + # see if model_flowlines from spinup exist + nfls = gdir.read_pickle( + 'model_flowlines', + filesuffix=f'_dynamic_spinup_pygem_mb_{args.sim_startyear}', + ) + else: + nfls = get_spinup_flowlines(gdir, y0=args.sim_startyear) except: raise glen_a = gdir.get_diagnostics()['inversion_glen_a'] diff --git a/pygem/setup/config.yaml b/pygem/setup/config.yaml index 1cf9127f..af1b4ff8 100644 --- a/pygem/setup/config.yaml +++ b/pygem/setup/config.yaml @@ -159,7 +159,7 @@ calib: # Chain options mcmc_step: 0.5 # mcmc step size (in terms of standard deviation) n_chains: 1 # number of chains (min 1, max 3) - mcmc_sample_no: 20000 # number of steps (10000 was found to be sufficient in HMA) + mcmc_sample_no: 10000 # number of steps (10000 was found to be sufficient in HMA) mcmc_burn_pct: 2 # percentage of steps to burn-in (0 records all steps in chain) thin_interval: 10 # thin interval if need to reduce file size (best to leave at 1 if space allows) # Degree-day factor of snow distribution options