Commit 7175007b authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.2.9.8 CLEAN: syntax revision of TransfoParam_GR6J

parent 52d20262
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.2.9.7
Version: 1.2.9.8
Date: 2019-03-13
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -13,7 +13,7 @@ output:
### 1.2.9.7 Release Notes (2019-03-13)
### 1.2.9.8 Release Notes (2019-03-13)
......
TransfoParam_GR6J <- function(ParamIn,Direction){
NParam <- 6;
Bool <- is.matrix(ParamIn);
if(Bool==FALSE){ ParamIn <- rbind(ParamIn); }
if(ncol(ParamIn)!=NParam){ stop(paste("the GR6J model requires ",NParam," parameters",sep="")) }
if(Direction=="TR"){
ParamOut <- ParamIn;
ParamOut[,1] <- exp(ParamIn[,1]); ### GR6J X1 (production store capacity)
ParamOut[,2] <- sinh(ParamIn[,2]); ### GR6J X2 (groundwater exchange coefficient 1)
ParamOut[,3] <- exp(ParamIn[,3]); ### GR6J X3 (routing store capacity)
ParamOut[,4] <- 20+19.5*(ParamIn[,4]-9.99)/19.98; ### GR6J X4 (unit hydrograph time constant)
ParamOut[,5] <- ParamIn[,5]/5.; ### GR5J X5 (groundwater exchange coefficient 2)
ParamOut[,6] <- exp(ParamIn[,6]); ### GR6J X6 (coefficient for emptying exponential store)
TransfoParam_GR6J <- function(ParamIn, Direction) {
NParam <- 6
Bool <- is.matrix(ParamIn)
if (Bool == FALSE) {
ParamIn <- rbind(ParamIn)
}
if(Direction=="RT"){
ParamOut <- ParamIn;
ParamOut[,1] <- log(ParamIn[,1]); ### GR6J X1 (production store capacity)
ParamOut[,2] <- asinh(ParamIn[,2]); ### GR6J X2 (groundwater exchange coefficient 1)
ParamOut[,3] <- log(ParamIn[,3]); ### GR6J X3 (routing store capacity)
ParamOut[,4] <- 9.99+19.98*(ParamIn[,4]-20)/19.5; ### GR6J X4 (unit hydrograph time constant)
ParamOut[,5] <- ParamIn[,5] * 5.; ### GR5J X5 (groundwater exchange coefficient 2)
ParamOut[,6] <- log(ParamIn[,6]); ### GR6J X6 (coefficient for emptying exponential store)
if (ncol(ParamIn) != NParam) {
stop(sprintf("the GR6J model requires %i parameters", NParam))
}
if(Bool==FALSE){ ParamOut <- ParamOut[1,]; }
return(ParamOut);
if (Direction == "TR") {
ParamOut <- ParamIn
}
ParamOut[, 1] <- exp(ParamIn[, 1])
### GR6J X1 (production store capacity)
ParamOut[, 2] <- sinh(ParamIn[, 2])
### GR6J X2 (groundwater exchange coefficient 1)
ParamOut[, 3] <- exp(ParamIn[, 3])
### GR6J X3 (routing store capacity)
ParamOut[, 4] <- 20 + 19.5 * (ParamIn[, 4] - 9.99) / 19.98
### GR6J X4 (unit hydrograph time constant)
ParamOut[, 5] <- ParamIn[, 5] / 5.
### GR5J X5 (groundwater exchange coefficient 2)
ParamOut[, 6] <- exp(ParamIn[, 6])
### GR6J X6 (coefficient for emptying exponential store)
}
if (Direction == "RT") {
ParamOut <- ParamIn
ParamOut[, 1] <- log(ParamIn[, 1])
### GR6J X1 (production store capacity)
ParamOut[, 2] <- asinh(ParamIn[, 2])
### GR6J X2 (groundwater exchange coefficient 1)
ParamOut[, 3] <- log(ParamIn[, 3])
### GR6J X3 (routing store capacity)
ParamOut[, 4] <- 9.99 + 19.98 * (ParamIn[, 4] - 20) / 19.5
### GR6J X4 (unit hydrograph time constant)
ParamOut[, 5] <- ParamIn[, 5] * 5.
### GR5J X5 (groundwater exchange coefficient 2)
ParamOut[, 6] <- log(ParamIn[, 6])
### GR6J X6 (coefficient for emptying exponential store)
}
if (Bool == FALSE) {
ParamOut <- ParamOut[1, ]
}
return(ParamOut)
}
Markdown is supported
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