<jupyter_start><jupyter_text>Simulating groundwater levels with a surface water level*Developed by <NAME>* 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:- groundwater.csv: groundwaterlevels- rain.csv: Precipitation- evap.csv: Potential evaporation- waterlevel.csv: Surface waterlevel<jupyter_code>import pandas as pd
import pastas as ps
import matplotlib.pyplot as plt

%matplotlib notebook<jupyter_output><empty_output><jupyter_text>1. import and plot the data<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>2. Create a timeseries model<jupyter_code>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"))<jupyter_output>INFO: Cannot determine frequency of series  Groundwater
INFO: Time Series  Groundwater: 5 nan-value(s) was/were found and filled with: drop
WARNING: User-provided name ' Groundwater' contains illegal character  
INFO: Inferred frequency from time series  Precipitation: freq=D 
INFO: Inferred frequency from time series  Evaporation: freq=D<jupyter_text>3. Adding surface water level<jupyter_code>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")
ml.plots.results(figsize=(16, 8))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11625947767481044, 'fraction_numerical': 0.02190395956192081, 'mean_word_length': 7.636363636363637, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '372875', 'license': 'MIT', 'n_tokens_mistral': 859, 'n_tokens_neox': 801, 'n_words': 201, 'path': 'examples/notebooks/5_groundwater_surfacewater.ipynb', 'repo_name': 'pgraafstra/pastas', 'size': '2384'}