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.0
Numpy      : 2.4.6
Pandas     : 3.0.3
Scipy      : 1.17.1
Matplotlib : 3.10.9
Numba      : 0.65.1

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=head, stresses=[prec, evap, temp]);
../_images/d33b4d6d5f2a66b9f5021eff3511e24a576f4754841db24c97047b5f375c3050.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(
    prec, evap, recharge=ps.rch.FlexModel(), rfunc=ps.Gamma(), name="rch"
)
ml1.add_stressmodel(sm1)

# Solve the Pastas model in two steps
ml1.solve(tmin=tmin, tmax=tmax, fit_constant=False, report=False)
ml1.add_noisemodel(ps.ArNoiseModel())
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     41                     EVP          39.87
nobs     590                    R2            0.40
noise    True                   RMSE          0.13
tmin     1985-01-01 00:00:00    AICc      -3223.89
tmax     2010-01-01 00:00:00    BIC       -3193.42
freq     D                      Obj           1.22
freq_obs None                   ___               
warmup   3650 days 00:00:00     Interp.         No

Parameters (7 optimized)
==================================================
                 optimal     initial   vary
rch_A           2.039765    1.358609   True
rch_n           1.371473    3.129693   True
rch_a         190.729192   52.727898   True
rch_srmax       2.620060    2.620060  False
rch_lp          0.250000    0.250000  False
rch_ks       3021.870696  102.662189   True
rch_gamma       6.896212    1.121165   True
rch_kv          1.588253    1.999999   True
rch_simax       2.000000    2.000000  False
constant_d     77.728436    0.000000  False
noise_alpha   106.215950   15.000000   True
../_images/b097b4c605edb9579a7b0d51268853098592046250dde511c5657263307b6774.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(
    prec,
    evap,
    recharge=ps.rch.FlexModel(snow=True),
    rfunc=ps.Gamma(),
    name="rch",
    temp=temp,
)
ml2.add_stressmodel(sm2)

# Solve the Pastas model in two steps
ml2.solve(tmin=tmin, tmax=tmax, fit_constant=False, report=False)
ml2.add_noisemodel(ps.ArNoiseModel())
ml2.set_parameter("rch_srmax", vary=False)
ml2.solve(tmin=tmin, tmax=tmax, fit_constant=False, initial=False)
Fit report Head                     Fit Statistics
==================================================
nfev     37                     EVP          67.57
nobs     590                    R2            0.68
noise    True                   RMSE          0.10
tmin     1985-01-01 00:00:00    AICc      -3388.09
tmax     2010-01-01 00:00:00    BIC       -3353.30
freq     D                      Obj           0.92
freq_obs None                   ___               
warmup   3650 days 00:00:00     Interp.         No

Parameters (8 optimized)
==================================================
                optimal     initial   vary
rch_A          0.731108    0.573522   True
rch_n          1.080474    1.398730   True
rch_a        212.190498  108.625483   True
rch_srmax    159.889166  159.889166  False
rch_lp         0.250000    0.250000  False
rch_ks       482.485991  358.381607   True
rch_gamma     13.464169   18.461413   True
rch_kv         0.646750    0.713615   True
rch_simax      2.000000    2.000000  False
rch_tt         0.000000    0.000000  False
rch_k          0.660375    0.793974   True
constant_d    78.236264    0.000000  False
noise_alpha   71.586662   15.000000   True

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 0x7441e431f380>
../_images/d318d314fe64840f7d97b5ea10a39f499fd6b95b7ea00346d7061d00c9d61584.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/7612fcfd99ee49220427c46f44a9d89a783724663e4bcf143995fa75907f1997.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).