Commit 19abbf1d authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.0.10.7 add a warning message in CreateInputsCrit when the KGE (or KGE') is...

v1.0.10.7 add a warning message in CreateInputsCrit when the KGE (or KGE') is used with a log transfo on Q
Showing with 45 additions and 24 deletions
+45 -24
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.0.10.6 Version: 1.0.10.7
Date: 2018-05-22 Date: 2018-06-15
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl")), person("Laurent", "Coron", role = c("aut", "trl")),
person("Charles", "Perrin", role = c("aut", "ths")), person("Charles", "Perrin", role = c("aut", "ths")),
......
...@@ -14,7 +14,7 @@ output: ...@@ -14,7 +14,7 @@ output:
### 1.0.10.6 Release Notes (2018-05-22) ### 1.0.10.7 Release Notes (2018-06-15)
____________________________________________________________________________________ ____________________________________________________________________________________
......
CreateInputsCrit <- CreateInputsCrit <- function(FUN_CRIT,
function(FUN_CRIT, InputsModel,
InputsModel, RunOptions,
RunOptions, Qobs,
Qobs, BoolCrit = NULL,
BoolCrit = NULL, transfo = "",
transfo = "", Ind_zeroes = NULL,
Ind_zeroes = NULL, epsilon = NULL,
epsilon = NULL) { verbose = TRUE) {
ObjectClass <- NULL
ObjectClass <- NULL
##check_FUN_CRIT
BOOL <- FALSE
##check_FUN_CRIT
BOOL <- FALSE
if (identical(FUN_CRIT, ErrorCrit_NSE) | identical(FUN_CRIT, ErrorCrit_KGE) | if (identical(FUN_CRIT, ErrorCrit_NSE) | identical(FUN_CRIT, ErrorCrit_KGE) |
identical(FUN_CRIT, ErrorCrit_KGE2) | identical(FUN_CRIT, ErrorCrit_RMSE)) { identical(FUN_CRIT, ErrorCrit_KGE2) | identical(FUN_CRIT, ErrorCrit_RMSE)) {
...@@ -77,7 +79,7 @@ CreateInputsCrit <- ...@@ -77,7 +79,7 @@ CreateInputsCrit <-
stop("transfo must be a chosen among the following: '', 'sqrt', 'log' or 'inv' or 'sort' \n") stop("transfo must be a chosen among the following: '', 'sqrt', 'log' or 'inv' or 'sort' \n")
return(NULL) return(NULL)
} }
if (transfo %in% c("", "sqrt", "log", "inv", "sort") == FALSE) { if (! transfo %in% c("", "sqrt", "log", "inv", "sort")) {
stop("transfo must be a chosen among the following: '', 'sqrt', 'log' or 'inv' or 'sort' \n") stop("transfo must be a chosen among the following: '', 'sqrt', 'log' or 'inv' or 'sort' \n")
return(NULL) return(NULL)
} }
...@@ -102,12 +104,22 @@ CreateInputsCrit <- ...@@ -102,12 +104,22 @@ CreateInputsCrit <-
epsilon = as.double(epsilon) epsilon = as.double(epsilon)
} }
if (transfo == "log" & verbose) {
warn_log_kge <- "we do not advise using the %s with a log transformation on Qobs (see the details part in the 'CreateInputsCrit' help)"
if (identical(FUN_CRIT, ErrorCrit_KGE)) {
warning(sprintf(warn_log_kge, "KGE"))
}
if (identical(FUN_CRIT, ErrorCrit_KGE2)) {
warning(sprintf(warn_log_kge, "KGE'"))
}
}
##Create_InputsCrit ##Create_InputsCrit
InputsCrit <- list(BoolCrit = BoolCrit, InputsCrit <- list(BoolCrit = BoolCrit,
Qobs = Qobs, Qobs = Qobs,
transfo = transfo, transfo = transfo,
Ind_zeroes = Ind_zeroes, Ind_zeroes = Ind_zeroes,
epsilon = epsilon) epsilon = epsilon)
class(InputsCrit) <- c("InputsCrit", ObjectClass) class(InputsCrit) <- c("InputsCrit", ObjectClass)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
\usage{ \usage{
CreateInputsCrit(FUN_CRIT, InputsModel, RunOptions, Qobs, BoolCrit = NULL, CreateInputsCrit(FUN_CRIT, InputsModel, RunOptions, Qobs, BoolCrit = NULL,
transfo = "", Ind_zeroes = NULL, epsilon = NULL) transfo = "", Ind_zeroes = NULL, epsilon = NULL, verbose = TRUE)
} }
...@@ -30,6 +30,8 @@ CreateInputsCrit(FUN_CRIT, InputsModel, RunOptions, Qobs, BoolCrit = NULL, ...@@ -30,6 +30,8 @@ CreateInputsCrit(FUN_CRIT, InputsModel, RunOptions, Qobs, BoolCrit = NULL,
\item{Ind_zeroes}{(optional) [numeric] indices of the time steps where zeroes are observed} \item{Ind_zeroes}{(optional) [numeric] indices of the time steps where zeroes are observed}
\item{epsilon}{(optional) [numeric] epsilon to add to all Qobs and Qsim if \emph{$Ind_zeroes} is not empty} \item{epsilon}{(optional) [numeric] epsilon to add to all Qobs and Qsim if \emph{$Ind_zeroes} is not empty}
\item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}}
} }
...@@ -52,7 +54,8 @@ Creation of the \emph{InputsCrit} object required to the \code{ErrorCrit*} funct ...@@ -52,7 +54,8 @@ Creation of the \emph{InputsCrit} object required to the \code{ErrorCrit*} funct
\details{ \details{
Users wanting to use \code{FUN_CRIT} functions that are not included in Users wanting to use \code{FUN_CRIT} functions that are not included in
the package must create their own InputsCrit object accordingly. the package must create their own InputsCrit object accordingly. \cr
We do not advise computing KGE or KGE' with log-transformation as it might be wrongly influenced by discharge values close to 0 or 1 and it is dependent on the discharge unit. See Santos et al. (in review) for more details and alternative solutions (see the reference below).
} }
...@@ -119,6 +122,12 @@ OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsMode ...@@ -119,6 +122,12 @@ OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsMode
Laurent Coron Laurent Coron
} }
\references{
Santos, L., Thirel, G. and Perrin, C. (in review),
Technical note : Pitfalls in using log-transformed flows within the KGE criterion,
Hydrology and Earth System Sciences Discussions, doi:10.5194/hess-2018-298.
}
\seealso{ \seealso{
\code{\link{RunModel}}, \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, \code{\link{CreateCalibOptions}} \code{\link{RunModel}}, \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, \code{\link{CreateCalibOptions}}
......
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