Commit f04096da authored by Dorchies David's avatar Dorchies David
Browse files

fix (RunModel_Lag): bugs around QcontribDown$RunOptions$WarmUpQsim

- Replace wrong test `RunOptions$IndPeriod_WarmUp != 0L` by `!identical(RunOptions$IndPeriod_WarmUp, 0L)`
- Manage that WarmUpQsim is optional during calibration

Refs #137
parent 84d860ae
Pipeline #28589 failed with stages
in 12 minutes and 53 seconds
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.6.12.9000
Date: 2021-04-27
Version: 1.6.12.9001
Date: 2021-10-26
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
person("Olivier", "Delaigue", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7668-8468"), email = "airGR@inrae.fr"),
......
......@@ -24,10 +24,13 @@ RunModel_Lag <- function(InputsModel, RunOptions, Param, QcontribDown) {
if (length(QcontribDown$Qsim) != length(RunOptions$IndPeriod_Run)) {
stop("Time series Qsim in 'QcontribDown' should have the same lenght as 'RunOptions$IndPeriod_Run'")
}
if (!is.null(QcontribDown$WarmUpQsim) &&
length(QcontribDown$WarmUpQsim) != length(RunOptions$IndPeriod_WarmUp) &&
RunOptions$IndPeriod_WarmUp != 0L) {
stop("Time series WarmUpQsim in 'QcontribDown' should have the same lenght as 'RunOptions$IndPeriod_WarmUp'")
if (!identical(RunOptions$IndPeriod_WarmUp, 0L) && RunOptions$Outputs_Sim != RunOptions$Outputs_Cal) {
# This test is not necessary during calibration but usefull in other cases because
# WarmUpQsim is then used for downstream sub-basins because of the delay in Qupstream
if (is.null(QcontribDown$RunOptions$WarmUpQsim) ||
length(QcontribDown$RunOptions$WarmUpQsim) != length(RunOptions$IndPeriod_WarmUp)) {
stop("Time series WarmUpQsim in 'QcontribDown' should have the same lenght as 'RunOptions$IndPeriod_WarmUp'")
}
}
} else if (is.vector(QcontribDown) && is.numeric(QcontribDown)) {
if (length(QcontribDown) != length(RunOptions$IndPeriod_Run)) {
......
......@@ -37,8 +37,7 @@
if (!is.null(CemaNeigeLayers)) {
OutputsModel$CemaNeigeLayers <- CemaNeigeLayers
}
if ("WarmUpQsim" %in% RunOptions$Outputs_Sim) {
if ("WarmUpQsim" %in% RunOptions$Outputs_Sim && !identical(RunOptions$IndPeriod_WarmUp, 0L)) {
OutputsModel$RunOptions$WarmUpQsim <- RESULTS$Outputs[seq_len(length(RunOptions$IndPeriod_WarmUp)),
which(FortranOutputs == "Qsim")]
# class(OutputsModel$RunOptions$WarmUpQsim) <- c("WarmUpOutputsModelItem", class(OutputsModel$RunOptions$WarmUpQsim))
......
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