Commit af58cfa6 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

feat: allow 'WupPer' to be equal to 0L in 'SimGR' and 'CalGR'

Refs: #52
2 merge requests!45Merge branch 'dev' into 'master',!33Resolve "Change the default configuration of the "WupPer" argument (SimGR and CalGR functions)"
Pipeline #38073 passed with stage
in 3 minutes and 31 seconds
Showing with 28 additions and 20 deletions
+28 -20
......@@ -23,18 +23,22 @@ CalGR <- function(PrepGR, CalCrit = c("NSE", "KGE", "KGE2", "RMSE"),
WupInd <- NULL
if (!is.null(WupPer)) {
WupPer <- as.POSIXct(WupPer, tz = "UTC")
if (length(WupPer) != 2) {
stop("Warm-up period \"WupPer\" must be of length 2")
}
if (any(is.na(WupPer))) {
stop("Non convenient date format for the warm-up period \"WupPer\"")
} else {
if (!any(PrepGR$InputsModel$DatesR == WupPer[1]) | !any(PrepGR$InputsModel$DatesR == WupPer[2])) {
stop("Non convenient date for the warm-up period \"WupPer\"")
if (!identical(WupPer, 0L)){
WupPer <- as.POSIXct(WupPer, tz = "UTC")
if (length(WupPer) != 2) {
stop("Warm-up period \"WupPer\" must be of length 2")
}
if (any(is.na(WupPer))) {
stop("Non convenient date format for the warm-up period \"WupPer\"")
} else {
WupInd <- which(PrepGR$InputsModel$DatesR == WupPer[1]):which(PrepGR$InputsModel$DatesR == WupPer[2])
if (!any(PrepGR$InputsModel$DatesR == WupPer[1]) | !any(PrepGR$InputsModel$DatesR == WupPer[2])) {
stop("Non convenient date for the warm-up period \"WupPer\"")
} else {
WupInd <- which(PrepGR$InputsModel$DatesR == WupPer[1]):which(PrepGR$InputsModel$DatesR == WupPer[2])
}
}
} else {
WupInd <- 0L
}
}
......
......@@ -39,18 +39,22 @@ SimGR <- function(PrepGR, CalGR = NULL, Param, EffCrit = c("NSE", "KGE", "KGE2",
WupInd <- NULL
if (!is.null(WupPer)) {
WupPer <- as.POSIXct(WupPer, tz = "UTC")
if (length(WupPer) != 2) {
stop("Warm-up period \"WupPer\" must be of length 2")
}
if (any(is.na(WupPer))) {
stop("Non convenient date format for the warm-up period \"WupPer\"")
} else {
if (!any(PrepGR$InputsModel$DatesR == WupPer[1]) | !any(PrepGR$InputsModel$DatesR == WupPer[2])) {
stop("Non convenient date for the warm-up period \"WupPer\"")
if (!identical(WupPer, 0L)){
WupPer <- as.POSIXct(WupPer, tz = "UTC")
if (length(WupPer) != 2) {
stop("Warm-up period \"WupPer\" must be of length 2")
}
if (any(is.na(WupPer))) {
stop("Non convenient date format for the warm-up period \"WupPer\"")
} else {
WupInd <- which(PrepGR$InputsModel$DatesR == WupPer[1]):which(PrepGR$InputsModel$DatesR == WupPer[2])
if (!any(PrepGR$InputsModel$DatesR == WupPer[1]) | !any(PrepGR$InputsModel$DatesR == WupPer[2])) {
stop("Non convenient date for the warm-up period \"WupPer\"")
} else {
WupInd <- which(PrepGR$InputsModel$DatesR == WupPer[1]):which(PrepGR$InputsModel$DatesR == WupPer[2])
}
}
} else {
WupInd <- 0L
}
}
......
Supports Markdown
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