From c91208c6aaa89f799e59ae22228db0750fc0da4c Mon Sep 17 00:00:00 2001
From: Olivier Delaigue <olivier.delaigue@irstea.fr>
Date: Thu, 14 Apr 2016 16:06:13 +0200
Subject: [PATCH] =?UTF-8?q?Modification=20des=20transformations=20de=20par?=
 =?UTF-8?q?am=C3=A8tres=20#4001?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 R/TransfoParam_CemaNeige.R | 34 ++++++++++------------------------
 R/TransfoParam_GR1A.R      | 12 ------------
 R/TransfoParam_GR2M.R      | 20 ++++----------------
 R/TransfoParam_GR4H.R      | 24 ++++++------------------
 R/TransfoParam_GR4J.R      | 18 ++----------------
 R/TransfoParam_GR5J.R      | 24 ++++--------------------
 R/TransfoParam_GR6J.R      | 24 ++++--------------------
 7 files changed, 30 insertions(+), 126 deletions(-)

diff --git a/R/TransfoParam_CemaNeige.R b/R/TransfoParam_CemaNeige.R
index 73ba2134..41dd3703 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 963d6bd4..b29fc1ec 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 e3fba4cd..6a963f62 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 caa4ac6c..651d4da7 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 2613179d..6f7f5a13 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 126d25ba..0492c147 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 ed558b69..65ccf34f 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)
   }	
 
-- 
GitLab