Skip to content

Commit

Permalink
Fix weird idea in monthly melt correction (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion authored Aug 16, 2021
1 parent 129cf4b commit 94bd76b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions oggm/core/flowline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,7 @@ def run_with_hydro(gdir, run_task=None, store_monthly_hydro=False,
mb *= seconds * cfg.PARAMS['ice_density']

# Bias of the mb model is a fake melt term that we need to deal with
# This is here for correction purposes later
mb_bias = mb_mod.bias * seconds / cfg.SEC_IN_YEAR

liq_prcp_on_g = (prcp - prcpsol) * bin_area
Expand Down Expand Up @@ -2927,12 +2928,12 @@ def run_with_hydro(gdir, run_task=None, store_monthly_hydro=False,
):

real_melt = melt - bias
real_melt_sum = np.sum(real_melt)
bias_sum = np.sum(bias)
if real_melt_sum > 0:
to_correct = utils.clip_min(real_melt, 0)
to_correct_sum = np.sum(to_correct)
if (to_correct_sum > 1e-7) and (np.sum(melt) > 0):
# Ok we correct the positive melt instead
fac = 1 + bias_sum / real_melt_sum
melt[:] = real_melt * fac
fac = np.sum(melt) / to_correct_sum
melt[:] = to_correct * fac

# Correct for mass-conservation and match the ice-dynamics model
fmod.run_until(yr + 1)
Expand Down

0 comments on commit 94bd76b

Please sign in to comment.