Skip to content

Update glacierdynamics.MassRedistributionCurveModel to work with any timestep#147

Merged
btobers merged 10 commits into133-mb_dailyfrom
146_nonoggm_sims
Oct 22, 2025
Merged

Update glacierdynamics.MassRedistributionCurveModel to work with any timestep#147
btobers merged 10 commits into133-mb_dailyfrom
146_nonoggm_sims

Conversation

@btobers
Copy link
Collaborator

@btobers btobers commented Oct 20, 2025

@drounce This PR is branched from your 133-mb_daily branch. I went through the MassRedistributionCurveModel code and implemented some changes to properly index into the model indices following the changes to the mass balance model. I'll leave this for you to review and then we can pull it into branch 133-mb_daily to finalize the work of running daily simulations. I also created two simple tests in this PR which run the simulation script using the mass redistribution curve model or no dynamics - previously our tests were only running OGGM dynamics.

@btobers btobers self-assigned this Oct 20, 2025
@btobers btobers requested a review from drounce October 20, 2025 23:59
@btobers btobers marked this pull request as ready for review October 20, 2025 23:59
@btobers btobers linked an issue Oct 21, 2025 that may be closed by this pull request
@btobers
Copy link
Collaborator Author

btobers commented Oct 21, 2025

Some other updates that are included in this PR:

  1. This PR also introduces a new method under the PyGEMMassBalanceModel which returns the start and stop time indices for a given model year - since these indices are needed in a variety of places

    def get_step_inds(self, year):
        """
        Get time step start and stop indices for the specified model year.
        Both indices are inclusive, so standard Python slicing would use
        [t_start : t_stop + 1].
        """
        step_idxs = np.where(self.dates_table.year == int(year))[0]
        if step_idxs.size == 0:
            raise ValueError(f'Year {year} not found in dates_table.')
        return step_idxs[0], step_idxs[-1]
    
  2. Removed the now unused daysinmonth() from pygem_modelsetup.py.

  3. Cleaned up annual loop in constant-area runs. The following block was removed from run_simulation.py:

    mb_mwea = (
      mb_annual
      * 365
      * 24
      * 3600
      * pygem_prms['constants']['density_ice']
      / pygem_prms['constants']['density_water']
    
    glac_wide_mb_mwea = (
      mb_mwea * mbmod.glacier_area_initial
      ).sum() / mbmod.glacier_area_initial.sum()
      mb_all.append(glac_wide_mb_mwea)
    

    and was replaced with the following:

    t_start, t_stop = mbmod.get_step_inds(year)
    mb_all.append(
      mbmod.glac_wide_massbaltotal[t_start : t_stop + 1].sum()
      / mbmod.glacier_area_initial.sum()
    

    Note, this is only relevant for debugging:

    if debug:
      print(
      'iter:',
      n_iter,
      'massbal (mean, std):',
      np.round(np.mean(mb_all), 3),
      np.round(np.std(mb_all), 3),
      'massbal (med):',
      np.round(np.median(mb_all), 3),
      )
    

@btobers btobers merged commit 0e70634 into 133-mb_daily Oct 22, 2025
2 checks passed
@btobers btobers deleted the 146_nonoggm_sims branch October 22, 2025 17:23
@btobers btobers linked an issue Oct 22, 2025 that may be closed by this pull request
@btobers btobers mentioned this pull request Oct 22, 2025
btobers added a commit that referenced this pull request Nov 4, 2025
Closes #133. Closes #141. Closes #142.

The man updates from this PR include:
* Enabling the mass balance model to run on a daily timestep
* Removal of nested try/except blocks in run_simulation.py so that if the specified dynamical option fails the model does not default to a fallback option
* Storage of the dynamical option within the output netcdf file
* Add test_postproc_binned_subannual_thick() to test04
* Update glacierdynamics.MassRedistributionCurveModel to work with any timestep (#147)

---------

Co-authored-by: brandon s. tober <tobers.brandon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run test simulations without OGGM dynamics Expand test suite

1 participant