From 5313d54d35d61892335209e7b3d2ba36430bdf81 Mon Sep 17 00:00:00 2001 From: Patrick Schmitt <50843444+pat-schmitt@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:49:01 +0100 Subject: [PATCH] make sure that melt_f limits are not exceeded in dynamic calibration (#1685) --- oggm/core/dynamic_spinup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oggm/core/dynamic_spinup.py b/oggm/core/dynamic_spinup.py index e2184d1e0..aae925584 100644 --- a/oggm/core/dynamic_spinup.py +++ b/oggm/core/dynamic_spinup.py @@ -1978,8 +1978,10 @@ def c_fun(melt_f): def minimise_with_spline_fit(fct_to_minimise, melt_f_guess, mismatch): # defines limits of melt_f in accordance to maximal allowed change # between iterations - melt_f_limits = [melt_f_initial - melt_f_max_step_length, - melt_f_initial + melt_f_max_step_length] + melt_f_limits = [max(melt_f_initial - melt_f_max_step_length, + melt_f_min), + min(melt_f_initial + melt_f_max_step_length, + melt_f_max)] # this two variables indicate that the limits were already adapted to # avoid an error