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

v1.2.9.8 CLEAN: syntax revision of TransfoParam_GR6J

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