diff --git a/DESCRIPTION b/DESCRIPTION index 033ecb5713047d8632e91da7ced797b7bd722694..4d93f1c1e64ffb18e06cba8f06b36ed2fffe0e63 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.4.2.14 +Version: 1.4.2.15 Date: 2019-12-11 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.md b/NEWS.md index 72c115799372f1fa446b72f32b7913e35db75c14..426274bb629ae976364e33c803d12170c3dc8b43 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ -### 1.4.2.14 Release Notes (2019-12-11) +### 1.4.2.15 Release Notes (2019-12-11) #### New features diff --git a/R/CreateRunOptions.R b/R/CreateRunOptions.R index 9322c37da3c7c20c6ba3fd2a45c81d8db8abe92a..1c145a949b5f0504757ef1694f6e84a77a78d342 100644 --- a/R/CreateRunOptions.R +++ b/R/CreateRunOptions.R @@ -178,37 +178,65 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP ## check IniResLevels if ("GR" %in% ObjectClass & ("monthly" %in% ObjectClass | "daily" %in% ObjectClass | "hourly" %in% ObjectClass)) { if (!is.null(IniResLevels)) { - if (!is.vector(IniResLevels) | !is.numeric(IniResLevels) | any(is.na(IniResLevels))) { - stop("'IniResLevels' must be a vector of numeric values") + # if (!is.vector(IniResLevels) | !is.numeric(IniResLevels) | any(is.na(IniResLevels))) { + if (!is.vector(IniResLevels) | is.character(IniResLevels) | is.factor(IniResLevels) | length(IniResLevels) != 4) { + stop("'IniResLevels' must be a vector of 4 numeric values") } - if ((identical(FUN_MOD, RunModel_GR4H) | identical(FUN_MOD, RunModel_CemaNeigeGR4H) | - (identical(FUN_MOD, RunModel_GR5H) & !IsIntStore) | - identical(FUN_MOD, RunModel_GR4J) | identical(FUN_MOD, RunModel_CemaNeigeGR4J) | - identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) | - identical(FUN_MOD, RunModel_GR2M)) & - length(IniResLevels) != 2) { - stop("the length of 'IniResLevels' must be 2 for the chosen 'FUN_MOD'") + # if ((identical(FUN_MOD, RunModel_GR4H) | identical(FUN_MOD, RunModel_CemaNeigeGR4H) | + # # (identical(FUN_MOD, RunModel_GR5H) & !IsIntStore) | + # identical(FUN_MOD, RunModel_GR5H) | + # identical(FUN_MOD, RunModel_GR4J) | identical(FUN_MOD, RunModel_CemaNeigeGR4J) | + # identical(FUN_MOD, RunModel_GR5J) | identical(FUN_MOD, RunModel_CemaNeigeGR5J) | + # identical(FUN_MOD, RunModel_GR2M)) & + # length(IniResLevels) != 2) { + # stop("the length of 'IniResLevels' must be 2 for the chosen 'FUN_MOD'") + # } + if (any(is.na(IniResLevels[1:2]))) { + stop("the first 2 values of 'IniResLevels' cannot be missing values for the chosen 'FUN_MOD'") } - if ((identical(FUN_MOD,RunModel_GR6J) | identical(FUN_MOD,RunModel_CemaNeigeGR6J) | - (identical(FUN_MOD, RunModel_GR5H) & IsIntStore)) & - length(IniResLevels) != 3) { - stop("the length of 'IniResLevels' must be 3 for the chosen 'FUN_MOD'") + # if ((identical(FUN_MOD,RunModel_GR6J) | identical(FUN_MOD,RunModel_CemaNeigeGR6J) | + # (identical(FUN_MOD, RunModel_GR5H) & IsIntStore)) & + # length(IniResLevels) != 3) { + # stop("the length of 'IniResLevels' must be 3 for the chosen 'FUN_MOD'") + # } + if ((identical(FUN_MOD,RunModel_GR6J) | identical(FUN_MOD,RunModel_CemaNeigeGR6J))) { + if (is.na(IniResLevels[3L])) { + stop("the third value of 'IniResLevels' cannot be a missing value for the chosen 'FUN_MOD'") + } + } else { + if (!is.na(IniResLevels[3L])) { + warning("the third value of 'IniResLevels' is set to NA value for the chosen 'FUN_MOD'. Only GR6J presents an exponential store") + IniResLevels[3L] <- NA + } } + if (identical(FUN_MOD,RunModel_GR5H)) { # | identical(FUN_MOD,RunModel_CemaNeigeGR5H) + if (IsIntStore & is.na(IniResLevels[4L])) { + stop("the fourth value of 'IniResLevels' cannot be a missing value for the chosen 'FUN_MOD' with a given value set for 'Imax") + } + if (!IsIntStore & !is.na(IniResLevels[4L])) { + warning("the fourth value of 'IniResLevels' is set to NA value for the chosen 'FUN_MOD'. Only GR5H uses with an 'Imax' value presents an interception store") + IniResLevels[4L] <- NA + } + } else { + if (!is.na(IniResLevels[4L])) { + warning("the fourth value of 'IniResLevels' is set to NA value for the chosen 'FUN_MOD'. Only GR5H uses with an 'Imax' value presents an interception store") + IniResLevels[4L] <- NA + } + } } else if (is.null(IniStates)) { + IniResLevels <- as.double(c(0.3, 0.5, NA, NA)) if (identical(FUN_MOD, RunModel_GR6J) | identical(FUN_MOD, RunModel_CemaNeigeGR6J)) { IniResLevels <- as.double(c(0.3, 0.5, 0, NA)) } # if ((identical(FUN_MOD, RunModel_GR5H) | identical(FUN_MOD, RunModel_CemaNeigeGR5H)) & IsIntStore) { if ((identical(FUN_MOD, RunModel_GR5H)) & IsIntStore) { - IniResLevels <- as.double(c(0.3, 0.5, NA, 0)) } # if (!identical(FUN_MOD, RunModel_GR6J) & !identical(FUN_MOD, RunModel_CemaNeigeGR6J) & # !identical(FUN_MOD, RunModel_GR5H) & !identical(FUN_MOD, RunModel_CemaNeigeGR5H)) { - if (!identical(FUN_MOD, RunModel_GR6J) & !identical(FUN_MOD, RunModel_CemaNeigeGR6J) & - !identical(FUN_MOD, RunModel_GR5H)) { - IniResLevels <- as.double(c(0.3, 0.5, NA, NA)) - } + # if (is.null(IniStates)) { + # IniResLevels <- as.double(c(0.3, 0.5, NA, NA)) + # } } } else { if (!is.null(IniResLevels)) {