Skip to content

Update to latest OGGM - #19

Open
fmaussion wants to merge 10 commits into
masterfrom
dev
Open

fmaussion wants to merge 10 commits into
masterfrom
dev

Conversation

@fmaussion

Copy link
Copy Markdown
Member

No description provided.

fmaussion and others added 10 commits September 17, 2026 23:04
OGGM removed the t*/mu* calibration architecture in v1.6.0, and current
master adds the gdir.settings/observations refactor on top. oggm-vas did
not even import any more.

VAScalingMassBalance is now a subclass of OGGM's MonthlyTIModel that
overrides a single method, _get_climate_for_index(): it ignores `heights`
and evaluates the climate at the glacier terminus (min_hgt) with the
Marzeion solid-precipitation ramp over min_hgt/max_hgt. Everything else --
the climate reader, the melt_f/temp_bias/prcp_fac parameters and their
setters, the calib_params plumbing, year validation -- is inherited, which
is what lets OGGM's own calibration drive it as mb_model_class.

So mu_star becomes melt_f (kg m-2 day-1 K-1, day-weighted), and prcp_fac
and temp_bias become calibrated per-glacier parameters rather than a global
constant and a hard 0. On Hintereisferner the calibration closes to 1e-13
and gives melt_f = 2.51, matching the old mu_star of 82.7.

Deleted: local_t_star, t_star_from_refmb, compute_ref_t_stars,
mu_star_calibration_from_geodetic_mb, get_yearly_mb_temp_prcp, the
vas_ref_tstars_* tables, the vascaling_mustar basename, and
match_regional_geodetic_mb (which shifted a bias that no longer exists).

The precipitation lapse rate is dropped too, matching OGGM's view that it
adds noise rather than value: compute_solid_prcp loses prcp_grad, and
precipitation is used at the climate file's ref_hgt.

prcp_clim -- the turnover in the response-time formula and the last hidden
dependency on t* -- is now the mean solid precipitation over the
calibration reference period, evaluated lazily at the RGI-date geometry.

ConstantVASMassBalance and RandomVASMassBalance are rewritten as thin
wrappers over a shared base that proxies the geometry, the parameters and
prcp_clim to the inner model. y0 is now required (it defaulted to t*).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The scaling laws and the time stepping are untouched -- they are the model
and OGGM's changes do not reach them. What changed around them:

- The mass balance models now carry the glacier geometry, so the model
  hands over the current terminus elevation (mb_model.min_hgt) before
  asking for the mass balance, instead of passing min_hgt/max_hgt as
  arguments.
- run_until_and_store is calendar year based, like OGGM. It writes two
  files: model_diagnostics with volume/area/length, which is what
  utils.compile_run_output accepts, and vas_diagnostics with the full
  output on top of that (specific mass balance, terminus and maximum
  elevation, response time scales). compile_run_output also reads
  water_level/glen_a/fs unconditionally, so those are written as NaN --
  a volume/area scaling model has no ice dynamics parameters.
- FileModel reads vas_diagnostics, since restarting needs the terminus
  elevation.
- utils.monthly_timeseries and the hydro-year coordinates are gone;
  utils.calendardate_to_hydrodate gives the hydro_year/hydro_month
  coordinates OGGM still expects.

Fixed along the way: an unraised ValueError on an unknown glacier type;
create_start_glacier silently turning ice caps back into glaciers;
FileModel.reset_year_0 reading an attribute that is never set; an empty
start_area_minimization stub; np.NaN (gone in numpy 2); bias defaulting to
None where a number is required.

find_start_area now stops at the end of the climate record when the
inventory date is younger than it, rather than raising.

The initial specific mass balance is only computed when year_0 is inside
the climate record. It is a diagnostic of the last step, and year_0 can
legitimately sit outside the record.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The old suite compared against six OGGM functions that no longer exist
(mb_yearly_climate_on_glacier, mb_yearly_climate_on_height, local_t_star,
t_star_from_refmb, mu_star_calibration, PastMassBalance), and set three
cfg.PARAMS that were removed. The physics tests (terminus temperature,
solid precipitation, min/max elevation, time scales, reset, step) are kept
with their assertions; the rest is rebuilt around the new calibration.

The comparison against OGGM is now MonthlyTIModel, calibrated on the same
reference mass balance as the VAS model. The two specific mass balance
series correlate at 0.93 over 1953-2002 on Hintereisferner (0.13 against
noise), with the VAS model showing less variance -- it melts at a single
terminus temperature rather than integrating over the hypsometry, so its
melt_f is 2.5 against OGGM's 6.7.

Everything runs offline on the demo files: the reference mass balance is a
fixed value rather than WGMS or Hugonnet, so no download is needed.

New tests cover the calibration itself (parameters land in the glacier
settings, the calibrated model reproduces the target), the geodetic
wrapper, the refusal of multiple flowlines, the prcp_clim definition, the
ice cap scaling parameters, find_start_area, the FileModel and the fact
that utils.compile_run_output can read our output.

setup.py: drop the removed data files, declare the real dependencies and
move the python_requires floor to 3.10.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
examples/run_alps.py is the whole workflow on three Alpine glaciers:
prepro L3 elevation band directories, geodetic calibration through OGGM's
task with the VAS mass balance model, a run over 2000-2020, and both
output files.

Verified against the real Hugonnet data: prcp_fac comes out per glacier
from decide_winter_precip_factor (2.96 to 3.75), melt_f between 2.0 and
4.2, and the calibrated model reproduces the target dmdtda to ~1e-13.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
find_start_area silently returned its own bound. The bounds were hard-coded
to [100 m2, 2 x RGI area] and minimize_scalar(method='bounded') reports
success when it converges onto a bound, so Hintereisferner from 1902 with
W5E5 came back as exactly 2 x the RGI area with a 47% area error. The
correct start area is 4.2 x, which was unreachable.

The modelled area at the target year grows monotonically with the start
area, so this is a root find, not a minimisation. It now brackets by
doubling until the solution is inside, then brentq, then checks the match
and raises if it is not good enough. find_start_area returns the area as a
float rather than an OptimizeResult.

run_historic_from_climate_data becomes run_reconstruction: one continuous
run over the whole climate record that passes through the observed area at
the inventory date, rather than imposing the RGI area at an arbitrary start
year the way run_from_climate_data does. Since the RGI date ranges from the
1960s to the 2010s, this is what makes glaciers comparable to each other.
It records the start year, start area and target year in the diagnostics.

mb_calibration_dynamic_from_geodetic_mb calibrates melt_f against the mass
change of the evolving glacier instead of the fixed RGI geometry, using
OGGM's dmdtda convention (mass change over the fixed RGI area and the
period length). It is OGGM's dynamic melt_f calibration, but the spinup is
a 1D root find on the start area instead of a flowline run, so a glacier
takes seconds. Only melt_f is calibrated, as in OGGM. A large melt_f can
demand a start glacier bigger than max_area_factor allows, so the upper
bound is first shrunk to the largest reconstructible melt_f.

Also fixes a circular dependency I introduced earlier: prcp_clim was
averaged over settings['reference_period'], which the calibration itself
writes, so a glacier evolved differently during and after a dynamic
calibration (0.4% different start area, 3.5% different dmdtda). It is now
averaged over the whole climate record, which is stable, better sampled,
and arguably the better climatology for a response time; prcp_clim_period
overrides it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Replaces the earlier status section. The port itself is done and green, but
the 1901 reconstruction comes out far too weak (Hintereisferner 8.82 km2 in
1901 against 8.04 at the inventory date, where Fig. 13 of the 2012 paper has
11.3 in 1920). Two causes are diagnosed and tested but not merged: we
calibrate with temp_bias 0 instead of OGGM's informed prior, and
create_start_glacier re-anchors L_0 to the start year rather than the year of
the area measurement as in Eq. (8), which switches off the terminus feedback
the reconstruction depends on. Together they reproduce Fig. 13.

Also records the gotchas found while testing, the open questions for Ben, and
the recommendation to drop the dynamic calibration.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant