Skip to content

Commit a6cf3be

Browse files
authored
Allow for frontal ablation in dynamical spinup (#175)
* Allow for calving in dynamical spinup * Pull cfl params from pygem config * Allow for inversion in mcmc elev_change_1d calib * Optimize spinup run 0-year period with inversion dynamical run * Store model geom * Bug fix in indexing of time steps in mass balance loop introduced when updating to allow for daily calibration
1 parent 310d025 commit a6cf3be

8 files changed

Lines changed: 536 additions & 197 deletions

File tree

poetry.lock

Lines changed: 241 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pygem/bin/postproc/postproc_distribute_ice.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,19 @@ def run(simpath, debug=False):
156156
gdir,
157157
fl_diag=pygem_fl_diag,
158158
concat_input_filesuffix='_spinup_historical', # concatenate with the historical spinup
159-
output_filesuffix=f'_pygem_{f_suffix}', # filesuffix added to the output filename gridded_simulation.nc, if empty input_filesuffix is used
159+
output_filesuffix=f'_{f_suffix}', # filesuffix added to the output filename gridded_simulation.nc, if empty input_filesuffix is used
160160
)[0]
161-
print(
162-
'2D simulated ice thickness created: ',
163-
gdir.get_filepath('gridded_simulation', filesuffix=f'_pygem_{f_suffix}'),
164-
)
161+
162+
# copy glacier_ext from gridded_data
163+
with xr.open_dataset(gdir.get_filepath('gridded_data')) as ds0:
164+
ds['glacier_ext'] = ds0['glacier_ext']
165+
ds.to_netcdf(gdir.get_filepath('gridded_simulation', filesuffix=f'_{f_suffix}'))
166+
165167
if debug:
168+
print(
169+
'2D simulated ice thickness created: ',
170+
gdir.get_filepath('gridded_simulation', filesuffix=f'_{f_suffix}'),
171+
)
166172
plot_distributed_thickness(ds)
167173

168174
return

pygem/bin/run/run_calibration.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,10 @@ def calc_thick_change_1d(gdir, fls, mbmod, ds):
354354
years_subannual = np.array([d.year for d in gdir.dates_table['date']])
355355
yrs = np.unique(years_subannual)
356356
# grab components of interest
357-
bin_thick_annual = ds[0].thickness_m.values.T # glacier thickness [m ice], (nbins, nyears)
358-
bin_massbalclim_ice_annual = ds[0].climatic_mb_myr.values.T[
357+
bin_massbalclim_ice_annual = ds[0].climatic_mb.values.T[
359358
:, 1:
360359
] # annual climatic mass balance [m ice] (nbins, nyears - 1)
361-
bin_delta_thick_annual = ds[0].dhdt_myr.values.T[
362-
:, 1:
363-
] # annual change in ice thickness [m ice] (nbins, nyears - 1)
360+
bin_delta_thick_annual = ds[0].dhdt.values.T[:, 1:] # annual change in ice thickness [m ice] (nbins, nyears - 1)
364361
bin_flux_divergence_annual = (
365362
bin_massbalclim_ice_annual - bin_delta_thick_annual
366363
) # annual flux divergence [m ice] (nbins, nyears - 1)
@@ -384,8 +381,9 @@ def calc_thick_change_1d(gdir, fls, mbmod, ds):
384381
bin_delta_thick_subannual = bin_massbalclim_ice - bin_flux_divergence_subannual
385382

386383
# --- Step 4: calculate subannual thickness = running thickness change + initial thickness---
384+
bin_thick_initial = ds[0].thickness_m.isel(time=0).values # initial glacier thickness [m ice], (nbins)
387385
running_bin_delta_thick_subannual = np.nancumsum(bin_delta_thick_subannual, axis=-1)
388-
bin_thick_subannual = running_bin_delta_thick_subannual + bin_thick_annual[:, 0][:, np.newaxis]
386+
bin_thick_subannual = running_bin_delta_thick_subannual + bin_thick_initial[:, np.newaxis]
389387

390388
# --- Step 5: rebin ---
391389
# get surface height at the specified reference year

pygem/bin/run/run_inversion.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,11 @@ def main():
401401
nargs='+',
402402
help='Randoph Glacier Inventory glacier number (can take multiple)',
403403
)
404-
(
405-
parser.add_argument(
406-
'-rgi_glac_number_fn',
407-
type=str,
408-
default=None,
409-
help='Filepath containing list of rgi_glac_number, helpful for running batches on spc',
410-
),
404+
parser.add_argument(
405+
'-rgi_glac_number_fn',
406+
type=str,
407+
default=None,
408+
help='Filepath containing list of rgi_glac_number, helpful for running batches on spc',
411409
)
412410
parser.add_argument(
413411
'-calibrate_regional_glen_a',
@@ -473,10 +471,10 @@ def main():
473471
# format appropriately
474472
glac_no = [float(g) for g in glac_no]
475473
batches = [f'{g:.5f}' if g >= 10 else f'0{g:.5f}' for g in glac_no]
476-
regional_inv = False # flag to indicate per-glacier inversion
477474
elif args.rgi_glac_number_fn is not None:
478475
with open(args.rgi_glac_number_fn, 'r') as f:
479476
batches = json.load(f)
477+
regional_inv = False # flag to indicate per-glacier inversion
480478

481479
# set up partial function with common arguments
482480
run_partial = partial(

0 commit comments

Comments
 (0)