diff --git a/DESCRIPTION b/DESCRIPTION index 329a72570d1b779506ced11d693322ab8a9feec8..4616048782c9fbe935d06c4bff6290408921a43a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.2.14.6 -Date: 2019-04-16 +Version: 1.2.14.7 +Date: 2019-04-17 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@irstea.fr"), diff --git a/NEWS.rmd b/NEWS.rmd index 409a0708611753bf602af0522cb10f73742aa1ac..df2706e19c45fab5fb87b52c48874c93408bfd0f 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -14,7 +14,7 @@ output: -### 1.2.14.6 Release Notes (2019-04-16) +### 1.2.14.7 Release Notes (2019-04-17) #### New features diff --git a/R/Utils.R b/R/Utils.R index 69fe7901e0df2d7a29d1eafb53c57fd029ece87c..268074a58d0b1c9abfce776c4e2fe49403a4c27f 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -81,17 +81,17 @@ ## function to manage inputs of specific ErrorCrit_*() functions ## ================================================================================= -.ErrorCrit <- function(InputsCrit, crit) { +.ErrorCrit <- function(InputsCrit, Crit, OutputsModel, warnings) { ## Arguments check if (!inherits(InputsCrit, "InputsCrit")) { stop("'InputsCrit' must be of class 'InputsCrit'", call. = FALSE) } if (inherits(InputsCrit, "Multi") | inherits(InputsCrit, "Compo")) { - if (crit == "RMSE") { + if (Crit == "RMSE") { stop("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' with RMSE", call. = FALSE) } else { - stop(paste0("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with ", crit), call. = FALSE) + stop(paste0("'InputsCrit' must be of class 'Single'. Use the 'ErrorCrit' function on objects of class 'Multi' or 'Compo' with ", Crit), call. = FALSE) } } @@ -100,25 +100,25 @@ CritName <- NA CritVar <- InputsCrit$VarObs if (InputsCrit$transfo == "") { - CritName <- paste0(crit, "[CritVar]") + CritName <- paste0(Crit, "[CritVar]") } if (InputsCrit$transfo %in% c("sqrt", "log", "sort")) { - CritName <- paste0(crit, "[", InputsCrit$transfo, "(CritVar)]") + CritName <- paste0(Crit, "[", InputsCrit$transfo, "(CritVar)]") } if (InputsCrit$transfo == "inv") { - CritName <- paste0(crit, "[1/CritVar]") + CritName <- paste0(Crit, "[1/CritVar]") } - if (grepl("^", InputsCrit$transfo)) { - transfoPow <- as.numeric(gsub("^", "", InputsCrit$transfo)) - CritName <- paste0(crit, "[CritVar^", transfoPow, "]") + if (grepl("\\^", InputsCrit$transfo)) { + transfoPow <- suppressWarnings(as.numeric(gsub("\\^", "", InputsCrit$transfo))) + CritName <- paste0(Crit, "[CritVar^", transfoPow, "]") } CritName <- gsub(pattern = "CritVar", replacement = CritVar, x = CritName) CritValue <- NA - if (crit %in% c("RMSE")) { + if (Crit %in% c("RMSE")) { CritBestValue <- +1 Multiplier <- +1 } - if (crit %in% c("NSE", "KGE", "KGE2")) { + if (Crit %in% c("NSE", "KGE", "KGE2")) { CritBestValue <- +1 Multiplier <- -1 } @@ -172,7 +172,7 @@ VarObs <- sort(VarObs, na.last = TRUE) InputsCrit$BoolCrit <- sort(InputsCrit$BoolCrit, decreasing = TRUE) } - if ("exp" %in% InputsCrit$transfo) { + if (grepl("\\^", InputsCrit$transfo)) { VarObs <- VarObs^transfoPow VarSim <- VarSim^transfoPow } @@ -184,7 +184,7 @@ if (length(Ind_TS_ignore) == 0) { Ind_TS_ignore <- NULL } - if (sum(!TS_ignore) == 0 | (sum(!TS_ignore) == 1 & crit %in% c("KGE", "KGE2"))) { + if (sum(!TS_ignore) == 0 | (sum(!TS_ignore) == 1 & Crit %in% c("KGE", "KGE2"))) { CritCompute <- FALSE } else { CritCompute <- TRUE @@ -214,7 +214,9 @@ Multiplier = Multiplier, CritName = CritName, CritVar = CritVar, - CritCompute = CritCompute) + CritCompute = CritCompute, + TS_ignore = TS_ignore, + Ind_TS_ignore = Ind_TS_ignore) }