Skip to content

Commit

Permalink
Add filesuffix to mb calibration (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion authored Jan 22, 2024
1 parent 390f656 commit 6e0fb56
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions oggm/core/massbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ def mb_calibration_from_scalar_mb(gdir, *,
temp_bias_min=None,
temp_bias_max=None,
mb_model_class=MonthlyTIModel,
filesuffix='',
):
"""Determine the mass balance parameters from a scalar mass-balance value.
Expand Down Expand Up @@ -1684,6 +1685,10 @@ def mb_calibration_from_scalar_mb(gdir, *,
temp_bias_max: float
the maximum accepted value for the temperature bias during optimisation.
Defaults to cfg.PARAMS['temp_bias_max'].
filesuffix: str
add a filesuffix to mb_params.json. This could be useful for sensitivity
analyses with MB models, if they need to fetch other sets of params for
example.
"""

# Param constraints
Expand Down Expand Up @@ -1881,12 +1886,12 @@ def to_minimize(x, model_attr):
df['baseline_climate_source'] = gdir.get_climate_info()['baseline_climate_source']
# Write
if write_to_gdir:
if gdir.has_file('mb_calib') and not overwrite_gdir:
if gdir.has_file('mb_calib', filesuffix=filesuffix) and not overwrite_gdir:
raise InvalidWorkflowError('`mb_calib.json` already exists for '
'this repository. Set `overwrite_gdir` '
'to True if you want to overwrite '
'a previous calibration.')
gdir.write_json(df, 'mb_calib')
gdir.write_json(df, 'mb_calib', filesuffix=filesuffix)
return df


Expand Down

0 comments on commit 6e0fb56

Please sign in to comment.