Commit 6bd48cbb authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

Merge branch '168-error-message-slightly-wrong-for-transfoparamgr5j' into 'dev'

Resolve "Error message slightly wrong for TransfoParamGR5J"

Closes #168

See merge request !83
2 merge requests!95docs(man): review text of the '$CemaNeigeLayers' element in the 'value'...,!83Resolve "Error message slightly wrong for TransfoParamGR5J"
Pipeline #49407 failed with stages
in 10 minutes and 26 seconds
Showing with 12 additions and 12 deletions
+12 -12
TransfoParam_GR5J <- 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'")
}
......@@ -17,10 +17,10 @@ TransfoParam_GR5J <- function(ParamIn, Direction) {
stop("'Direction' must be a character vector of length 1 equal to 'RT' or 'TR'")
}
if (ncol(ParamIn) != NParam) {
stop(sprintf("the GR4J model requires %i parameters", NParam))
stop(sprintf("the GR5J model requires %i parameters", NParam))
}
## transformation
if (Direction == "TR") {
ParamOut <- ParamIn
......@@ -29,7 +29,7 @@ TransfoParam_GR5J <- function(ParamIn, Direction) {
ParamOut[, 3] <- exp(ParamIn[, 3]) ### GR5J X3 (routing store capacity)
ParamOut[, 4] <- 20 + 19.5 * (ParamIn[, 4] - 9.99) / 19.98 ### GR5J X4 (unit hydrograph time constant)
ParamOut[, 5] <- (ParamIn[, 5] + 9.99) / 19.98 ### GR5J X5 (groundwater exchange coefficient 2)
}
}
if (Direction == "RT") {
ParamOut <- ParamIn
ParamOut[, 1] <- log(ParamIn[, 1]) ### GR5J X1 (production store capacity)
......@@ -37,14 +37,14 @@ TransfoParam_GR5J <- function(ParamIn, Direction) {
ParamOut[, 3] <- log(ParamIn[, 3]) ### GR5J X3 (routing store capacity)
ParamOut[, 4] <- 9.99 + 19.98 * (ParamIn[, 4] - 20) / 19.5 ### GR5J X4 (unit hydrograph time constant)
ParamOut[, 5] <- ParamIn[, 5] * 19.98 - 9.99 ### GR5J X5 (groundwater exchange coefficient 2)
}
}
## check output
if (isVecParamIn) {
ParamOut <- as.vector(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