From 5287148e836ffcfab9d4d03e5f44bcd22ccad9a5 Mon Sep 17 00:00:00 2001 From: Delaigue Olivier <olivier.delaigue@irstea.priv> Date: Wed, 20 Nov 2019 10:35:52 +0100 Subject: [PATCH] v1.3.2.60 BUG: boxcox transformation formula corrected in .ErrorCrit #19 moreover, epsilon is useless with this transformation --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/Utils.R | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a1368521..7fac5438 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.3.2.59 +Version: 1.3.2.60 Date: 2019-11-20 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 d6a54785..3da7fe44 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ -### 1.3.2.59 Release Notes (2019-11-19) +### 1.3.2.60 Release Notes (2019-11-20) #### New features @@ -15,6 +15,7 @@ - Fixed bug in <code>TransfoParam_GR1A()</code>. The number of model parameters was wrong (2 instead of 1) which caused an error when the GR1 model during the calibration. - Fixed bug in <code>plot.OutputsModel()</code>. The function does not return any error message when <code>log_scale = TRUE</code>, <code>Qobs = NULL</code> and user want to draw flows time series. - Fixed bug in <code>RunModel_*GR*()</code>. The functions do not return any error message anymore due to slightly negative values returned by GR4H, GR4J, GR5J or GR6J Fortran codes (the message was returned by <code>CreateIniStates()</code> when the final states were created). The <code>RunModel_*GR*()</code> functions now returns zero instead of these slightly negative values, except for the ExpStore where negatives values are allowed. +- Fixed bug in the <code>.ErrorCrit()</code> function. The Box-Cox transformation formula is now corrected when the <code>ErrorCrit*()</code> are used. #### Minor user-visible changes diff --git a/R/Utils.R b/R/Utils.R index bce34322..435bced0 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -148,7 +148,7 @@ warning("zeroes detected in 'Qsim': the corresponding time-steps will be excluded from the criteria computation if the epsilon argument of 'CreateInputsCrit' = NULL", call. = FALSE) } } - if ("epsilon" %in% names(InputsCrit) & !is.null(InputsCrit$epsilon)) { + if ("epsilon" %in% names(InputsCrit) & !is.null(InputsCrit$epsilon) & !(InputsCrit$transfo == "boxcox")) { VarObs <- VarObs + InputsCrit$epsilon VarSim <- VarSim + InputsCrit$epsilon } @@ -173,8 +173,9 @@ InputsCrit$BoolCrit <- sort(InputsCrit$BoolCrit, decreasing = TRUE) } if (InputsCrit$transfo == "boxcox") { - VarSim <- (VarSim^0.25 - 0.01 * mean(VarSim, na.rm = TRUE)) / 0.25 - VarObs <- (VarObs^0.25 - 0.01 * mean(VarObs, na.rm = TRUE)) / 0.25 + muTransfoVarObs <- (0.01 * mean(VarObs, na.rm = TRUE))^0.25 + VarSim <- (VarSim^0.25 - muTransfoVarObs) / 0.25 + VarObs <- (VarObs^0.25 - muTransfoVarObs) / 0.25 } if (grepl("\\^", InputsCrit$transfo)) { VarObs <- VarObs^transfoPow @@ -221,7 +222,6 @@ CritCompute = CritCompute, TS_ignore = TS_ignore, Ind_TS_ignore = Ind_TS_ignore) - } -- GitLab