An error occurred while loading the file. Please try again.
-
Dorchies David authored
- Modified CreateInputsCrit for handling parameters Refs #111
755717fc
ErrorCrit_RMSE <- function(InputsCrit, OutputsModel, warnings = TRUE, verbose = TRUE) {
##Arguments_check________________________________
if (!inherits(InputsCrit, "InputsCrit")) {
stop("InputsCrit must be of class 'InputsCrit' \n")
return(NULL)
}
if (!inherits(OutputsModel, "OutputsModel")) {
stop("OutputsModel must be of class 'OutputsModel' \n")
return(NULL)
}
##Initialisation_________________________________
CritName <- NA
if (InputsCrit$transfo == "") {
CritName <- "RMSE[Q]"
}
if (InputsCrit$transfo == "sqrt") {
CritName <- "RMSE[sqrt(Q)]"
}
if (InputsCrit$transfo == "log") {
CritName <- "RMSE[log(Q)]"
}
if (InputsCrit$transfo == "inv") {
CritName <- "RMSE[1/Q]"
}
if (InputsCrit$transfo == "sort") {
CritName <- "RMSE[sort(Q)]"
}
CritValue <- NA
CritBestValue <- +1
Multiplier <- +1
### must be equal to -1 or +1 only
##Data_preparation_______________________________
VarObs <- InputsCrit$obs
VarObs[!InputsCrit$BoolCrit] <- NA
VarSim <- OutputsModel$Qsim
VarSim[!InputsCrit$BoolCrit] <- NA
##Data_transformation
if (InputsCrit$transfo %in% c("log", "inv") & is.null(InputsCrit$epsilon) & warnings) {
if (any(VarObs %in% 0)) {
warning("zeroes detected in Qobs: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL")
}
if (any(VarSim %in% 0)) {
warning("zeroes detected in Qsim: the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL")
}
}
if ("epsilon" %in% names(InputsCrit) & !is.null(InputsCrit$epsilon)) {
VarObs <- VarObs + InputsCrit$epsilon
VarSim <- VarSim + InputsCrit$epsilon
}
if (InputsCrit$transfo == "sqrt") {
VarObs <- sqrt(VarObs)
VarSim <- sqrt(VarSim)
}
if (InputsCrit$transfo == "log") {
VarObs <- log(VarObs)
VarSim <- log(VarSim)
VarSim[VarSim < -1e100] <- NA
}
if (InputsCrit$transfo == "inv") {
VarObs <- 1 / VarObs
VarSim <- 1 / VarSim
VarSim[abs(VarSim) > 1e+100] <- NA
}