-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add capability to reset the "state" of the mass balance model #1757
base: master
Are you sure you want to change the base?
Conversation
Hello @dngoldberg! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2025-01-17 10:51:02 UTC |
@dngoldberg thanks for this. Here is an alternative suggestion which I think is a bit cleaner. Changes:
The current way that Let me know if this works for you as suggested by my last commit. |
hi @fmaussion thanks very much and i will look at your change soon. But i want to say, i was thinking about it further and maybe the issue that led to this PR could be addressed simply at the level of the "state"-ful MB model through implementing get_specific_mb() instead of using the parent class. at the same time, though, you mentioned that a MB model should always be reproducible and the output of get_annual_mb() should not depend on previous calls. this PR is meant to address this which is why i decided to submit it after all. But if you think this is less important, i could close without merging. Please let me know. i need to understand apparent_mb_from_any_mb() better, my suspicion is that it does NOT need to call get_specific_mb() but i will look carefully. (that would, also, address the issue that precipitated this PR -- but, of course, there might be other issues not yet encountered, such as in dynamic spinup..) |
@dngoldberg the current PR is totally fine by me. It should do exactly what you wanted it to do (resetting a state each year when calling multiple years), but a bit differently.
I agree with that ;-) - I've just been lazy. The second call to MB on the flowlines is what's needed. It can be avoided. |
hi @fmaussion have looked it over. while this does solve the apparent_mb_from_any_mb() issue, it is not quite what i wanted, because in the specific implementation that I am thinking of the state is important when modelling mb over a multi-year period. this is why i was only resetting the state at the beginning of get_specific_mb(). However -- i like your addition of a reset_state() function in the parent class. Therefore I propose this:
I don't know a clever way to (1) and (2) without just undoing the commits and adding the reset_state() function manually. but if you agree with the above, and you know a quick way, feel free! |
… in apparent_mb_from_any_mb subject to kwarg, no other changes
hi @fmaussion what do you think of these changes? i like it because it's far less extensive. all tests pass, and it addresses the issue i was having with apparent mass balance. refactoring apparent_mb_from_any_mb() might be beyond the scope of this PR, but an issue could be created. meanwhile, this gives more flexibility. |
Although this does not apply to any existing mass balance models, there may be mass balance models in the future that have a "state" associated. Now, for a given set of climate files for a given glacier in a given year or interval, the mass balance models return consistent values whenever
get_annual_mb
orget_specific_mb
is called. But if an energy balance model is implemented, the mass balance will depend on properties such as snow state and glacier surface temperature, and this may not give consistent results unless there is a consistent "state". The issue arises, for instance, inapparent_mb_from_any_mb
, but there could be others as well.One possibility is to save the "state" in a given year in a glacier directory. However, this will not completely address the problem as get_annual_mb may be called for a different year.
Another is to give flexibility by allowing a "reset_state" kwarg. This does absolutely nothing with existing mass balance models, but allows developers of new MB models a way to address the issues above. That is what the current pull request does.
NOTE a far less-invasive option to address the issue in
apparent_mb_from_any_mb
might be to re-instantiate the mass balance model within the function. But this led to multiple testing errors.Closes #1755
whats-new.rst
: Added "reset_state" functionality toMassBalanceModel.get_specific_mb()
tosignal any state-dependent mass balance model to "reset its state" at the start
of the period. This is achieved through a "reset_state" kwarg passed by
MassBalanceModel.get_annual_mb()
. Done to address thatapparent_mb_from_any_mb()
callsget_specific_mb()
twice, leading to nonzeroterminal flux (potentially) with a state-dependent mass balance model.
apparent_mb_from_any_mb()
also changed accordingly. Similar change alsomade to
MultipleFlowlineMassBalanceModel.get_specific_mb()
. Does not impactany current functionality within oggm.
NOTE: this PR is invasive, and i have decided on a less invasive change. so i am closing it.