diff --git a/R/TransfoParam_CemaNeige.R b/R/TransfoParam_CemaNeige.R index 73ba2134c7f1a4708abdb7908582585e64ca6df9..41dd37033fde1ce68ceb97a1bbab086f0adb59da 100644 --- a/R/TransfoParam_CemaNeige.R +++ b/R/TransfoParam_CemaNeige.R @@ -1,37 +1,23 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the CemaNeige module -#' @author Laurent Coron (December 2013) -#' @seealso \code{\link{TransfoParam}}, \code{\link{TransfoParam_GR4J}}, \code{\link{TransfoParam_GR5J}}, \code{\link{TransfoParam_GR6J}} -#' @example tests/example_TransfoParam_CemaNeige.R -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_CemaNeige <- function(ParamIn,Direction){ - NParam <- 2; - Bool <- is.matrix(ParamIn); - if(Bool==FALSE){ ParamIn <- rbind(ParamIn); } - if(ncol(ParamIn)!=NParam){ stop(paste("the CemaNeige module requires ",NParam," parameters \n",sep="")); return(NULL); } + NParam <- 2 + Bool <- is.matrix(ParamIn) + if(Bool==FALSE){ ParamIn <- rbind(ParamIn) } + if(ncol(ParamIn)!=NParam){ stop(paste("the CemaNeige module requires ",NParam," parameters \n",sep="")); return(NULL) } if(Direction=="TR"){ ParamOut <- ParamIn; - ParamOut[,1] <- (ParamIn[,1]+9.99)/19.98; ### CemaNeige X1 (weighting coefficient for snow pack thermal state) - ParamOut[,2] <- exp(ParamIn[,2]); ### CemaNeige X2 (degree-day melt coefficient) + ParamOut[,1] <- (ParamIn[,1]+9.99)/19.98 ### CemaNeige X1 (weighting coefficient for snow pack thermal state) + ParamOut[,2] <- exp(ParamIn[, 2]) / 200 ### CemaNeige X2 (degree-day melt coefficient) } if(Direction=="RT"){ ParamOut <- ParamIn; - ParamOut[,1] <- ParamIn[,1]*19.98-9.99; ### CemaNeige X1 (weighting coefficient for snow pack thermal state) - ParamOut[,2] <- log(ParamIn[,2]); ### CemaNeige X2 (degree-day melt coefficient) + ParamOut[,1] <- ParamIn[,1]*19.98-9.99 ### CemaNeige X1 (weighting coefficient for snow pack thermal state) + ParamOut[,2] <- log(ParamIn[,2] * 200) ### CemaNeige X2 (degree-day melt coefficient) } - if(Bool==FALSE){ ParamOut <- ParamOut[1,]; } - return(ParamOut); + if(Bool==FALSE){ ParamOut <- ParamOut[1,] } + return(ParamOut) } diff --git a/R/TransfoParam_GR1A.R b/R/TransfoParam_GR1A.R index 963d6bd4e3d950e7ddd6b3d6f6a44eae435bb788..b29fc1ec16d740b940a78323190ebc1974628587 100644 --- a/R/TransfoParam_GR1A.R +++ b/R/TransfoParam_GR1A.R @@ -1,15 +1,3 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the GR1A model -#' @author Laurent Coron (March 2015) -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_GR1A <- function(ParamIn,Direction){ NParam <- 1; diff --git a/R/TransfoParam_GR2M.R b/R/TransfoParam_GR2M.R index e3fba4cd02634f5fd268c7c77cc701945bb4c99e..6a963f62f25a9c8500b0632d9c972c430f9e9920 100644 --- a/R/TransfoParam_GR2M.R +++ b/R/TransfoParam_GR2M.R @@ -1,15 +1,3 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the GR2M model -#' @author Laurent Coron (March 2015) -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_GR2M <- function(ParamIn,Direction){ NParam <- 2; @@ -19,13 +7,13 @@ TransfoParam_GR2M <- function(ParamIn,Direction){ if(Direction=="TR"){ ParamOut <- ParamIn; - ParamOut[,1] <- exp(1.5*ParamIn[,1]); - ParamOut[,2] <- ParamIn[,2]/5; + ParamOut[,1] <- exp(ParamIn[,1]); + ParamOut[,2] <- ParamIn[, 2] / 4 + 2.5; } if(Direction=="RT"){ ParamOut <- ParamIn; - ParamOut[,1] <- log(ParamIn[,1])/1.5; - ParamOut[,2] <- ParamIn[,2]*5; + ParamOut[,1] <- log(ParamIn[,1]); + ParamOut[,2] <- (ParamIn[,2] - 2.5) * 4; } if(Bool==FALSE){ ParamOut <- ParamOut[1,]; } diff --git a/R/TransfoParam_GR4H.R b/R/TransfoParam_GR4H.R index caa4ac6c9e75f8f07e1f2e89d341d4504cdb4139..651d4da7c473abc412cb319180b5cafae9656f99 100644 --- a/R/TransfoParam_GR4H.R +++ b/R/TransfoParam_GR4H.R @@ -1,15 +1,3 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the GR4H model -#' @author Laurent Coron (July 2014) -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_GR4H <- function(ParamIn,Direction){ NParam <- 4; @@ -19,17 +7,17 @@ TransfoParam_GR4H <- function(ParamIn,Direction){ if(Direction=="TR"){ ParamOut <- ParamIn; - ParamOut[,1] <- exp(1.5*ParamIn[,1]); ### GR4H X1 (production store capacity) - ParamOut[,2] <- sinh(ParamIn[,2]); ### GR4H X2 (groundwater exchange coefficient) + ParamOut[,1] <- exp(ParamIn[,1]); ### GR4H X1 (production store capacity) + ParamOut[,2] <- sinh(ParamIn[, 2] / 3); ### GR4H X2 (groundwater exchange coefficient) ParamOut[,3] <- exp(ParamIn[,3]); ### GR4H X3 (routing store capacity) - ParamOut[,4] <- 20+(19.5*24)*(ParamIn[,4]-9.99)/(19.98*24); ### GR4H X4 (unit hydrograph time constant) + ParamOut[,4] <- 480 + (480 - 0.5) * (ParamIn[,4] - 9.99) / 19.98; ### GR4H X4 (unit hydrograph time constant) } if(Direction=="RT"){ ParamOut <- ParamIn; - ParamOut[,1] <- log(ParamIn[,1])/1.5; ### GR4H X1 (production store capacity) - ParamOut[,2] <- asinh(ParamIn[,2]); ### GR4H X2 (groundwater exchange coefficient) + ParamOut[,1] <- log(ParamIn[,1]); ### GR4H X1 (production store capacity) + ParamOut[,2] <- 3 * asinh(ParamIn[,2]); ### GR4H X2 (groundwater exchange coefficient) ParamOut[,3] <- log(ParamIn[,3]); ### GR4H X3 (routing store capacity) - ParamOut[,4] <- 9.99+(19.98*24)*(ParamIn[,4]-20)/(19.5*24); ### GR4H X4 (unit hydrograph time constant) + ParamOut[,4] <- (ParamIn[,4] - 480) * 19.98 / (480 - 0.5) + 9.99; ### GR4H X4 (unit hydrograph time constant) } if(Bool==FALSE){ ParamOut <- ParamOut[1,]; } diff --git a/R/TransfoParam_GR4J.R b/R/TransfoParam_GR4J.R index 2613179d3797eff0c8e0f171a60b8e6c7fc33fed..6f7f5a1395348884831234b379f0649d0712a0b4 100644 --- a/R/TransfoParam_GR4J.R +++ b/R/TransfoParam_GR4J.R @@ -1,17 +1,3 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the GR4J model -#' @author Laurent Coron (December 2013) -#' @seealso \code{\link{TransfoParam}}, \code{\link{TransfoParam_GR5J}}, \code{\link{TransfoParam_GR6J}}, \code{\link{TransfoParam_CemaNeige}} -#' @example tests/example_TransfoParam_GR4J.R -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_GR4J <- function(ParamIn,Direction){ NParam <- 4; @@ -21,14 +7,14 @@ TransfoParam_GR4J <- function(ParamIn,Direction){ if(Direction=="TR"){ ParamOut <- ParamIn; - ParamOut[,1] <- exp(1.5*ParamIn[,1]); ### GR4J X1 (production store capacity) + ParamOut[,1] <- exp(ParamIn[,1]); ### GR4J X1 (production store capacity) ParamOut[,2] <- sinh(ParamIn[,2]); ### GR4J X2 (groundwater exchange coefficient) ParamOut[,3] <- exp(ParamIn[,3]); ### GR4J X3 (routing store capacity) ParamOut[,4] <- 20+19.5*(ParamIn[,4]-9.99)/19.98; ### GR4J X4 (unit hydrograph time constant) } if(Direction=="RT"){ ParamOut <- ParamIn; - ParamOut[,1] <- log(ParamIn[,1])/1.5; ### GR4J X1 (production store capacity) + ParamOut[,1] <- log(ParamIn[,1]); ### GR4J X1 (production store capacity) ParamOut[,2] <- asinh(ParamIn[,2]); ### GR4J X2 (groundwater exchange coefficient) ParamOut[,3] <- log(ParamIn[,3]); ### GR4J X3 (routing store capacity) ParamOut[,4] <- 9.99+19.98*(ParamIn[,4]-20)/19.5; ### GR4J X4 (unit hydrograph time constant) diff --git a/R/TransfoParam_GR5J.R b/R/TransfoParam_GR5J.R index 126d25ba8597f8b17dd0f624c44075f52ab502d5..0492c1471464d86a479de150c3deb02967215205 100644 --- a/R/TransfoParam_GR5J.R +++ b/R/TransfoParam_GR5J.R @@ -1,17 +1,3 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the GR5J model -#' @author Laurent Coron (December 2013) -#' @seealso \code{\link{TransfoParam}}, \code{\link{TransfoParam_GR4J}}, \code{\link{TransfoParam_GR6J}}, \code{\link{TransfoParam_CemaNeige}} -#' @example tests/example_TransfoParam_GR5J.R -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_GR5J <- function(ParamIn,Direction){ NParam <- 5; @@ -21,21 +7,19 @@ TransfoParam_GR5J <- function(ParamIn,Direction){ if(Direction=="TR"){ ParamOut <- ParamIn; - ParamOut[,1] <- exp(1.5*ParamIn[,1]); ### GR5J X1 (production store capacity) + ParamOut[,1] <- exp(ParamIn[,1]); ### GR5J X1 (production store capacity) ParamOut[,2] <- sinh(ParamIn[,2]); ### GR5J X2 (groundwater exchange coefficient 1) 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] <- sinh(ParamIn[,5]); ### GR5J X5 (groundwater exchange coefficient 2) - ParamOut[,5] <- ParamIn[,5]/5; ### GR5J X5 (groundwater exchange coefficient 2) + ParamOut[,5] <- (ParamIn[,5] + 9.99) / 19.98; ### GR5J X5 (groundwater exchange coefficient 2) } if(Direction=="RT"){ ParamOut <- ParamIn; - ParamOut[,1] <- log(ParamIn[,1]) / 1.5; ### GR5J X1 (production store capacity) + ParamOut[,1] <- log(ParamIn[,1]); ### GR5J X1 (production store capacity) ParamOut[,2] <- asinh(ParamIn[,2]); ### GR5J X2 (groundwater exchange coefficient 1) 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] <- asinh(ParamIn[,5]); ### GR5J X5 (groundwater exchange coefficient 2) - ParamOut[,5] <- ParamIn[,5]*5; ### GR5J X5 (groundwater exchange coefficient 2) + ParamOut[,5] <- ParamIn[,5] * 19.98 - 9.99; ### GR5J X5 (groundwater exchange coefficient 2) } if(Bool==FALSE){ ParamOut <- ParamOut[1,]; } diff --git a/R/TransfoParam_GR6J.R b/R/TransfoParam_GR6J.R index ed558b69f7af0b695884d170fbf7b2ee000560b0..65ccf34f6b894c5c8390a5cd6f18a1319af9d560 100644 --- a/R/TransfoParam_GR6J.R +++ b/R/TransfoParam_GR6J.R @@ -1,17 +1,3 @@ -#************************************************************************************************** -#' Function which transforms model parameters (from real to transformed parameters and vice versa). -#************************************************************************************************** -#' @title Transformation of the parameters from the GR6J model -#' @author Laurent Coron (December 2013) -#' @seealso \code{\link{TransfoParam}}, \code{\link{TransfoParam_GR4J}}, \code{\link{TransfoParam_GR5J}}, \code{\link{TransfoParam_CemaNeige}} -#' @example tests/example_TransfoParam_GR6J.R -#' @encoding UTF-8 -#' @export -#_FunctionInputsOutputs____________________________________________________________________________ -#' @param ParamIn [numeric] matrix of parameter sets (sets in line, parameter values in column) -#' @param Direction [character] direction of the transformation: use "RT" for Real->Transformed and "TR" for Transformed->Real -#' @return \emph{ParamOut} [numeric] matrix of parameter sets (sets in line, parameter values in column) -#************************************************************************************************** TransfoParam_GR6J <- function(ParamIn,Direction){ NParam <- 6; @@ -21,22 +7,20 @@ TransfoParam_GR6J <- function(ParamIn,Direction){ if(Direction=="TR"){ ParamOut <- ParamIn; - ParamOut[,1] <- exp(1.5*ParamIn[,1]); ### GR6J X1 (production store capacity) + 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] <- sinh(ParamIn[,5]); ### GR6J X5 (groundwater exchange coefficient 2) - ParamOut[,5] <- ParamIn[,5]/5; ### GR6J X5 (groundwater exchange coefficient 2) + ParamOut[,5] <- (ParamIn[,5] + 9.99) / 19.98; ### 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]) / 1.5; ### GR6J X1 (production store capacity) + 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] <- asinh(ParamIn[,5]); ### GR6J X5 (groundwater exchange coefficient 2) - ParamOut[,5] <- ParamIn[,5]*5; ### GR6J X5 (groundwater exchange coefficient 2) + ParamOut[,5] <- ParamIn[,5] * 19.98 - 9.99; ### GR5J X5 (groundwater exchange coefficient 2) ParamOut[,6] <- log(ParamIn[,6]); ### GR6J X6 (coefficient for emptying exponential store) }