Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pygem/bin/postproc/postproc_distribute_ice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pygem/bin/run/run_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 13 additions & 6 deletions pygem/bin/run/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion pygem/setup/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down