Allow to simulate a subperiod without discharge in SimGR
Current behaviour
It is possible to run SimGR()
using a PrepGR()
output whthout anny Qobs, but it is not possible when it is only a sub-period.
Obs
:
On the whole periode without ## data.frame of observed data
data(L0123001, package = "airGR")
BasinObs2 <- BasinObs[, c("DatesR", "P", "E", "Qmm", "T")]
BasinObs2$Qmm <- NA
### Preparation of observed data for modelling
PREP <- PrepGR(ObsDF = BasinObs2, HydroModel = "GR4J", CemaNeige = FALSE)
## Simulation step using model parameters set by the user
SIM <- SimGR(PrepGR = PREP, Param = c(270.426, 0.984, 108.853, 2.149), EffCrit = "KGE2",
WupPer = NULL, SimPer = c("1994-01-01", "1998-12-31"))
Warning messages:
1: In SimGR(PrepGR = PREP, Param = c(270.426, 0.984, 108.853, 2.149), :
"PrepGR" does not contain any Qobs values. The efficiency criterion is not computed
2: In CreateRunOptions(FUN_MOD = get(PrepGR$TypeModel), InputsModel = PrepGR$InputsModel, :
model warm up period not defined: default configuration used
the year preceding the run period is used
Obs
:
On a subperiod without ## data.frame of observed data
data(L0123001, package = "airGR")
BasinObs2 <- BasinObs[, c("DatesR", "P", "E", "Qmm", "T")]
BasinObs2$Qmm[3654:length(BasinObs2$Qmm)] <- NA
## Preparation of observed data for modelling
PREP <- PrepGR(ObsDF = BasinObs2, HydroModel = "GR4J", CemaNeige = FALSE)
## Simulation step using model parameters set by the user
SIM <- SimGR(PrepGR = PREP, Param = c(270.426, 0.984, 108.853, 2.149), EffCrit = "KGE2",
WupPer = NULL, SimPer = c("1994-01-01", "1998-12-31"))
Erreur : 'Obs' contains only missing values
De plus : Warning message:
In CreateRunOptions(FUN_MOD = get(PrepGR$TypeModel), InputsModel = PrepGR$InputsModel, :
model warm up period not defined: default configuration used
the year preceding the run period is used
Expected behaviour
Allow to run SimGR()
on a subperiod whitout discharge and return a warning message.
Current code
Lines 19 to 22
isQobs <- !all(is.na(PrepGR$Qobs))
if (!isQobs) {
warning("\"PrepGR\" does not contain any Qobs values. The efficiency criterion is not computed")
}
Lines 82 to 98
if (isQobs) {
MOD_crt <- CreateInputsCrit(FUN_CRIT = FUN_CRIT, InputsModel = PrepGR$InputsModel,
RunOptions = MOD_opt, Obs = PrepGR$Qobs[SimInd],
transfo = transfo)
}
else {
MOD_crt <- NULL
}
SIM <- RunModel(InputsModel = PrepGR$InputsModel, RunOptions = MOD_opt,
Param = Param, FUN_MOD = get(PrepGR$TypeModel))
if (isQobs) {
CRT <- ErrorCrit(InputsCrit = MOD_crt, OutputsModel = SIM,
verbose = verbose)
}
else {
CRT <- NULL
}
Proposed solution
Remove ines 19 to 22.
Add the following code just before the line 82:
isQobs <- !all(is.na(PrepGR$Qobs[SimInd]))
if (!isQobs) {
warning("\"PrepGR\" does not contain any Qobs values on \"SimPer\". The efficiency criterion is not computed")
}