diff --git a/_toc.yml b/_toc.yml index ef1f24dc..a7bb9355 100644 --- a/_toc.yml +++ b/_toc.yml @@ -27,6 +27,7 @@ chapters: - file: notebooks/tutorials/plot_mass_balance - file: notebooks/tutorials/massbalance_global_params - file: notebooks/tutorials/massbalance_perturbation + - file: notebooks/tutorials/specific_mb_climate - file: book/hydro sections: diff --git a/book/massbalance.md b/book/massbalance.md index d856ef32..348d35d2 100644 --- a/book/massbalance.md +++ b/book/massbalance.md @@ -4,3 +4,4 @@ - [](../notebooks/tutorials/massbalance_calibration.ipynb) - [](../notebooks/tutorials/massbalance_global_params.ipynb) - [](../notebooks/tutorials/massbalance_perturbation.ipynb) +- [](../notebooks/tutorials/specific_mb_climate.ipynb) diff --git a/notebooks/tutorials/specific_mb_climate.ipynb b/notebooks/tutorials/specific_mb_climate.ipynb new file mode 100644 index 00000000..c1d11502 --- /dev/null +++ b/notebooks/tutorials/specific_mb_climate.ipynb @@ -0,0 +1,991 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "89068a39", + "metadata": {}, + "source": [ + "# Fast specific mass balance and its gradient: the glacier wide climate series\n", + "\n", + "Calibration, sampling and optimisation routines evaluate the specific (glacier wide) mass balance of the same glacier and period again and again, changing only the mass balance parameters. Calling the mass balance model each time is wasted work: on a fixed geometry, most of the computation does not depend on the parameters.\n", + "\n", + "OGGM's temperature index models (`MonthlyTIModel` and `DailyTIModel`) can therefore give you two short time series, the **glacier wide climate series**, from which the specific mass balance follows for any melt factor and precipitation factor with one line of arithmetic. The same object also gives the **exact gradient** of the specific mass balance with respect to the three calibration parameters `melt_f`, `prcp_fac` and `temp_bias`.\n", + "\n", + "In this tutorial you will learn:\n", + "\n", + "- what the glacier wide climate series are, and how to get them with `get_specific_mb_climate`,\n", + "- how to compute the specific mass balance and its gradient from them,\n", + "- how to use them for Monte Carlo experiments, a sampler, an uncertainty estimate, a linear fit and a gradient-based calibration of all three parameters,\n", + "- what their limits are.\n", + "\n", + "We use the `MonthlyTIModel` for most of the tutorial. Everything works the same with the `DailyTIModel`, as shown at the end.\n", + "\n", + "We assume that you know the basics of the OGGM mass balance models and their calibration, e.g. from the [mass balance calibration tutorial](massbalance_calibration.ipynb)." + ] + }, + { + "cell_type": "markdown", + "id": "5c0c1e32", + "metadata": {}, + "source": [ + "## Set-up" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f448f2ff", + "metadata": {}, + "outputs": [], + "source": [ + "import time\n", + "\n", + "import numpy as np\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "from scipy.optimize import minimize\n", + "\n", + "from oggm import cfg, utils, workflow, tasks, DEFAULT_BASE_URL\n", + "from oggm.core.massbalance import (MonthlyTIModel, DailyTIModel,\n", + " MultipleFlowlineMassBalance, mb_calibration_to_rmsd)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb1a9ca7", + "metadata": {}, + "outputs": [], + "source": [ + "cfg.initialize(logging_level='WARNING')\n", + "cfg.PATHS['working_dir'] = utils.gettempdir('OGGM_specific_mb_climate', reset=True)\n", + "\n", + "# Hintereisferner, from the preprocessed directories\n", + "gdir = workflow.init_glacier_directories(['RGI60-11.00897'], from_prepro_level=3,\n", + " prepro_base_url=DEFAULT_BASE_URL,\n", + " prepro_border=80)[0]" + ] + }, + { + "cell_type": "markdown", + "id": "3e91a014", + "metadata": {}, + "source": [ + "A small helper to measure run times. Timings differ between machines: look at the ratios, not at the absolute numbers." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1069149", + "metadata": {}, + "outputs": [], + "source": [ + "def best_time(func, repeat=5):\n", + " # Fastest of several runs, in seconds\n", + " out = []\n", + " for _ in range(repeat):\n", + " t0 = time.perf_counter()\n", + " func()\n", + " out.append(time.perf_counter() - t0)\n", + " return min(out)" + ] + }, + { + "cell_type": "markdown", + "id": "89be1e67", + "metadata": {}, + "source": [ + "The mass balance model of the preprocessed directory, the glacier geometry (altitudes and widths of the elevation bands), and the period we look at:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b1055dcb", + "metadata": {}, + "outputs": [], + "source": [ + "mb_model = MonthlyTIModel(gdir)\n", + "heights, widths = gdir.get_inversion_flowline_hw()\n", + "years = np.arange(2000, 2020)\n", + "\n", + "# the calibrated parameters, to come back to them later\n", + "calibrated = mb_model.melt_f, mb_model.prcp_fac, mb_model.temp_bias\n", + "print('melt_f = {:.2f}, prcp_fac = {:.2f}, temp_bias = {:.2f}'.format(*calibrated))" + ] + }, + { + "cell_type": "markdown", + "id": "e3755c46", + "metadata": {}, + "source": [ + "## The idea\n", + "\n", + "At each altitude, the temperature index model computes the mass balance of a time step as\n", + "\n", + "$$\\text{MB}(z, t) = P_f \\cdot \\text{prcpsol}(z, t) - d_f \\cdot \\text{tempformelt}(z, t) - \\text{bias}$$\n", + "\n", + "with the precipitation factor $P_f$ (`prcp_fac`), the melt factor $d_f$ (`melt_f`), the solid precipitation `prcpsol` (for $P_f = 1$) and the temperature above the melt threshold `tempformelt`. The specific mass balance is the width-weighted average of this over the glacier. The two factors are the same everywhere, so they can be taken out of the average:\n", + "\n", + "$$\\text{SMB}(t) = P_f \\cdot S(t) - d_f \\cdot M(t) - b(t)$$\n", + "\n", + "- $S(t)$: the glacier average of the solid precipitation, one value per year or month (`prcpsol`).\n", + "- $M(t)$: the glacier average of the temperature above the melt threshold (`tempformelt`).\n", + "- $b(t)$: the residual bias of the model (`bias`): its value for a year, and its share of it for a month.\n", + "\n", + "$S$ and $M$ depend on the geometry, the time steps and the temperature bias, and on nothing else. You ask the model for them once, with `get_specific_mb_climate`. It takes the same arguments as `get_specific_mb`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c8716bd4", + "metadata": {}, + "outputs": [], + "source": [ + "clim = mb_model.get_specific_mb_climate(heights, widths, year=years)\n", + "clim" + ] + }, + { + "cell_type": "markdown", + "id": "937b6a73", + "metadata": {}, + "source": [ + "**You do not have to write the equation yourself.** The object which holds the two series also applies the equation, exactly as the model does, including the bias and its monthly share. Use `clim.get_specific_mb(melt_f, prcp_fac)` rather than your own formula, so that nothing is forgotten:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4abc5b47", + "metadata": {}, + "outputs": [], + "source": [ + "# the specific MB for any melt_f and prcp_fac, without calling the model\n", + "smb = clim.get_specific_mb(melt_f=6.0, prcp_fac=2.5)\n", + "\n", + "# the same from the model\n", + "mb_model.melt_f, mb_model.prcp_fac = 6.0, 2.5\n", + "smb_model = mb_model.get_specific_mb(heights, widths, year=years)\n", + "mb_model.melt_f, mb_model.prcp_fac, _ = calibrated\n", + "\n", + "print(f'Largest difference: {np.abs(smb - smb_model).max():.1e} mm w.e.')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eded0951", + "metadata": {}, + "outputs": [], + "source": [ + "t_model = best_time(lambda: mb_model.get_specific_mb(heights, widths, year=years))\n", + "t_series = best_time(lambda: clim.get_specific_mb(melt_f=6.0, prcp_fac=2.5))\n", + "print(f'One evaluation: {t_model * 1e6:.0f} microseconds with the model, '\n", + " f'{t_series * 1e6:.1f} with the series')" + ] + }, + { + "cell_type": "markdown", + "id": "ac49b50b", + "metadata": {}, + "source": [ + "## What the `SpecificMBClimate` object provides\n", + "\n", + "**The two series**, with one value per time step. They do not depend on `melt_f` and `prcp_fac`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0c35158b", + "metadata": {}, + "outputs": [], + "source": [ + "fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 3.5))\n", + "ax1.plot(clim.years, clim.prcpsol, 'o-')\n", + "ax1.set_title('clim.prcpsol'); ax1.set_ylabel('mm w.e. per year (for prcp_fac = 1)')\n", + "ax2.plot(clim.years, clim.tempformelt, 'o-', color='C3')\n", + "ax2.set_title('clim.tempformelt'); ax2.set_ylabel('K day per year');" + ] + }, + { + "cell_type": "markdown", + "id": "ae54990c", + "metadata": {}, + "source": [ + "**The bias** of each time step, in mm w.e. It is the residual bias of the model (zero for our calibrated model) for a year, and its share of it for a month. We show it with a model which has a bias of 120 mm w.e. per year:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cd2a03ac", + "metadata": {}, + "outputs": [], + "source": [ + "# the 240 months of 2000 to 2019\n", + "months = utils.float_years_timeseries(2000, 2019, include_last_year=True)\n", + "\n", + "mb_bias = MonthlyTIModel(gdir, bias=120)\n", + "print('annual: ', mb_bias.get_specific_mb_climate(heights, widths, year=[2001, 2002]).bias)\n", + "clim_m = mb_bias.get_specific_mb_climate(heights, widths, year=months[:12],\n", + " time_resolution='monthly')\n", + "print('monthly:', clim_m.bias.round(2), '\\nsum of the 12 months:', clim_m.bias.sum())" + ] + }, + { + "cell_type": "markdown", + "id": "1c28906a", + "metadata": {}, + "source": [ + "**The equation**, with the parameters of the model by default, with your own, or with many parameter sets at once (the result then has one row per set):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "919a5693", + "metadata": {}, + "outputs": [], + "source": [ + "print(clim.get_specific_mb()[:3]) # with melt_f and prcp_fac of the model\n", + "print(clim.get_specific_mb(melt_f=6.0, prcp_fac=2.5)[:3]) # with your own\n", + "print(clim.get_specific_mb(melt_f=[5.0, 6.0, 7.0], prcp_fac=2.5).shape) # three sets, 20 years" + ] + }, + { + "cell_type": "markdown", + "id": "3ad04fd1", + "metadata": {}, + "source": [ + "**What the series are valid for**: the time steps, their resolution and the temperature bias. The parameters of the model when the series were computed are there as well (the defaults of `get_specific_mb`):" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c217537a", + "metadata": {}, + "outputs": [], + "source": [ + "print(clim.years[:3], clim.time_resolution, clim.temp_bias)\n", + "print(clim.melt_f, clim.prcp_fac)" + ] + }, + { + "cell_type": "markdown", + "id": "ba10efad", + "metadata": {}, + "source": [ + "## The gradient\n", + "\n", + "`get_specific_mb_gradient` returns the derivatives of the specific mass balance with respect to the three calibration parameters. They are exact: no finite differences are involved. It takes the same parameters as `get_specific_mb`, and each derivative has one value per time step:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f0e1191b", + "metadata": {}, + "outputs": [], + "source": [ + "d_melt_f, d_prcp_fac, d_temp_bias = clim.get_specific_mb_gradient(melt_f=6.0, prcp_fac=2.5)\n", + "\n", + "fig, axs = plt.subplots(1, 3, figsize=(13, 3.2))\n", + "axs[0].plot(years, d_melt_f, 'o-', color='C3')\n", + "axs[0].set_title('d SMB / d melt_f'); axs[0].set_ylabel('mm w.e. per (kg m$^{-2}$ day$^{-1}$ K$^{-1}$)')\n", + "axs[1].plot(years, d_prcp_fac, 'o-')\n", + "axs[1].set_title('d SMB / d prcp_fac'); axs[1].set_ylabel('mm w.e.')\n", + "axs[2].plot(years, d_temp_bias, 'o-', color='C2')\n", + "axs[2].set_title('d SMB / d temp_bias'); axs[2].set_ylabel('mm w.e. per K')\n", + "plt.tight_layout();" + ] + }, + { + "cell_type": "markdown", + "id": "e02c5651", + "metadata": {}, + "source": [ + "Where do they come from?\n", + "\n", + "- **`melt_f` and `prcp_fac`.** The equation is linear in them: the derivatives are `-clim.tempformelt` and `clim.prcpsol`, and do not depend on the values of the two parameters.\n", + "- **`temp_bias`.** The two series depend on the temperature bias, and not linearly. With their derivatives,\n", + "\n", + "$$\\frac{\\partial\\,\\text{SMB}}{\\partial T_{bias}} = P_f \\cdot \\frac{\\partial S}{\\partial T_{bias}} - d_f \\cdot \\frac{\\partial M}{\\partial T_{bias}}$$\n", + "\n", + "The derivatives of the two series are simple to state. One degree more adds one degree to `tempformelt` for every day and grid point which is above the melt threshold, and takes away a part of the snow where the temperature is between the two thresholds for snow and rain. The mass balance model computes them together with the series (`clim.d_tempformelt` and `clim.d_prcpsol`).\n", + "\n", + "A warming always means less mass: the derivative with respect to `temp_bias` is negative. For this glacier, one degree costs about this much per year:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1985e9ba", + "metadata": {}, + "outputs": [], + "source": [ + "print(f'Mean of d SMB / d temp_bias: {d_temp_bias.mean():.0f} mm w.e. per K')" + ] + }, + { + "cell_type": "markdown", + "id": "8351ff2a", + "metadata": {}, + "source": [ + "It is a good habit to check a gradient once against finite differences. Here with the model itself, for the temperature bias:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ce0c3fae", + "metadata": {}, + "outputs": [], + "source": [ + "def smb_of_model(temp_bias, melt_f=6.0, prcp_fac=2.5):\n", + " mb_model.melt_f, mb_model.prcp_fac, mb_model.temp_bias = melt_f, prcp_fac, temp_bias\n", + " out = mb_model.get_specific_mb(heights, widths, year=years)\n", + " mb_model.melt_f, mb_model.prcp_fac, mb_model.temp_bias = calibrated\n", + " return out\n", + "\n", + "eps = 1e-5\n", + "tb = clim.temp_bias\n", + "finite_difference = (smb_of_model(tb + eps) - smb_of_model(tb - eps)) / (2 * eps)\n", + "print(f'Largest difference to the finite differences: '\n", + " f'{np.abs(d_temp_bias - finite_difference).max():.1e} mm w.e. per K')" + ] + }, + { + "cell_type": "markdown", + "id": "8199c652", + "metadata": {}, + "source": [ + "### When are the derivatives computed?\n", + "\n", + "The derivatives of the two series are only needed for the gradient with respect to `temp_bias`. By default they are computed by the mass balance model at the first call of `get_specific_mb_gradient` (what happened above). If you know that you need them, ask for them directly with `derivatives=True`: the series and their derivatives are then computed together." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bdedd719", + "metadata": {}, + "outputs": [], + "source": [ + "print(mb_model.get_specific_mb_climate(heights, widths, year=years))\n", + "print(mb_model.get_specific_mb_climate(heights, widths, year=years, derivatives=True))" + ] + }, + { + "cell_type": "markdown", + "id": "b985b121", + "metadata": {}, + "source": [ + "## Another temperature bias\n", + "\n", + "The two series are valid for **one** temperature bias, the one the model had when they were computed (`clim.temp_bias`). Both methods accept another one as third parameter:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5cdfca2b", + "metadata": {}, + "outputs": [], + "source": [ + "smb_warm = clim.get_specific_mb(melt_f=6.0, prcp_fac=2.5, temp_bias=1.0)\n", + "print(f'Largest difference to the model: {np.abs(smb_warm - smb_of_model(1.0)).max():.1e} mm w.e.')\n", + "\n", + "plt.plot(years, clim.get_specific_mb(melt_f=6.0, prcp_fac=2.5), label=f'temp_bias = {clim.temp_bias:.0f} K')\n", + "plt.plot(years, smb_warm, label='temp_bias = 1 K')\n", + "plt.ylabel('Specific mass balance (mm w.e.)'); plt.legend();" + ] + }, + { + "cell_type": "markdown", + "id": "89652f48", + "metadata": {}, + "source": [ + "What happens then:\n", + "\n", + "- The object asks the mass balance model for the series of this temperature bias. It kept the model and the geometry for this. **The model is not changed**: its own `temp_bias` stays what it was.\n", + "- Such a call is not free: it costs about as much as one call of `get_specific_mb` of the model. Calls with the temperature bias of the object only apply the equation.\n", + "- The object remembers the series of the *last* other temperature bias. Asking for the value and then for the gradient with the same temperature bias needs one computation, as an optimiser does.\n", + "- `temp_bias` has to be a single value, where `melt_f` and `prcp_fac` can be arrays." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c8be24d", + "metadata": {}, + "outputs": [], + "source": [ + "print('temp_bias of the model, before and after:', calibrated[2], mb_model.temp_bias)\n", + "\n", + "# a new temperature bias at each call, and the same one again\n", + "tbs = iter(np.linspace(-2, 2, 1000))\n", + "t_new = best_time(lambda: clim.get_specific_mb(6.0, 2.5, temp_bias=next(tbs)), repeat=200)\n", + "t_same = best_time(lambda: clim.get_specific_mb(6.0, 2.5, temp_bias=1.0), repeat=200)\n", + "t_own = best_time(lambda: clim.get_specific_mb(6.0, 2.5), repeat=200)\n", + "print(f'One evaluation: new temp_bias {t_new * 1e6:.0f}, the same again {t_same * 1e6:.1f}, '\n", + " f'temp_bias of the object {t_own * 1e6:.1f} microseconds')" + ] + }, + { + "cell_type": "markdown", + "id": "37de3df5", + "metadata": {}, + "source": [ + "So the rule is the same as everywhere with these models: `melt_f` and `prcp_fac` are cheap to change, `temp_bias` is not. But even a new temperature bias is not slower than with the model in the loop, and you get the gradient with it.\n", + "\n", + "## What it is good for\n", + "\n", + "For the examples we need observations. We take the annual mass balance which was measured on Hintereisferner. In the first examples we compare it with the modelled mass balance of the calendar years 2000 to 2019, to keep them short. The measurements are for hydrological years: the last example shows how to do it properly." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e512ca55", + "metadata": {}, + "outputs": [], + "source": [ + "ref_mb = gdir.get_ref_mb_data()['ANNUAL_BALANCE']\n", + "observations = ref_mb.loc[2000:2019].values\n", + "assert len(observations) == len(years)\n", + "\n", + "plt.plot(years, observations, 'o-', color='k', label='observations')\n", + "plt.plot(years, clim.get_specific_mb(), label='MonthlyTIModel (calibrated on the geodetic MB)')\n", + "plt.ylabel('Specific mass balance (mm w.e.)'); plt.legend();" + ] + }, + { + "cell_type": "markdown", + "id": "9fba688b", + "metadata": {}, + "source": [ + "### Monte Carlo experiments\n", + "\n", + "These need very many evaluations ($10^5$ to $10^6$ parameter sets). With the series, one evaluation is two multiplications on short arrays, and many parameter sets can be evaluated in one call. We evaluate 100000 parameter sets with the series. With the model in the loop we only time 200 of them and extrapolate, because all of them would take too long:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20162107", + "metadata": {}, + "outputs": [], + "source": [ + "rng = np.random.default_rng(0)\n", + "n = 100_000\n", + "melt_f = rng.uniform(3, 12, n)\n", + "prcp_fac = rng.uniform(1, 4, n)\n", + "\n", + "t0 = time.perf_counter()\n", + "smb_all = clim.get_specific_mb(melt_f, prcp_fac) # shape (100000, 20)\n", + "rmsd = np.sqrt(((smb_all - observations) ** 2).mean(axis=1))\n", + "t_series = time.perf_counter() - t0\n", + "\n", + "# the same with the model in the loop, for 200 of them\n", + "def model_in_the_loop():\n", + " for mf, pf in zip(melt_f[:200], prcp_fac[:200]):\n", + " mb_model.melt_f, mb_model.prcp_fac = mf, pf\n", + " mb_model.get_specific_mb(heights, widths, year=years)\n", + "t_model_200 = best_time(model_in_the_loop, 3)\n", + "mb_model.melt_f, mb_model.prcp_fac, _ = calibrated\n", + "\n", + "print(f'With the series: {t_series:.3f} s for all {n} parameter sets (measured).')\n", + "print(f'With the model in the loop: {t_model_200:.3f} s for 200 parameter sets (measured), '\n", + " f'which would be about {t_model_200 / 200 * n:.0f} s for all {n} (extrapolated).')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fad7a49b", + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plt.subplots(figsize=(6, 4))\n", + "sc = ax.scatter(melt_f[::20], prcp_fac[::20], c=rmsd[::20], s=4, vmax=1500)\n", + "plt.colorbar(sc, label='RMSD to the observations (mm w.e.)')\n", + "ax.set_xlabel('melt_f'); ax.set_ylabel('prcp_fac');" + ] + }, + { + "cell_type": "markdown", + "id": "cc8d841f", + "metadata": {}, + "source": [ + "### Bayesian sampling\n", + "\n", + "A sampler works the same way. Here is a minimal Metropolis sampler of the two parameters, with a Gaussian likelihood (we assume an uncertainty of the observations of 300 mm w.e.) and flat priors inside of bounds. It is only meant to show where `clim.get_specific_mb` goes; for real applications use a tested sampling package. Gradient-based samplers (such as Hamiltonian Monte Carlo) can use `get_specific_mb_gradient` in the same way." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fdfc4b9c", + "metadata": {}, + "outputs": [], + "source": [ + "bounds_2 = np.array([[1.5, 17], [0.1, 10]]) # melt_f, prcp_fac\n", + "sigma = 300.\n", + "\n", + "def log_prob(x):\n", + " if np.any(x < bounds_2[:, 0]) or np.any(x > bounds_2[:, 1]):\n", + " return -np.inf\n", + " smb = clim.get_specific_mb(melt_f=x[0], prcp_fac=x[1])\n", + " return -0.5 * np.sum(((smb - observations) / sigma) ** 2)\n", + "\n", + "rng = np.random.default_rng(1)\n", + "x = np.array([8., 3.])\n", + "lp = log_prob(x)\n", + "chain = np.empty((20_000, 2))\n", + "t0 = time.perf_counter()\n", + "for k in range(len(chain)):\n", + " proposal = x + rng.normal(0, [0.3, 0.1])\n", + " lp_proposal = log_prob(proposal)\n", + " if np.log(rng.uniform()) < lp_proposal - lp:\n", + " x, lp = proposal, lp_proposal\n", + " chain[k] = x\n", + "print(f'{len(chain)} steps in {time.perf_counter() - t0:.2f} s')\n", + "\n", + "chain = chain[2000:] # without the burn-in\n", + "fig, ax = plt.subplots(figsize=(5, 4))\n", + "ax.plot(chain[::10, 0], chain[::10, 1], '.', markersize=2)\n", + "ax.set_xlabel('melt_f'); ax.set_ylabel('prcp_fac'); ax.set_title('Samples of the posterior');" + ] + }, + { + "cell_type": "markdown", + "id": "8eb621db", + "metadata": {}, + "source": [ + "### Sensitivity and uncertainty\n", + "\n", + "The gradient tells how much the specific mass balance changes when a parameter changes a little: it is the **sensitivity** of the mass balance to each parameter. This is what is needed to answer the question *\"my parameters are uncertain, how uncertain is my mass balance?\"*, with a method called first order (or linear) error propagation.\n", + "\n", + "**The method.** Close to a parameter set $p = (d_f, P_f, T_{bias})$, the specific mass balance of a year changes approximately linearly with a small change $\\delta p$ of the parameters:\n", + "\n", + "$$\\text{SMB}(p + \\delta p) \\approx \\text{SMB}(p) + \\frac{\\partial\\,\\text{SMB}}{\\partial d_f}\\,\\delta d_f + \\frac{\\partial\\,\\text{SMB}}{\\partial P_f}\\,\\delta P_f + \\frac{\\partial\\,\\text{SMB}}{\\partial T_{bias}}\\,\\delta T_{bias}$$\n", + "\n", + "Now assume that we do not know the parameters exactly: each one has an uncertainty, given as a standard deviation ($\\sigma_{d_f}$, $\\sigma_{P_f}$, $\\sigma_{T_{bias}}$). Each term of the sum is then uncertain too, with a standard deviation of *sensitivity times uncertainty of the parameter*: this is the **contribution** of this parameter to the uncertainty of the mass balance. If the errors of the three parameters are independent of each other, the variances of the three terms add up:\n", + "\n", + "$$\\sigma_{\\text{SMB}}^2 = \\left(\\frac{\\partial\\,\\text{SMB}}{\\partial d_f}\\,\\sigma_{d_f}\\right)^2 + \\left(\\frac{\\partial\\,\\text{SMB}}{\\partial P_f}\\,\\sigma_{P_f}\\right)^2 + \\left(\\frac{\\partial\\,\\text{SMB}}{\\partial T_{bias}}\\,\\sigma_{T_{bias}}\\right)^2$$\n", + "\n", + "All of this holds for each year separately, because the gradient has one value per year.\n", + "\n", + "**What you need for it** is one call of `get_specific_mb_gradient` and the uncertainties of the parameters. The values below are made up for the example; in a real application they come from the calibration (e.g. from a sampler as above)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ca37418a", + "metadata": {}, + "outputs": [], + "source": [ + "# the sensitivities, for the calibrated parameters\n", + "d_melt_f, d_prcp_fac, d_temp_bias = clim.get_specific_mb_gradient()\n", + "# the assumed uncertainties (standard deviations) of the three parameters\n", + "sigma_melt_f, sigma_prcp_fac, sigma_temp_bias = 0.5, 0.2, 0.5\n", + "\n", + "# the contribution of each parameter: sensitivity times uncertainty\n", + "parts = {'melt_f': d_melt_f * sigma_melt_f,\n", + " 'prcp_fac': d_prcp_fac * sigma_prcp_fac,\n", + " 'temp_bias': d_temp_bias * sigma_temp_bias}\n", + "# independent errors: the variances add up\n", + "sigma_smb = np.sqrt(sum(p ** 2 for p in parts.values()))\n", + "\n", + "fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 3.5))\n", + "smb = clim.get_specific_mb()\n", + "ax1.fill_between(years, smb - sigma_smb, smb + sigma_smb, alpha=0.3)\n", + "ax1.plot(years, smb); ax1.set_ylabel('Specific mass balance (mm w.e.)')\n", + "ax1.set_xticks(years[::5]); ax2.set_xticks(years[::5])\n", + "for name, p in parts.items():\n", + " ax2.plot(years, np.abs(p), label=name)\n", + "ax2.set_ylabel('Contribution to the uncertainty (mm w.e.)'); ax2.legend();" + ] + }, + { + "cell_type": "markdown", + "id": "e1997a0b", + "metadata": {}, + "source": [ + "The left plot shows the specific mass balance with its uncertainty (plus and minus one standard deviation), the right plot what each parameter contributes to it. With the uncertainties we assumed, the temperature bias matters most and the precipitation factor least. Note that this ranking depends on the assumed uncertainties as much as on the sensitivities.\n", + "\n", + "**Is the linear approximation good enough?** We can check it with a Monte Carlo experiment: draw many parameter sets from normal distributions with these standard deviations, compute the specific mass balance of each one, and look at the spread of the results. This needs no approximation, but many evaluations, and a new series for each temperature bias:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40bc886c", + "metadata": {}, + "outputs": [], + "source": [ + "rng = np.random.default_rng(3)\n", + "n_mc = 2000\n", + "mf_mc = rng.normal(calibrated[0], sigma_melt_f, n_mc)\n", + "pf_mc = rng.normal(calibrated[1], sigma_prcp_fac, n_mc)\n", + "tb_mc = rng.normal(calibrated[2], sigma_temp_bias, n_mc)\n", + "\n", + "t0 = time.perf_counter()\n", + "smb_mc = np.array([clim.get_specific_mb(mf, pf, tb) for mf, pf, tb in zip(mf_mc, pf_mc, tb_mc)])\n", + "print(f'{n_mc} parameter sets in {time.perf_counter() - t0:.2f} s')\n", + "\n", + "plt.plot(years, sigma_smb, 'o-', label='error propagation with the gradient (one call)')\n", + "plt.plot(years, smb_mc.std(axis=0), 's--', label=f'Monte Carlo ({n_mc} parameter sets)')\n", + "plt.ylabel('Uncertainty of the specific MB (mm w.e.)'); plt.xticks(years[::5]); plt.legend()\n", + "print(f'Mean ratio of the two: {(sigma_smb / smb_mc.std(axis=0)).mean():.3f}')" + ] + }, + { + "cell_type": "markdown", + "id": "2d82de2e", + "metadata": {}, + "source": [ + "The two agree within the sampling noise of the Monte Carlo experiment (a standard deviation estimated from 2000 samples is itself uncertain by one to two percent). For these uncertainties the linear approximation is good, and it needs one call of the gradient instead of thousands of evaluations.\n", + "\n", + "**The limits of the method.**\n", + "\n", + "- It is a *first order* method. The specific mass balance is exactly linear in `melt_f` and `prcp_fac` when they change one at a time, but not in `temp_bias`, and not when several parameters change together (the product `melt_f * tempformelt` changes with both). The larger the uncertainties, the less accurate the linear approximation.\n", + "- We assumed **independent** errors. Calibrated parameters are usually strongly correlated: a larger `melt_f` can be compensated by a larger `prcp_fac`, as the sampler above shows. Their errors then partly cancel, and the formula above overestimates the uncertainty. With the covariance matrix $C$ of the parameters (e.g. from the samples of a sampler) and the gradient $g$ of a year, the general formula is $\\sigma_{\\text{SMB}}^2 = g^T C\\, g$." + ] + }, + { + "cell_type": "markdown", + "id": "eed9636d", + "metadata": {}, + "source": [ + "### Fitting `melt_f` and `prcp_fac` is a linear regression\n", + "\n", + "For a least squares fit of these two parameters without bounds, no optimiser is needed at all: the best `melt_f` and `prcp_fac` are the solution of a linear system." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eeee2553", + "metadata": {}, + "outputs": [], + "source": [ + "A = np.column_stack([clim.prcpsol, -clim.tempformelt])\n", + "(prcp_fac_fit, melt_f_fit), *_ = np.linalg.lstsq(A, observations + clim.bias, rcond=None)\n", + "rmsd_fit = np.sqrt(np.mean((clim.get_specific_mb(melt_f_fit, prcp_fac_fit) - observations) ** 2))\n", + "print(f'melt_f = {melt_f_fit:.3f}, prcp_fac = {prcp_fac_fit:.3f}, RMSD = {rmsd_fit:.1f} mm w.e.')" + ] + }, + { + "cell_type": "markdown", + "id": "ce0cb712", + "metadata": {}, + "source": [ + "### Calibrating all three parameters with the gradient\n", + "\n", + "Now the full problem: `melt_f`, `prcp_fac` and `temp_bias` together, with bounds, and done properly with **hydrological years**. The observations are annual values of hydrological years (October to September in the northern hemisphere), so we need the modelled mass balance at monthly resolution, and sum the twelve months of each hydrological year.\n", + "\n", + "First the months, as one long series, and the climate series for them. We ask for the derivatives directly:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f6a3c501", + "metadata": {}, + "outputs": [], + "source": [ + "obs_h = ref_mb.loc[:2019]\n", + "y0, y1 = obs_h.index[0], obs_h.index[-1]\n", + "assert len(obs_h) == y1 - y0 + 1 # no gaps\n", + "print(f'{len(obs_h)} hydrological years, {y0} to {y1}')\n", + "\n", + "# all months from January y0 - 1 to December y1, then October y0 - 1 to September y1\n", + "hydro_months = utils.float_years_timeseries(y0 - 1, y1, include_last_year=True)[9:-3]\n", + "print(utils.floatyear_to_date(hydro_months[0]), 'to', utils.floatyear_to_date(hydro_months[-1]))\n", + "\n", + "clim_h = mb_model.get_specific_mb_climate(heights, widths, year=hydro_months,\n", + " time_resolution='monthly', derivatives=True)\n", + "\n", + "def to_hydro_years(monthly):\n", + " # the sum of the twelve months of each hydrological year\n", + " return monthly.reshape(-1, 12).sum(axis=1)" + ] + }, + { + "cell_type": "markdown", + "id": "89cad926", + "metadata": {}, + "source": [ + "As cost we take the mean squared difference to the observations $o$:\n", + "\n", + "$$J(d_f, P_f, T_{bias}) = \\frac{1}{N} \\sum_y r_y^2, \\qquad r_y = \\text{SMB}_y - o_y$$\n", + "\n", + "The chain rule gives its gradient from the gradient of the specific mass balance, for each parameter $p$:\n", + "\n", + "$$\\frac{\\partial J}{\\partial p} = \\frac{2}{N} \\sum_y r_y \\, \\frac{\\partial\\,\\text{SMB}_y}{\\partial p}$$\n", + "\n", + "`scipy.optimize.minimize` accepts a function which returns the cost and its gradient (`jac=True`). With the method `L-BFGS-B` bounds can be given: we take the ones of the OGGM settings." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bb5e7ea3", + "metadata": {}, + "outputs": [], + "source": [ + "names = ['melt_f', 'prcp_fac', 'temp_bias']\n", + "bounds = [(gdir.settings[f'{k}_min'], gdir.settings[f'{k}_max']) for k in names]\n", + "print(dict(zip(names, bounds)))\n", + "\n", + "n_calls = [0]\n", + "\n", + "def cost_and_gradient(x):\n", + " n_calls[0] += 1\n", + " melt_f, prcp_fac, temp_bias = x\n", + " r = to_hydro_years(clim_h.get_specific_mb(melt_f, prcp_fac, temp_bias)) - obs_h.values\n", + " grad = [2 * np.mean(r * to_hydro_years(g))\n", + " for g in clim_h.get_specific_mb_gradient(melt_f, prcp_fac, temp_bias)]\n", + " return np.mean(r ** 2), np.array(grad)\n", + "\n", + "x0 = [5.0, 2.5, 0.0]\n", + "\n", + "def with_gradient():\n", + " n_calls[0] = 0\n", + " return minimize(cost_and_gradient, x0=x0, jac=True, method='L-BFGS-B', bounds=bounds)\n", + "\n", + "res = with_gradient()\n", + "t_gradient = best_time(with_gradient, 3)\n", + "print(f'melt_f = {res.x[0]:.3f}, prcp_fac = {res.x[1]:.3f}, temp_bias = {res.x[2]:.3f}, '\n", + " f'RMSD = {np.sqrt(res.fun):.1f} mm w.e.')\n", + "print(f'{n_calls[0]} evaluations, {t_gradient:.3f} s')" + ] + }, + { + "cell_type": "markdown", + "id": "79b668af", + "metadata": {}, + "source": [ + "For comparison, the same minimisation without the gradient (the optimiser then estimates it with finite differences, which needs four evaluations instead of one), and OGGM's `mb_calibration_to_rmsd`, which uses a global optimiser (differential evolution) with the model in the loop:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "74e2ab56", + "metadata": {}, + "outputs": [], + "source": [ + "def cost_with_model(x):\n", + " n_calls[0] += 1\n", + " mb_model.melt_f, mb_model.prcp_fac, mb_model.temp_bias = x\n", + " smb = mb_model.get_specific_mb(heights, widths, year=hydro_months, time_resolution='monthly')\n", + " return np.mean((to_hydro_years(smb) - obs_h.values) ** 2)\n", + "\n", + "def without_gradient():\n", + " n_calls[0] = 0\n", + " return minimize(cost_with_model, x0=x0, method='L-BFGS-B', bounds=bounds)\n", + "\n", + "res_fd = without_gradient()\n", + "n_fd = n_calls[0]\n", + "t_fd = best_time(without_gradient, 3)\n", + "mb_model.melt_f, mb_model.prcp_fac, mb_model.temp_bias = calibrated\n", + "\n", + "t0 = time.perf_counter()\n", + "out = mb_calibration_to_rmsd(gdir, ref_df=obs_h, calibrate_params=tuple(names),\n", + " write_to_gdir=False, optimisation_kwargs={'seed': 42})\n", + "t_de = time.perf_counter() - t0\n", + "\n", + "df = pd.DataFrame(\n", + " [[*res.x, np.sqrt(res.fun), res.nfev, t_gradient],\n", + " [*res_fd.x, np.sqrt(res_fd.fun), n_fd, t_fd],\n", + " [out['melt_f'], out['prcp_fac'], out['temp_bias'], out['rmsd'], np.nan, t_de]],\n", + " columns=names + ['RMSD (mm w.e.)', 'evaluations', 'time (s)'],\n", + " index=['L-BFGS-B with the gradient', 'L-BFGS-B, finite differences, model in the loop',\n", + " 'mb_calibration_to_rmsd (differential evolution)'])\n", + "df.round(3)" + ] + }, + { + "cell_type": "markdown", + "id": "81d27913", + "metadata": {}, + "source": [ + "**A word of caution.** `L-BFGS-B` is a *local* optimiser: it walks downhill from the first guess. This calibration problem is known to be badly constrained (quite different parameter sets fit the observations almost equally well), and the cost is not guaranteed to have a single minimum. Differential evolution searches the whole range of the parameters, which is why it needs so many evaluations. A cheap way to gain confidence with a local optimiser is to start it from several first guesses, which the fast gradient makes affordable:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d70b5bf4", + "metadata": {}, + "outputs": [], + "source": [ + "rng = np.random.default_rng(2)\n", + "starts = []\n", + "n_calls[0] = 0\n", + "t0 = time.perf_counter()\n", + "for _ in range(20):\n", + " x_start = [rng.uniform(lo, hi) for lo, hi in bounds]\n", + " r = minimize(cost_and_gradient, x0=x_start, jac=True, method='L-BFGS-B', bounds=bounds)\n", + " starts.append([*x_start, *r.x, np.sqrt(r.fun)])\n", + "print(f'20 minimisations in {time.perf_counter() - t0:.2f} s, {n_calls[0]} evaluations')\n", + "\n", + "starts = pd.DataFrame(starts, columns=[f'start {k}' for k in names] + names + ['RMSD'])\n", + "n_best = (starts.RMSD < starts.RMSD.min() + 1).sum()\n", + "print(f'{n_best} of {len(starts)} starts end at the best RMSD of {starts.RMSD.min():.1f} mm w.e.')\n", + "starts.sort_values('RMSD').round(3)" + ] + }, + { + "cell_type": "markdown", + "id": "9ea289ec", + "metadata": {}, + "source": [ + "Most starts end at the same minimum, the one which differential evolution found. The others end at the bounds of the parameters, with a much larger RMSD. They got into a region where the temperature bias is so low that there is no melt at all: the cost is flat there, the gradient is zero, and a local optimiser has nothing to follow. Such a result is easy to recognise (parameters at their bounds, a poor fit), but only if you look.\n", + "\n", + "So: start from sensible values (as the first guess above), or take the best of several starts. Twenty minimisations with the gradient take about as long as one run of differential evolution." + ] + }, + { + "cell_type": "markdown", + "id": "aa16287b", + "metadata": {}, + "source": [ + "## With the `DailyTIModel`\n", + "\n", + "The `DailyTIModel` has the same method, with the same object as result. It needs daily climate data and its own calibration (see the [tutorial on the daily model and its mass balance profiles](daily_mb_profiles.ipynb)). We create it twice: computing from all the days (the default), and with the mass balance profiles." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c5548b13", + "metadata": {}, + "outputs": [], + "source": [ + "tasks.process_gswp3_w5e5_data(gdir, daily=True)\n", + "gdir.create_new_settings('_daily', parent_filesuffix='', data={'use_mb_profiles': True})\n", + "tasks.process_mb_profiles(gdir, settings_filesuffix='_daily')\n", + "tasks.mb_calibration_from_geodetic_mb(gdir, settings_filesuffix='_daily',\n", + " observations_filesuffix='_daily',\n", + " mb_model_class=DailyTIModel, overwrite_gdir=True)\n", + "\n", + "mb_daily = DailyTIModel(gdir, settings_filesuffix='_daily') # with profiles\n", + "mb_days = DailyTIModel(gdir, settings_filesuffix='_daily', use_mb_profiles=False)\n", + "\n", + "clim_d = mb_daily.get_specific_mb_climate(heights, widths, year=years)\n", + "smb_d = clim_d.get_specific_mb(melt_f=6.0, prcp_fac=2.5, temp_bias=0.5)\n", + "\n", + "mb_daily.melt_f, mb_daily.prcp_fac, mb_daily.temp_bias = 6.0, 2.5, 0.5\n", + "print('Largest difference to the model: '\n", + " f'{np.abs(smb_d - mb_daily.get_specific_mb(heights, widths, year=years)).max():.1e} mm w.e.')" + ] + }, + { + "cell_type": "markdown", + "id": "a5f4bee2", + "metadata": {}, + "source": [ + "Once you have the series, an evaluation costs the same whatever the model: the daily model is then as fast as the monthly one. What differs is the time to compute the series, which is also the cost of each new temperature bias. Here for the 240 months of 2000 to 2019, with the derivatives:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6f3f4d7e", + "metadata": {}, + "outputs": [], + "source": [ + "models = {'MonthlyTIModel': mb_model,\n", + " 'DailyTIModel, profiles': mb_daily,\n", + " 'DailyTIModel, all days': mb_days}\n", + "rows = []\n", + "for name, mod in models.items():\n", + " c = mod.get_specific_mb_climate(heights, widths, year=months, time_resolution='monthly',\n", + " derivatives=True)\n", + " tbs = iter(np.linspace(-2, 2, 100))\n", + " rows.append([\n", + " 1e3 * best_time(lambda: mod.get_specific_mb(heights, widths, year=months,\n", + " time_resolution='monthly')),\n", + " 1e3 * best_time(lambda: (c.get_specific_mb(6.0, 2.5), c.get_specific_mb_gradient(6.0, 2.5))),\n", + " 1e3 * best_time(lambda: [f(6.0, 2.5, tb) for tb in [next(tbs)]\n", + " for f in (c.get_specific_mb, c.get_specific_mb_gradient)]),\n", + " ])\n", + "pd.DataFrame(rows, index=list(models),\n", + " columns=['get_specific_mb of the model (ms)',\n", + " 'value and gradient from the series (ms)',\n", + " 'the same for a new temp_bias (ms)']).round(3)" + ] + }, + { + "cell_type": "markdown", + "id": "87eabc93", + "metadata": {}, + "source": [ + "- **From the series**, the value and the gradient cost the same for all models, and far less than a call of the model.\n", + "- **A new temperature bias** costs about as much as a call of the model for the `MonthlyTIModel`. For the `DailyTIModel`, the mass balance profiles make it several times cheaper than the computation from all the days. Even from all the days it is cheaper than `get_specific_mb` of the model, because the series are computed for all time steps at once.\n", + "- The first column of the `DailyTIModel` with profiles is this low because the model remembers its last series (the series cache) and the parameters did not change between the calls." + ] + }, + { + "cell_type": "markdown", + "id": "6f5c266d", + "metadata": {}, + "source": [ + "## Glaciers with several flowlines\n", + "\n", + "For several flowlines, use the `MultipleFlowlineMassBalance`, which has the same method. It takes the flowlines instead of altitudes and widths, and returns one object for the whole glacier:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "10af00d0", + "metadata": {}, + "outputs": [], + "source": [ + "mb_multi = MultipleFlowlineMassBalance(gdir, mb_model_class=MonthlyTIModel,\n", + " use_inversion_flowlines=True)\n", + "clim_multi = mb_multi.get_specific_mb_climate(year=years)\n", + "print('Largest difference to the model: '\n", + " f'{np.abs(clim_multi.get_specific_mb() - mb_multi.get_specific_mb(year=years)).max():.1e} mm w.e.')" + ] + }, + { + "cell_type": "markdown", + "id": "e9d46c45", + "metadata": {}, + "source": [ + "## Good to know\n", + "\n", + "- **One geometry.** The series are valid for the altitudes and widths they were computed with. When the geometry changes (e.g. during a dynamical run), call `get_specific_mb_climate` again.\n", + "- **Glacier wide only.** The series give the specific mass balance, not the mass balance at each altitude.\n", + "- **No monthly parameters in the model.** OGGM's temperature index models accept 12 monthly values for their `temp_bias` and `prcp_fac` (not for `melt_f`). `get_specific_mb_climate` does not work with such a model: both have to be single values.\n", + "- **Arrays of parameters.** `get_specific_mb` and `get_specific_mb_gradient` accept arrays for `melt_f` and `prcp_fac`, to evaluate many parameter sets at once. `temp_bias` has to be a single value in each call, because each temperature bias needs its own series.\n", + "- **Several flowlines** need the same `melt_f`, `prcp_fac` and `bias` for all of them.\n", + "- **Kinks.** The specific mass balance is a continuous function of the temperature bias, but its derivative jumps where a time step of a grid point is exactly at a temperature threshold. There, the derivative towards lower temperatures is returned. This never showed up as a problem in the optimisations above.\n", + "- **Which models.** The `MonthlyTIModel`, the `DailyTIModel` (with or without mass balance profiles) and the `MultipleFlowlineMassBalance` of the two.\n", + "- **Memory.** The series have one value per time step, whatever the number of grid points. This also holds for 2D geometries with many glacier pixels.\n", + "- **Other tools.** The series are small arrays which are easily saved and used in a calibration written in another tool or programming language.\n", + "\n", + "## What's next?\n", + "\n", + "- look at the [tutorial on the daily mass balance model and its mass balance profiles](daily_mb_profiles.ipynb)\n", + "- look at the [mass balance calibration tutorial](massbalance_calibration.ipynb)\n", + "- return to the [OGGM documentation](https://docs.oggm.org)\n", + "- back to the [table of contents](../welcome.ipynb)" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/welcome.ipynb b/notebooks/welcome.ipynb index 01816c29..df06f8c5 100644 --- a/notebooks/welcome.ipynb +++ b/notebooks/welcome.ipynb @@ -68,7 +68,8 @@ "- [Plotting the OGGM surface mass-balance, the ELA and AAR](tutorials/plot_mass_balance.ipynb)\n", "- [A look into the new mass balance calibration in OGGM v1.6](tutorials/massbalance_calibration.ipynb)\n", "- [Global distribution of the mass-balance model parameters](tutorials/massbalance_global_params.ipynb)\n", - "- [Mass balance parameter perturbation experiments with OGGM](tutorials/massbalance_perturbation.ipynb)" + "- [Mass balance parameter perturbation experiments with OGGM](tutorials/massbalance_perturbation.ipynb)\n", + "- [Fast specific mass balance and its gradient: the glacier wide climate series](tutorials/specific_mb_climate.ipynb)" ] }, {