Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
obs = obs[obs.index > pd.to_datetime('1-1-2010')]
# Create the time series model
ml = ps.Model(obs)
# Read weather data
prec = ps.read_knmi('data/neerslaggeg_HEIBLOEM-L_967-2.txt', variables='RD')
evap = ps.read_knmi('data/etmgeg_380.txt', variables='EV24')
# Create stress
if False:
sm = ps.StressModel2(stress=[prec, evap], rfunc=ps.Exponential,
name='recharge')
ml.add_stressmodel(sm)
elif False:
sm = ps.StressModel(prec, rfunc=ps.Exponential, name='prec')
ml.add_stressmodel(sm)
sm = ps.StressModel(evap, rfunc=ps.Exponential, name='evap', up=False)
ml.add_stressmodel(sm)
else:
sm = ps.stressmodels.NoConvModel(prec, rfunc=ps.Exponential,
name='prec_no_conv')
ml.add_stressmodel(sm)
sm = ps.stressmodels.NoConvModel(evap, rfunc=ps.Exponential,
name='evap_no_conv', up=False)
ml.add_stressmodel(sm)
# Solve and plot
ml.solve(noise=False, warmup=0)
# Plotting takes the longest
ml.plot()
ml = ps.Model(head, name="groundwater head")
# read weather data
rain = pd.read_csv("notebooks/data_notebook_7/prec_wellex.csv",
index_col="Date", parse_dates=True)
evap = pd.read_csv("notebooks/data_notebook_7/evap_wellex.csv",
index_col="Date", parse_dates=True)
# Create stress
rm = ps.RechargeModel(prec=rain, evap=evap, rfunc=ps.Exponential,
recharge="Linear", name='recharge')
ml.add_stressmodel(rm)
well = pd.read_csv("notebooks/data_notebook_7/well_wellex.csv",
index_col="Date", parse_dates=True)
sm = ps.StressModel(well, rfunc=ps.Gamma, name="well", up=False)
ml.add_stressmodel(sm)
# Solve
ml.solve(noise=True, tmax="2010")
ml.plots.results()
# IN = meny.IN['Extraction 1']
# well = ps.TimeSeries(IN["values"], freq_original="M", settings="well")
# # extraction amount counts for the previous month
# sm = ps.StressModel(well, ps.Hantush, 'Extraction_1', up=False)
# Add well extraction 2
IN = meny.IN['Extraction 2']
well = ps.TimeSeries(IN["values"], freq_original="M", settings="well")
# extraction amount counts for the previous month
sm1 = ps.StressModel(well, ps.Hantush, 'Extraction_2', up=False)
# Add well extraction 3
IN = meny.IN['Extraction 3']
well = ps.TimeSeries(IN["values"], freq_original="M", settings="well")
# extraction amount counts for the previous month
sm2 = ps.StressModel(well, ps.Hantush, 'Extraction_3', up=False)
# add_stressmodels also allows addings multiple stressmodels at once
ml.add_stressmodel(sm, sm1, sm2)
# Solve
ml.solve(tmax="1995")
ax = ml.plots.decomposition(ytick_base=1.)
# round to days (precipitation is measured at 9:00)
IN = meny.IN['Precipitation']
IN['values'].index = IN['values'].index.normalize()
#round to days (evaporation is measured at 1:00)
IN2 = meny.IN['Evaporation']
IN2['values'].index = IN2['values'].index.normalize()
sm = ps.StressModel2([IN['values'], IN2['values']], ps.Gamma, 'Recharge')
ml.add_stressmodel(sm)
settings = dict(freq='W')
# Add well extraction 1
IN = meny.IN['Extraction 1']
sm = ps.StressModel(IN['values'], ps.Hantush, 'Extraction_1', up=False,
kind="well", settings=settings)
ml.add_stressmodel(sm)
# Add well extraction 2
IN = meny.IN['Extraction 2']
sm = ps.StressModel(IN['values'], ps.Hantush, 'Extraction_2', up=False,
kind="well", settings=settings)
ml.add_stressmodel(sm)
#Add well extraction 3
# IN = meny.IN['Extraction 3']
# print(IN['values'].index.min())
# ts = ps.StressModel(IN['values'], ps.Hantush, 'Extraction_3', up=False,
# kind="well", settings=settings)
# ml.add_tseries(ts)
IN2['values'].index = IN2['values'].index.normalize()
sm = ps.StressModel2([IN['values'], IN2['values']], ps.Gamma, 'Recharge')
ml.add_stressmodel(sm)
settings = dict(freq='W')
# Add well extraction 1
IN = meny.IN['Extraction 1']
sm = ps.StressModel(IN['values'], ps.Hantush, 'Extraction_1', up=False,
kind="well", settings=settings)
ml.add_stressmodel(sm)
# Add well extraction 2
IN = meny.IN['Extraction 2']
sm = ps.StressModel(IN['values'], ps.Hantush, 'Extraction_2', up=False,
kind="well", settings=settings)
ml.add_stressmodel(sm)
#Add well extraction 3
# IN = meny.IN['Extraction 3']
# print(IN['values'].index.min())
# ts = ps.StressModel(IN['values'], ps.Hantush, 'Extraction_3', up=False,
# kind="well", settings=settings)
# ml.add_tseries(ts)
# replace extraction 3 by a step-function, to test the step-tseries
# ts = TseriesStep(pd.Timestamp(1970,1,1), 'step', rfunc=Gamma, up=False)
# ml.add_tseries(ts)
# Add noise model
n = ps.NoiseModel()
# Create the time series model
ml = ps.Model(obs)
# Read weather data
prec = ps.read_knmi('data/neerslaggeg_HEIBLOEM-L_967-2.txt', variables='RD')
evap = ps.read_knmi('data/etmgeg_380.txt', variables='EV24')
# Create stress
if False:
sm = ps.StressModel2(stress=[prec, evap], rfunc=ps.Exponential,
name='recharge')
ml.add_stressmodel(sm)
elif False:
sm = ps.StressModel(prec, rfunc=ps.Exponential, name='prec')
ml.add_stressmodel(sm)
sm = ps.StressModel(evap, rfunc=ps.Exponential, name='evap', up=False)
ml.add_stressmodel(sm)
else:
sm = ps.stressmodels.NoConvModel(prec, rfunc=ps.Exponential,
name='prec_no_conv')
ml.add_stressmodel(sm)
sm = ps.stressmodels.NoConvModel(evap, rfunc=ps.Exponential,
name='evap_no_conv', up=False)
ml.add_stressmodel(sm)
# Solve and plot
ml.solve(noise=False, warmup=0)
# Plotting takes the longest
ml.plot()