dbrakenhoff
dbrakenhoff

Reputation: 51

Making a prediction with a pastas timeseries model

For my thesis project I am trying to forecast groundwater levels by applying a particle filter which uses weather forecast data (specifically mm of rainfall and evaporation). As part of the particle filtering process I need to make a prediction of the groundwater level based on this weather forecast data, which I want to do using a Pastas model.

At the moment I have trained a Pastas model as follows:

import pastas as ps

# set up model
model = ps.Model(gwml_train.gws)

# add stresses information
rain = ps.StressModel(wm_train.RH, ps.Gamma, name='rain', settings="prec")
evap = ps.StressModel(wm_train.EV, ps.Gamma, name='evap', settings="evap")
model.add_stressmodel(rain)
model.add_stressmodel(evap)

# solve model
model.solve()

Where the gwml_train is the groundwater level data for the period of 1-1-2018 until 1-1-2019 and wm_train the weather measurements for the same data. Rh is rainfall and EV is evaporation.

This model explains the groundwater level measurements that are given in combination with the weather measurements. What I want to do, is to make a prediction for a period in which no groundwater level measurements are given but there are weather measurements.

Specifically, I use a for-loop which makes a 30 day forecast for each day in the period 1-1-2019 until 1-3-2019. At each day I get a dataset with the 30-day weather forecast for that day. What I would like to do, is to add this weather forecast data to the model and use it to predict the groundwater levels for that 30-day period. Is there a way to do this?

Adding the data to solve() does not work and the method simulate() does not take any data.

This question was sent to me by a user via mail. I'm posting it here to add a pastas question on SO.

EDIT: updated question with user explanation.

Upvotes: 1

Views: 297

Answers (1)

dbrakenhoff
dbrakenhoff

Reputation: 51

Let's say we have created a pastas Model ml with precipitation and evaporation as stresses. Optimizing the timeseries model on a specific period is done by specifying the period in ml.solve():

ml.solve(tmin="2010", tmax="2020")

To simulate a specific period use the same tmin/tmax options in ml.simulate(). So for a prediction of the groundwater level in january 2020:

sim  = ml.simulate(tmin="2020-01-01", tmax="2020-01-31")

sim is a pandas.Series containing the simulated groundwater head. Note that the precipitation and evaporation timeseries do need to have data for the period you want to simulate, otherwise the model will use the mean of the timeseries to calculate the groundwater level.

Upvotes: 1

Related Questions