Skip to content
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 new possiblities for providing paramters. #1756

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

pat-schmitt
Copy link
Member

@pat-schmitt pat-schmitt commented Jan 13, 2025

This PR introduces two new ways to define and provide parameters for the model (in addition to the current default of using cfg.PARAMS):

  1. Minimal params.cfg File: You can now pass a minimal params.cfg file to cfg.initialize. If some parameters are missing in this file, the defaults from the main params.cfg (available here) will be used automatically.
  2. New run_settings.yml File, which could contain:
  • Almost all parameters from params.cfg
  • Values of observations used during calibration or initialization
  • If any parameter is not included in run_settings.yml, it falls back to the current defaults.

These additions required significant changes in sensitive parts of the model, particularly for the second point. However, tests appear to be passing. I have also included some tests for run_settings.yml. Not every aspect is tested yet, as adding more tests would overly expand the test suite.

Points for Discussion

  • Each function currently opens the run_settings.yml file independently, instead of opening it once at the start of a workflow and passing it around. While this approach may slightly reduce performance (dynamic runs are not effected by this), it maintains the flexibility needed for setting up custom workflows.

  • The new run_settings.yml works similarly to the existing mb_calib logic but supports calibration for only a single flowline. For now, I’ve kept mb_calib for backward compatibility and enforce a selection between the two possibilities to avoid potential confusions. However, we could consider removing mb_calib in the future.

  • When using run_settings.yml, all diagnostics are saved both to gdir.add_diagnostics and the run_settings.yml file. Maybe one or the other is enough?

  • Potentially the run_settings could be used to save all used parameters in each gdir. This would avoid confusions when a default params.cfg and a 'mini-params.cfg' is used, and make it clear which actual parameter was used. However, it also means that many same numbers are saved up to 200000 times globally, where one time would also be enough...

  • Tests added/passed

  • Fully documented

  • Entry in whats-new.rst

@pep8speaks
Copy link

Hello @pat-schmitt! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 1899:22: E241 multiple spaces after ','

@pat-schmitt
Copy link
Member Author

I managed to fix all tests, beside of python:3.11-slim. The problem is that the package yaml is not getting installed. @TimoRoth or @fmaussion could you direct me, where I need to add the package to be installed? Alternatively, I can do all imports of yaml using try-statements.

Beside of this, the PR slowly gets into a merge-able state. However, as this touches almost all sensitive parts of OGGM, before merging we should have a meeting. I would like to discus if the way I implemented everything is a good way or if their are better ways of doing it. And we need to decide how all this is or could change the default way of handling the params in OGGM.

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.

2 participants