From f4d12c1696ebd8d88bdce2b0ef9cd4685ea3ca01 Mon Sep 17 00:00:00 2001 From: Delaigue Olivier <olivier.delaigue@irstea.fr> Date: Fri, 23 Apr 2021 11:43:42 +0200 Subject: [PATCH] refactor: set GR5H X1 transformation as it is done for GR4H Refs #50 --- R/TransfoParam_GR5H.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/R/TransfoParam_GR5H.R b/R/TransfoParam_GR5H.R index 11df92a9..cd9b604d 100644 --- a/R/TransfoParam_GR5H.R +++ b/R/TransfoParam_GR5H.R @@ -2,13 +2,13 @@ TransfoParam_GR5H <- function(ParamIn, Direction) { ## number of model parameters NParam <- 5L - - + + ## check arguments isVecParamIn <- is.vector(ParamIn) if (isVecParamIn) { ParamIn <- matrix(ParamIn, nrow = 1) - } + } if (!inherits(ParamIn, "matrix")) { stop("'ParamIn' must be of class 'matrix'") } @@ -18,32 +18,32 @@ TransfoParam_GR5H <- function(ParamIn, Direction) { if (ncol(ParamIn) != NParam) { stop(sprintf("the GR5H model requires %i parameters", NParam)) } - - + + ## transformation if (Direction == "TR") { ParamOut <- ParamIn - ParamOut[, 1] <- exp(1.5 * ParamIn[, 1]) ### GR5H X1 (production store capacity) - ParamOut[, 2] <- sinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient) - ParamOut[, 3] <- exp(ParamIn[, 3]) ### GR5H X3 (routing store capacity) + ParamOut[, 1] <- exp(ParamIn[, 1]) ### GR5H X1 (production store capacity) + ParamOut[, 2] <- sinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient) + ParamOut[, 3] <- exp(ParamIn[, 3]) ### GR5H X3 (routing store capacity) ParamOut[, 4] <- 480 + (480 - 0.01) * (ParamIn[, 4] - 10) / 20 ### GR5H X4 (unit hydrograph time constant) ParamOut[, 5] <- (ParamIn[, 5] + 10) / 20 ### GR5H X5 (groundwater exchange coefficient 2) } if (Direction == "RT") { ParamOut <- ParamIn - ParamOut[, 1] <- log(ParamIn[, 1]) / 1.5 ### GR5H X1 (production store capacity) - ParamOut[, 2] <- asinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient) - ParamOut[, 3] <- log(ParamIn[, 3]) ### GR5H X3 (routing store capacity) + ParamOut[, 1] <- log(ParamIn[, 1]) ### GR5H X1 (production store capacity) + ParamOut[, 2] <- asinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient) + ParamOut[, 3] <- log(ParamIn[, 3]) ### GR5H X3 (routing store capacity) ParamOut[, 4] <- (ParamIn[, 4] - 480) * 20 / (480 - 0.01) + 10 ### GR5H X4 (unit hydrograph time constant) ParamOut[, 5] <- ParamIn[, 5] * 20 - 10 ### GR5H X5 (groundwater exchange coefficient 2) } - + ## check output if (isVecParamIn) { ParamOut <- as.vector(ParamOut) } - + return(ParamOut) } -- GitLab