Commit b8b29b91 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

Merge branch '50-adjust-transfoparam_gr5h-production-store' into 'dev'

Resolve "Adjust TransfoParam_GR5H (production store)"

Closes #50

See merge request !44
Showing with 13 additions and 13 deletions
+13 -13
...@@ -2,13 +2,13 @@ TransfoParam_GR5H <- function(ParamIn, Direction) { ...@@ -2,13 +2,13 @@ TransfoParam_GR5H <- function(ParamIn, Direction) {
## number of model parameters ## number of model parameters
NParam <- 5L NParam <- 5L
## check arguments ## check arguments
isVecParamIn <- is.vector(ParamIn) isVecParamIn <- is.vector(ParamIn)
if (isVecParamIn) { if (isVecParamIn) {
ParamIn <- matrix(ParamIn, nrow = 1) ParamIn <- matrix(ParamIn, nrow = 1)
} }
if (!inherits(ParamIn, "matrix")) { if (!inherits(ParamIn, "matrix")) {
stop("'ParamIn' must be of class 'matrix'") stop("'ParamIn' must be of class 'matrix'")
} }
...@@ -18,32 +18,32 @@ TransfoParam_GR5H <- function(ParamIn, Direction) { ...@@ -18,32 +18,32 @@ TransfoParam_GR5H <- function(ParamIn, Direction) {
if (ncol(ParamIn) != NParam) { if (ncol(ParamIn) != NParam) {
stop(sprintf("the GR5H model requires %i parameters", NParam)) stop(sprintf("the GR5H model requires %i parameters", NParam))
} }
## transformation ## transformation
if (Direction == "TR") { if (Direction == "TR") {
ParamOut <- ParamIn ParamOut <- ParamIn
ParamOut[, 1] <- exp(1.5 * ParamIn[, 1]) ### GR5H X1 (production store capacity) ParamOut[, 1] <- exp(ParamIn[, 1]) ### GR5H X1 (production store capacity)
ParamOut[, 2] <- sinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient) ParamOut[, 2] <- sinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient)
ParamOut[, 3] <- exp(ParamIn[, 3]) ### GR5H X3 (routing store capacity) 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[, 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) ParamOut[, 5] <- (ParamIn[, 5] + 10) / 20 ### GR5H X5 (groundwater exchange coefficient 2)
} }
if (Direction == "RT") { if (Direction == "RT") {
ParamOut <- ParamIn ParamOut <- ParamIn
ParamOut[, 1] <- log(ParamIn[, 1]) / 1.5 ### GR5H X1 (production store capacity) ParamOut[, 1] <- log(ParamIn[, 1]) ### GR5H X1 (production store capacity)
ParamOut[, 2] <- asinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient) ParamOut[, 2] <- asinh(ParamIn[, 2]) ### GR5H X2 (groundwater exchange coefficient)
ParamOut[, 3] <- log(ParamIn[, 3]) ### GR5H X3 (routing store capacity) 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[, 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) ParamOut[, 5] <- ParamIn[, 5] * 20 - 10 ### GR5H X5 (groundwater exchange coefficient 2)
} }
## check output ## check output
if (isVecParamIn) { if (isVecParamIn) {
ParamOut <- as.vector(ParamOut) ParamOut <- as.vector(ParamOut)
} }
return(ParamOut) return(ParamOut)
} }
......
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