Modeling snow#

R.A. Collenteur, University of Graz / Eawag, November 2021

In this notebook it is shown how to account for snowfall and smowmelt on groundwater recharge and groundwater levels, using a degree-day snow model. This notebook is work in progress and will be extended in the future.

import matplotlib.pyplot as plt
import pandas as pd

import pastas as ps

ps.set_log_level("ERROR")
ps.show_versions()
Pastas     : 2.0.0
Python     : 3.14.6
Numpy      : 2.4.6
Pandas     : 3.0.5
Scipy      : 1.18.0
Matplotlib : 3.11.1
Numba      : 0.66.0

1. Load data#

In this notebook we will look at some data for a well near Heby, Sweden. All the meteorological data is taken from the E-OBS database. As can be observed from the temperature time series, the temperature regularly drops below zero in winter. Given this observation, we may expect precipitation to (partially) fall as snow during these periods.

head = pd.read_csv("data/heby_head.csv", index_col=0, parse_dates=True).squeeze()
evap = pd.read_csv("data/heby_evap.csv", index_col=0, parse_dates=True).squeeze()
prec = pd.read_csv("data/heby_prec.csv", index_col=0, parse_dates=True).squeeze()
temp = pd.read_csv("data/heby_temp.csv", index_col=0, parse_dates=True).squeeze()

ps.plots.series(head, stresses=[prec, evap, temp]);
../_images/fd1dd58a9cc7680203daa739b1f80abfa97c79b997681cc420c574e596317eaf.png

2. Make a simple model#

First we create a simple model with precipitation and potential evaporation as input, using the non-linear FlexModel to compute the recharge flux. We not not yet take snowfall into account, and thus assume all precipitation occurs as snowfall. The model is calibrated and the results are visualized for inspection.

# Settings
tmin = "1985"  # Needs warmup
tmax = "2010"
ml1 = ps.Model(head)
sm1 = ps.RechargeModel(
    ml1, prec, evap, recharge=ps.rch.FlexModel(), rfunc=ps.Gamma(), name="rch"
)

# Solve the Pastas model in two steps
ml1.solve(tmin=tmin, tmax=tmax, fit_constant=False, report=False)
ps.ArNoiseModel(model=ml1)
ml1.set_parameter("rch_srmax", vary=False)
ml1.solve(tmin=tmin, tmax=tmax, fit_constant=False, initial=False)
ml1.plot(figsize=(10, 3));
Fit report Head                     Fit Statistics
==================================================
nfev     32                     EVP          52.11
nobs     590                    R2            0.52
noise    True                   RMSE          0.12
tmin     1985-01-01 00:00:00    AICc      -3305.81
tmax     2010-01-01 00:00:00    BIC       -3275.34
freq     D                      Obj            nan
freq_obs None                   ___               
warmup   3650 days 00:00:00     Interp.         No

Parameters (7 optimized)
==================================================
                optimal     initial   vary
rch_A          1.471318    0.525948   True
rch_n          0.404834    1.689645   True
rch_a        563.251678   93.906690   True
rch_srmax    197.375057  197.375057  False
rch_lp         0.250000    0.250000  False
rch_ks         1.000022   27.608111   True
rch_gamma      0.617967    4.997388   True
rch_kv         0.666496    0.671541   True
rch_simax      2.000000    2.000000  False
constant_d    77.765490    0.000000  False
noise_alpha   95.146875   15.000000   True
../_images/9a39e0ab8dbe7b97bff4b83a7720ed0c4141c742ab471f61ff8ba9ad112441ca.png

The model fit with the data is not too bad, but we are clearly missing the highs and lows of the observed groundwater levels. This could have many causes, but in this case we may suspect that the occurrence of snowfall and melt impacts the results.

3. Account for snowfall and snow melt#

A second model is now created that accounts for snowfall and melt through a degree-day snow model (see e.g., Kavetski & Kuczera (2007). To run the model we add the keyword snow=True to the FlexModel and provide a time series of mean daily temperature to the RechargeModel. The temperature time series is used to split the precipitation into snowfall and rainfall.

ml2 = ps.Model(head)
sm2 = ps.RechargeModel(
    ml2,
    prec,
    evap,
    recharge=ps.rch.FlexModel(snow=True),
    rfunc=ps.Gamma(),
    name="rch",
    temp=temp,
)

# Solve the Pastas model in two steps
ml2.solve(tmin=tmin, tmax=tmax, fit_constant=False, report=False)
ps.ArNoiseModel(model=ml2)
ml2.set_parameter("rch_srmax", vary=False)
ml2.solve(tmin=tmin, tmax=tmax, fit_constant=False, initial=False)
Fit report Head                     Fit Statistics
==================================================
nfev     29                     EVP          56.30
nobs     590                    R2            0.56
noise    True                   RMSE          0.11
tmin     1985-01-01 00:00:00    AICc      -3362.29
tmax     2010-01-01 00:00:00    BIC       -3327.49
freq     D                      Obj            nan
freq_obs None                   ___               
warmup   3650 days 00:00:00     Interp.         No

Parameters (8 optimized)
==================================================
                 optimal     initial   vary
rch_A           0.872568    0.576359   True
rch_n           1.091563    1.408583   True
rch_a         246.291260  107.074787   True
rch_srmax     155.741687  155.741687  False
rch_lp          0.250000    0.250000  False
rch_ks       1000.000000    9.004201   True
rch_gamma       5.000000    4.999657   True
rch_kv          0.796857    0.677661   True
rch_simax       2.000000    2.000000  False
rch_tt          0.000000    0.000000  False
rch_k           1.000000    1.115652   True
constant_d     78.040271    0.000000  False
noise_alpha    97.536696   15.000000   True

Warnings! (3)
==================================================
Parameter 'rch_ks' on upper bound: 1.00e+03
Parameter 'rch_gamma' on upper bound: 5.00e+00
Parameter 'rch_k' on lower bound: 1.00e+00

Compare results#

From the fit_report we can already observe that the model fit improved quite a bit. We can also visualize the results to see how the model improved.

ax = ml2.plot(figsize=(10, 3))
ml1.simulate().plot(ax=ax)
plt.legend(
    [
        "Observations",
        "Model w Snow NSE={:.2f}".format(ml2.stats.nse()),
        "Model w/o Snow NSE={:.2f}".format(ml1.stats.nse()),
    ],
    ncol=3,
)
<matplotlib.legend.Legend at 0x72321269eba0>
../_images/90fe1970c3a289b9576d684a787019ec61f656ac63529cc562f2ba98764b784b.png

Extract the water balance (States & Fluxes)#

df = ml2.stressmodels["rch"].get_water_balance(
    ml2.get_parameters("rch"), tmin=tmin, tmax=tmax
)
df.plot(subplots=True, figsize=(10, 10));
../_images/8ba5ef3232a6475744faa615a9a4da9c11b2d259a7bfb8158a5ae263aecb300f.png

References#

  • Kavetski, D. and Kuczera, G. (2007). Model smoothing strategies to remove microscale discontinuities and spurious secondary optima in objective functions in hydrological calibration. Water Resources Research, 43(3).