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

Modification des transformations de paramètres #4001

Showing with 30 additions and 126 deletions
+30 -126
#**************************************************************************************************
#' 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)
}
#**************************************************************************************************
#' 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;
......
#**************************************************************************************************
#' 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,]; }
......
#**************************************************************************************************
#' 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,]; }
......
#**************************************************************************************************
#' 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)
......
#**************************************************************************************************
#' 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,]; }
......
#**************************************************************************************************
#' 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)
}
......
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