Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#**************************************************************************************************
#' 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); }
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)
}
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)
}
if(Bool==FALSE){ ParamOut <- ParamOut[1,]; }
return(ParamOut);
}