V05_sd_model.Rmd 12.5 KB
Newer Older
1
---
2
title: "Simulated vs observed upstream flows in calibration of semi-distributed GR4J model"
3
author: "David Dorchies"
4
5
6
7
bibliography: V00_airgr_ref.bib
output: rmarkdown::html_vignette
vignette: >
  %\VignetteEngine{knitr::rmarkdown}
8
  %\VignetteIndexEntry{Simulated vs observed upstream flows in calibration of semi-distributed GR4J model}
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  %\VignetteEncoding{UTF-8}
---

```{r, include=FALSE, fig.keep='none', results='hide'}
library(airGR)
options(digits = 3)
```

# Introduction

## Scope

The **airGR** package implements semi-distributed model capabilities using a lag model between subcatchments. It allows to chain together several lumped models as well as integrating anthropogenic influence such as reservoirs or withdrawals.

23
`RunModel_Lag` documentation gives an example of simulating the influence of a reservoir in a lumped model. Try `example(RunModel_Lag)` to get it.
24

25
26
In this vignette, we show how to calibrate 2 sub-catchments in series with a semi-distributed model consisting of 2 GR4J models.
For doing this we compare 3 strategies for calibrating the downstream subcatchment:
27
28
29

- using upstream observed flows
- using upstream simulated flows
30
- using upstream simulated flows and parameter regularisation [@delavenne_regularization_2019]
31
32

We finally compare these calibrations with a theoretical set of parameters.
33
This comparison is based on the Kling-Gupta Efficiency computed on the root-squared discharges as performance criterion.
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

## Model description

```{r, warning=FALSE, include=FALSE}
library(airGR)
options(digits = 3)
```

We use an example data set from the package that unfortunately contains data for only one catchment.

```{r, warning=FALSE}
## loading catchment data
data(L0123001)
```

Let's imagine that this catchment of 360 km² is divided into 2 subcatchments:

- An upstream subcatchment of 180 km²
- 100 km downstream another subcatchment of 180 km²

We consider that meteorological data are homogeneous on the whole catchment, so we use the same pluviometry `BasinObs$P` and the same evapotranspiration `BasinObs$E` for the 2 subcatchments.

For the observed flow at the downstream outlet, we generate it with the assumption that the upstream flow arrives at downstream with a constant delay of 2 days.

```{r}
QObsDown <- (BasinObs$Qmm + c(0, 0, BasinObs$Qmm[1:(length(BasinObs$Qmm)-2)])) / 2
60
61
62
options(digits = 5)
summary(cbind(QObsUp = BasinObs$Qmm, QObsDown))
options(digits = 3)
63
64
```

65
66
67
68
69
70
71
With a delay of 2 days between the 2 gauging stations, the theoretical Velocity parameter should be equal to:

```{r}
Velocity <- 100 * 1e3 / (2 * 86400)
paste("Velocity: ", format(Velocity), "m/s")
```

72
73
74
75
76
77
# Calibration of the upstream subcatchment

The operations are exactly the same as the ones for a GR4J lumped model. So we do exactly the same operations as in the [Get Started](V01_get_started.html) vignette.

```{r}
InputsModelUp <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR,
78
                                   Precip = BasinObs$P, PotEvap = BasinObs$E)
79
80
81
Ind_Run <- seq(which(format(BasinObs$DatesR, format = "%Y-%m-%d") == "1990-01-01"),
               which(format(BasinObs$DatesR, format = "%Y-%m-%d") == "1999-12-31"))
RunOptionsUp <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
82
83
                                 InputsModel = InputsModelUp,
                                 IndPeriod_WarmUp = NULL, IndPeriod_Run = Ind_Run,
84
                                 IniStates = NULL, IniResLevels = NULL)
85
86
# Error criterion is KGE computed on the root-squared discharges
InputsCritUp <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModelUp,
87
                                 RunOptions = RunOptionsUp,
88
89
                                 VarObs = "Q", Obs = BasinObs$Qmm[Ind_Run],
                                 transfo = "sqrt")
90
91
CalibOptionsUp <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibration_Michel)
OutputsCalibUp <- Calibration_Michel(InputsModel = InputsModelUp, RunOptions = RunOptionsUp,
92
93
                                     InputsCrit = InputsCritUp, CalibOptions = CalibOptionsUp,
                                     FUN_MOD = RunModel_GR4J)
94
95
96
97
98
99
100
101
102
103
```

And see the result of the simulation:

```{r}
OutputsModelUp <- RunModel_GR4J(InputsModel = InputsModelUp, RunOptions = RunOptionsUp,
                                Param = OutputsCalibUp$ParamFinalR)
```


104
# Calibration of the downstream subcatchment
105

106
107
108
## Creation of the InputsModel objects

we need to create `InputsModel` objects completed with upstream information with upstream observed flow for the calibration of first case and upstream simulated flows for the other cases:
109
110
111
112
113

```{r}
InputsModelDown1 <- CreateInputsModel(
  FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR,
  Precip = BasinObs$P, PotEvap = BasinObs$E,
114
  Qupstream = matrix(BasinObs$Qmm, ncol = 1), # upstream observed flow
115
  LengthHydro = 100, # distance between upstream catchment outlet & the downstream one [km]
116
  BasinAreas = c(180, 180) # upstream and downstream areas [km²]
117
118
119
)
```

120
121
122
123
124
For using upstream simulated flows, we should concatenate a vector with the simulated flows for the entire period of simulation (warm-up + run):

```{r}
Qsim_upstream <- rep(NA, length(BasinObs$DatesR))
# Simulated flow during warm-up period (365 days before run period)
125
Qsim_upstream[Ind_Run[seq_len(365)] - 365] <- OutputsModelUp$RunOptions$WarmUpQsim
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Simulated flow during run period
Qsim_upstream[Ind_Run] <- OutputsModelUp$Qsim

InputsModelDown2 <- CreateInputsModel(
  FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR,
  Precip = BasinObs$P, PotEvap = BasinObs$E,
  Qupstream = matrix(Qsim_upstream, ncol = 1), # upstream observed flow
  LengthHydro = 100, # distance between upstream catchment outlet & the downstream one [km]
  BasinAreas = c(180, 180) # upstream and downstream areas [km²]
)
```


## Calibration with upstream flow observations

We calibrate the combination of Lag model for upstream flow transfer and GR4J model for the runoff of the downstream subcatchment:
142
143
144

```{r}
RunOptionsDown <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
145
146
147
                                   InputsModel = InputsModelDown1,
                                   IndPeriod_WarmUp = NULL, IndPeriod_Run = Ind_Run,
                                   IniStates = NULL, IniResLevels = NULL)
148
InputsCritDown <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModelDown1,
149
                                   RunOptions = RunOptionsDown,
150
151
                                   VarObs = "Q", Obs = QObsDown[Ind_Run],
                                   transfo = "sqrt")
152
153
CalibOptionsDown <- CreateCalibOptions(FUN_MOD = RunModel_GR4J,
                                       FUN_CALIB = Calibration_Michel,
154
155
156
157
158
                                       IsSD = TRUE) # specify that it's a SD model
OutputsCalibDown1 <- Calibration_Michel(InputsModel = InputsModelDown1,
                                        RunOptions = RunOptionsDown,
                                        InputsCrit = InputsCritDown,
                                        CalibOptions = CalibOptionsDown,
159
160
161
                                        FUN_MOD = RunModel_GR4J)
```

162
`RunModel` is run in order to automatically combine GR4J and Lag models.
163
164
165
166
167
168
169
170
171
172
173

```{r}
OutputsModelDown1 <- RunModel(InputsModel = InputsModelDown2,
                              RunOptions = RunOptionsDown,
                              Param = OutputsCalibDown1$ParamFinalR,
                              FUN_MOD = RunModel_GR4J)
```

Performance of the model validation is then:

```{r}
174
KGE_down1 <- ErrorCrit_KGE(InputsCritDown, OutputsModelDown1)
175
176
177
```


178
## Calibration with upstream simulated flow
179
180
181
182

We calibrate the model with the `InputsModel` object previously created for substituting the observed upstream flow with the simulated one:

```{r}
183
184
185
186
OutputsCalibDown2 <- Calibration_Michel(InputsModel = InputsModelDown2,
                                        RunOptions = RunOptionsDown,
                                        InputsCrit = InputsCritDown,
                                        CalibOptions = CalibOptionsDown,
187
188
189
190
                                        FUN_MOD = RunModel_GR4J)
ParamDown2 <- OutputsCalibDown2$ParamFinalR
```

191
## Calibration with upstream simulated flow and parameter regularisation
192

193
The regularisation follow the method proposed by @delavenne_regularization_2019.
194

195
As a priori parameter set, we use the calibrated parameter set of the upstream catchment and the theoretical velocity:
196

197
198
199
200
```{r}
ParamDownTheo <- c(Velocity, OutputsCalibUp$ParamFinalR)
```

201
The Lavenne criterion is initialised with the a priori parameter set and the value of the KGE of the upstream basin.
202
203

```{r}
204
IC_Lavenne <- CreateInputsCrit_Lavenne(InputsModel = InputsModelDown2,
205
206
                                    RunOptions = RunOptionsDown,
                                    Obs = QObsDown[Ind_Run],
207
                                    AprParamR = ParamDownTheo,
208
                                    AprCrit = OutputsCalibUp$CritFinal)
209
210
```

211
The Lavenne criterion is used instead of the KGE for calibration with regularisation
212
213
214
215

```{r}
OutputsCalibDown3 <- Calibration_Michel(InputsModel = InputsModelDown2,
                                        RunOptions = RunOptionsDown,
216
                                        InputsCrit = IC_Lavenne,
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
                                        CalibOptions = CalibOptionsDown,
                                        FUN_MOD = RunModel_GR4J)
```

The KGE is then calculated for performance comparisons:

```{r}
OutputsModelDown3 <- RunModel(InputsModel = InputsModelDown2,
                              RunOptions = RunOptionsDown,
                              Param = OutputsCalibDown3$ParamFinalR,
                              FUN_MOD = RunModel_GR4J)
KGE_down3 <- ErrorCrit_KGE(InputsCritDown, OutputsModelDown3)
```


# Discussion

## Identification of Velocity parameter

236
237
238
Both calibrations overestimate this parameter:

```{r}
239
mVelocity <- matrix(c(Velocity,
Delaigue Olivier's avatar
Delaigue Olivier committed
240
                      OutputsCalibDown1$ParamFinalR[1],
241
                      OutputsCalibDown2$ParamFinalR[1],
242
                      OutputsCalibDown3$ParamFinalR[1]),
Delaigue Olivier's avatar
Delaigue Olivier committed
243
244
245
                    ncol = 1,
                    dimnames = list(c("theoretical",
                                      "calibrated with observed upstream flow",
246
247
                                      "calibrated with simulated  upstream flow",
                                      "calibrated with sim upstream flow and regularisation"),
Delaigue Olivier's avatar
Delaigue Olivier committed
248
                                    c("Velocity parameter")))
249
knitr::kable(mVelocity)
250
251
252
253
```

## Value of the performance criteria with theoretical calibration

254
Theoretically, the parameters of the downstream GR4J model should be the same as the upstream one with the velocity as extra parameter:
255
256
257

```{r}
OutputsModelDownTheo <- RunModel(InputsModel = InputsModelDown2,
258
259
260
                                 RunOptions = RunOptionsDown,
                                 Param = ParamDownTheo,
                                 FUN_MOD = RunModel_GR4J)
261
KGE_downTheo <- ErrorCrit_KGE(InputsCritDown, OutputsModelDownTheo)
262
263
264
265
266
267
```


## Parameters and performance of each subcatchment for all calibrations

```{r}
268
269
270
comp <- matrix(c(0, OutputsCalibUp$ParamFinalR,
                 rep(OutputsCalibDown1$ParamFinalR, 2),
                 OutputsCalibDown2$ParamFinalR,
271
                 OutputsCalibDown3$ParamFinalR,
272
273
274
275
                 ParamDownTheo),
               ncol = 5, byrow = TRUE)
comp <- cbind(comp, c(OutputsCalibUp$CritFinal,
                      OutputsCalibDown1$CritFinal,
276
                      KGE_down1$CritValue,
277
                      OutputsCalibDown2$CritFinal,
278
279
280
                      KGE_down3$CritValue,
                      KGE_downTheo$CritValue))
colnames(comp) <- c("Velocity", paste0("X", 1:4), "KGE(√Q)")
281
282
283
284
rownames(comp) <- c("Calibration of the upstream subcatchment",
                    "Calibration 1 with observed upstream flow",
                    "Validation 1 with simulated upstream flow",
                    "Calibration 2 with simulated upstream flow",
285
                    "Calibration 3 with simulated upstream flow and regularisation",
286
287
288
289
                    "Validation theoretical set of parameters")
knitr::kable(comp)
```

290
291
292
Even if calibration with observed upstream flows gives an improved performance criteria, in validation using simulated upstream flows the result is quite similar as the performance obtained with the calibration with upstream simulated flows. The theoretical set of parameters give also an equivalent performance but still underperforming the calibration 2 one. Regularisation allows to get similar performance as the one for calibration with simulated flows but with the big advantage of having parameters closer to the theoretical ones (Especially for the velocity parameter).

# References