Commit 32aa9e51 authored by Dorchies David's avatar Dorchies David
Browse files

doc(vignettes): updates following the optional Qobs in CreateInputsModel

Refs #60
parent 5f086b4e
Pipeline #28828 passed with stage
in 5 minutes and 50 seconds
......@@ -109,7 +109,7 @@ The **airGR** `CreateInputsModel` function is extended in order to handle the `G
```{r}
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap, Qobs)
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap)
```
# References
......@@ -47,7 +47,7 @@ PotEvapTot <- cbind(sapply(BasinsObs, function(x) {x$peti}))
Qobs <- cbind(sapply(BasinsObs, function(x) {x$discharge_spec}))
Precip <- ConvertMeteoSD(griwrm, PrecipTot)
PotEvap <- ConvertMeteoSD(griwrm, PotEvapTot)
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap, Qobs)
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap)
str(InputsModel)
```
......
......@@ -69,15 +69,21 @@ BasinsObs <- Severn$BasinsObs
DatesR <- BasinsObs[[1]]$DatesR
PrecipTot <- cbind(sapply(BasinsObs, function(x) {x$precipitation}))
PotEvapTot <- cbind(sapply(BasinsObs, function(x) {x$peti}))
Qobs <- cbind(sapply(BasinsObs, function(x) {x$discharge_spec}))
Precip <- ConvertMeteoSD(griwrm, PrecipTot)
PotEvap <- ConvertMeteoSD(griwrm, PotEvapTot)
Qobs <- cbind(sapply(BasinsObs, function(x) {x$discharge_spec}))
```
This time, we need to provide observed flows as inputs for the nodes '54002' and '54095':
```{r}
QobsInputs <- Qobs[, c("54002", "54095")]
```
The `GRiwrmInputsModel` object can be generated taking into account the new `GRiwrm` object:
Then, the `GRiwrmInputsModel` object can be generated taking into account the new `GRiwrm` object:
```{r}
IM_OL <- CreateInputsModel(griwrmV03, DatesR, Precip, PotEvap, Qobs)
IM_OL <- CreateInputsModel(griwrmV03, DatesR, Precip, PotEvap, QobsInputs)
```
## Calibration of the new model
......
......@@ -231,10 +231,10 @@ for (x in 1:ncol(m))
As for the previous model, we need to set up an `GRiwrmInputsModel` object containing all the model inputs:
```{r}
# A flow is needed for all the nodes in the network
# even if it is overwritten after by a controller
# A flow is needed for all direct injection nodes in the network
# even if they may be overwritten after by a controller
# The Qobs matrix is completed with 2 new columns for the new nodes
QobsIrrig <- cbind(Qobs, Irrigation1 = 0, Irrigation2 = 0)
QobsIrrig <- cbind(Qobs[, c("54002", "54095")], Irrigation1 = 0, Irrigation2 = 0)
# Creation of the GRiwrmInputsModel object
IM_Irrig <- CreateInputsModel(griwrmV04, DatesR, Precip, PotEvap, QobsIrrig)
......
......@@ -80,7 +80,7 @@ The **airGR** CreateInputsModel function is extended in order to handle the griw
```{r CreateInputsModel}
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap, Qnat)
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap)
```
......
......@@ -195,7 +195,6 @@ Then, we load observation data for each reservoir and each connection:
library(seinebasin)
data(QNAT)
data(Qreservoirs)
Qnat <- cbind(Qnat, Qreservoirs)
```
## How to handle online reservoir? The Pannecière lake case.
......@@ -208,15 +207,15 @@ There are two possibilities:
If we know in advance the flow released by the reservoir, upstream flow informations is not usefull for the simulation. But reservoir management simulation would need upstream flow informations for simulating the reservoir state during simulation. The second alternative will be useful for the next phases.
```{r Qnat}
Qnat <- cbind(Qnat, -Qnat[,"CHAUM_07"] * griwrm2$area[griwrm2$id == "CHAUM_07"] * 1e3)
colnames(Qnat)[ncol(Qnat)] <- "PANNEC_P"
Qreservoirs <- cbind(Qreservoirs, -Qnat[,"CHAUM_07"] * griwrm2$area[griwrm2$id == "CHAUM_07"] * 1e3)
colnames(Qreservoirs)[ncol(Qreservoirs)] <- "PANNEC_P"
```
## Create the InputsModel object
```{r CreateInputsModel}
InputsModel2 <- CreateInputsModel(griwrm2, DatesR, Precip, PotEvap, Qnat)
InputsModel2 <- CreateInputsModel(griwrm2, DatesR, Precip, PotEvap, Qreservoirs)
```
## Run simulation with naturalised flow parameters
......
......@@ -48,13 +48,13 @@ data(QOBS)
iEnd <-which(DatesR == as.POSIXct("2008-07-31", tz = "UTC"))
data(Qreservoirs)
Qobs3 <- cbind(Qobs, Qreservoirs[1:iEnd,])
QresMarne <- Qreservoirs[1:iEnd, grep("MARNE", colnames(Qreservoirs))]
id_GR_nodes <- griwrm3$id[!is.na(griwrm3$model)]
InputsModel3 <- CreateInputsModel(griwrm3,
DatesR[1:iEnd],
Precip[1:iEnd, id_GR_nodes],
PotEvap[1:iEnd, id_GR_nodes],
Qobs3[, griwrm3$id])
QresMarne)
```
## GriwmRunOptions object
......@@ -89,7 +89,7 @@ RunOptions <- CreateRunOptions(
InputsCrit <- CreateInputsCrit(
InputsModel = InputsModel3,
FUN_CRIT = airGR::ErrorCrit_KGE2,
RunOptions = RunOptions, Obs = Qobs3[IndPeriod_Run,]
RunOptions = RunOptions, Obs = Qobs[IndPeriod_Run,]
)
```
......@@ -124,7 +124,7 @@ OutputsModels3 <- RunModel(
htmltools::tagList(lapply(
griwrm3$id[!is.na(griwrm3$model)],
function(x) {
Q3 <- Qobs3[RunOptions[[1]]$IndPeriod_Run,x]
Q3 <- Qobs[RunOptions[[1]]$IndPeriod_Run,x]
iQ3 <- which(!is.na(Q3))
IndPeriod_Obs <- iQ3[1]:tail(iQ3,1)
OutputsModels <- ReduceOutputsModel(OutputsModels3[[x]], IndPeriod_Obs)
......
......@@ -49,13 +49,13 @@ data(QOBS)
iEnd <-which(DatesR == as.POSIXct("2008-07-31", tz = "UTC"))
data(Qreservoirs)
Qobs3 <- cbind(Qobs, Qreservoirs[1:iEnd,])
QresMarne <- Qreservoirs[1:iEnd, grep("MARNE", colnames(Qreservoirs))]
id_GR_nodes <- griwrm3$id[!is.na(griwrm3$model)]
InputsModel3 <- CreateInputsModel(griwrm3,
DatesR[1:iEnd],
Precip[1:iEnd, id_GR_nodes],
PotEvap[1:iEnd, id_GR_nodes],
Qobs3[, griwrm3$id])
InputsModel3 <- CreateInputsModel(griwrm3,
DatesR[1:iEnd],
Precip[1:iEnd, id_GR_nodes],
PotEvap[1:iEnd, id_GR_nodes],
QresMarne)
```
## GriwmRunOptions object
......@@ -90,7 +90,7 @@ RunOptions <- CreateRunOptions(
InputsCrit <- CreateInputsCrit(
InputsModel = InputsModel3,
FUN_CRIT = airGR::ErrorCrit_KGE2,
RunOptions = RunOptions, Obs = Qobs3[IndPeriod_Run,]
RunOptions = RunOptions, Obs = Qobs[IndPeriod_Run,]
)
```
......@@ -125,7 +125,7 @@ OutputsModels3 <- RunModel(
htmltools::tagList(lapply(
griwrm3$id[!is.na(griwrm3$model)],
function(x) {
Q3 <- Qobs3[RunOptions[[1]]$IndPeriod_Run,x]
Q3 <- Qobs[RunOptions[[1]]$IndPeriod_Run,x]
iQ3 <- which(!is.na(Q3))
IndPeriod_Obs <- iQ3[1]:tail(iQ3,1)
OutputsModels <- ReduceOutputsModel(OutputsModels3[[x]], IndPeriod_Obs)
......
......@@ -59,8 +59,7 @@ data(QNAT)
InputsModel4 <- CreateInputsModel(griwrm4,
DatesR,
Precip[, selectedNodes],
PotEvap[, selectedNodes],
Qnat[, selectedNodes])
PotEvap[, selectedNodes])
```
## GriwmRunOptions object
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment