In this example it is shown how to create a time series model with not only evaporation and precipitation, but also including surface water levels. The following data is used:
In [1]:
import pandas as pd
import pastas as ps
import matplotlib.pyplot as plt
%matplotlib notebook
In [2]:
oseries = pd.read_csv("data_notebook_5/groundwater.csv", parse_dates=True, squeeze=True, index_col=0)
rain = pd.read_csv("data_notebook_5/rain.csv", parse_dates=True, squeeze=True, index_col=0)
evap = pd.read_csv("data_notebook_5/evap.csv", parse_dates=True, squeeze=True, index_col=0)
waterlevel = pd.read_csv("data_notebook_5/waterlevel.csv", parse_dates=True, squeeze=True, index_col=0)
fig, axes = plt.subplots(4,1, figsize=(12, 5), sharex=True)
oseries.plot(ax=axes[0], x_compat=True, legend=True)
rain.plot(ax=axes[1], x_compat=True, legend=True)
evap.plot(ax=axes[2], x_compat=True, legend=True)
waterlevel.plot(ax=axes[3], x_compat=True, legend=True)
Out[2]:
In [3]:
ml = ps.Model(oseries)
sm = ps.StressModel2([rain, evap], rfunc=ps.Gamma, name="recharge")
ml.add_stressmodel(sm)
ml.solve(tmin="2000")
ml.plots.results(tmin="2012", figsize=(16, 8))
print("The explained variance percentage over the period 2012-2017 is: %s" % ml.stats.evp(tmin="2012"))
In [4]:
w = ps.StressModel(waterlevel, rfunc=ps.Exponential, name="waterlevel", settings="waterlevel")
# Normalize the stress by the mean such that only the variation in the waterlevel matters
w.update_stress(norm="mean")
ml.add_stressmodel(w)
ml.solve(tmin="2012")
In [5]:
ml.plots.results(figsize=(16, 8))
Out[5]: