diff --git a/R/CreateRunOptions.R b/R/CreateRunOptions.R index 35d930ee681fd9fbe966c2f30d65082fe13e6636..7b943183b67a1518c2130452b9d6bb1f890000cb 100644 --- a/R/CreateRunOptions.R +++ b/R/CreateRunOptions.R @@ -1,69 +1,3 @@ -#************************************************************************************************* -#' Creation of the RunOptions object required to the RunModel functions. -#' -#' Users wanting to use FUN_MOD functions that are not included in -#' the package must create their own RunOptions object accordingly. -#' -#' ##### Initialisation options ##### -#' -#' The model initialisation options can either be set to a default configuration or be defined by the user. -#' -#' This is done via three vectors: \cr \emph{IndPeriod_WarmUp}, \emph{IniStates}, \emph{IniResLevels}. \cr -#' A default configuration is used for initialisation if these vectors are not defined. -#' -#' (1) Default initialisation options: -#' -#' \itemize{ -#' \item \emph{IndPeriod_WarmUp} default setting ensures a one-year warm-up using the time-steps preceding the \emph{IndPeriod_Run}. -#' The actual length of this warm-up might be shorter depending on data availability (no missing value being allowed on model input series). -#' -#' \item \emph{IniStates} and \emph{IniResLevels} are automatically set to initialise all the model states at 0, except for the production and routing stores which are initialised at 50\% of their capacity. This initialisation is made at the very beginning of the model call (i.e. at the beginning of \emph{IndPeriod_WarmUp} or at the beginning of IndPeriod_Run if the warm-up period is disabled). -#' } -#' -#' (2) Customisation of initialisation options: -#' -#' \itemize{ -#' \item \emph{IndPeriod_WarmUp} can be used to specify the indices of the warm-up period (within the time-series prepared in InputsModel). \cr -#' - remark 1: for most common cases, indices corresponding to one or several years preceding \emph{IndPeriod_Run} are used (e.g. \emph{IndPeriod_WarmUp <- 1000:1365} and \emph{IndPeriod_Run <- 1366:5000)}. \cr -#' However, it is also possible to perform a long-term initialisation if other indices than the warm-up ones are set in \emph{IndPeriod_WarmUp} (e.g. \emph{IndPeriod_WarmUp <- c( 1:5000 , 1:5000 , 1:5000 ,1000:1365 )}). \cr -#' - remark 2: it is also possible to completely disable the warm-up period when using \emph{IndPeriod_WarmUp <- 0}. -#' -#' \item \emph{IniStates} and \emph{IniResLevels} can be used to specify the initial model states. \cr -#' - remark 1: if \emph{IniStates} is used, all model states must be provided (e.g. 60 floats [mm] are required for GR4J, GR5J and GR6J; 60+2*NLayers floats [mm] are required for CemaNeigeGR4J, CemaNeigeGR5J and CemaNeigeGR6J; see fortran source code for details). \cr -#' - remark 2: in addition to \emph{IniStates}, \emph{IniResLevels} allows to set the filling rate of the production and routing stores for the GR models. For instance for GR4J, GR5J and GR6J: \emph{IniResLevels <- c(0.3,0.5)} should be used to obtain initial fillings of 30\% and 50\% for the production and routing stores, respectively. \emph{IniResLevels} is optional and can only be used if \emph{IniStates} is also defined (the state values corresponding to these two stores in \emph{IniStates} are not used in such case). \cr \cr -#' } -#************************************************************************************************* -#' @title Creation of the RunOptions object required to the RunModel functions -#' @author Laurent Coron (June 2014) -#' @seealso \code{\link{RunModel}}, \code{\link{CreateInputsModel}}, \code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}} -#' @example tests/example_RunModel.R -#' @encoding UTF-8 -#' @export -#_FunctionInputs__________________________________________________________________________________ -#' @param FUN_MOD [function] hydrological model function (e.g. RunModel_GR4J, RunModel_CemaNeigeGR4J) -#' @param InputsModel [object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details -#' @param IndPeriod_WarmUp (optional) [numeric] index of period to be used for the model warm-up [-] -#' @param IndPeriod_Run [numeric] index of period to be used for the model run [-] -#' @param IniStates (optional) [numeric] vector of initial model states [mm] -#' @param IniResLevels (optional) [numeric] vector of initial filling rates for production and routing stores (2 values between 0 and 1) [-] -#' @param Outputs_Cal (optional) [character] vector giving the outputs needed for the calibration \cr (e.g. c("Qsim")), the least outputs the fastest the calibration -#' @param Outputs_Sim (optional) [character] vector giving the requested outputs \cr (e.g. c("DatesR","Qsim","SnowPack")), default="all" -#' @param RunSnowModule (optional) [boolean] option indicating whether CemaNeige should be activated, default=TRUE -#' @param MeanAnSolidPrecip (optional) [numeric] vector giving the annual mean of average solid precipitation for each layer (computed from InputsModel if not defined) [mm/y] -#' @param quiet (optional) [boolean] boolean indicating if the function is run in quiet mode or not, default=FALSE -#_FunctionOutputs_________________________________________________________________________________ -#' @return [list] object of class \emph{RunOptions} containing the data required to evaluate the model outputs; it can include the following: -#' \tabular{ll}{ -#' \emph{IndPeriod_WarmUp } \tab [numeric] index of period to be used for the model warm-up [-] \cr -#' \emph{IndPeriod_Run } \tab [numeric] index of period to be used for the model run [-] \cr -#' \emph{IniStates } \tab [numeric] vector of initial model states [mm] \cr -#' \emph{IniResLevels } \tab [numeric] vector of initial filling rates for production and routing stores [-] \cr -#' \emph{Outputs_Cal } \tab [character] character vector giving only the outputs needed for the calibration \cr -#' \emph{Outputs_Sim } \tab [character] character vector giving the requested outputs \cr -#' \emph{RunSnowModule } \tab [boolean] option indicating whether CemaNeige should be activated \cr -#' \emph{MeanAnSolidPrecip} \tab [numeric] vector giving the annual mean of average solid precipitation for each layer [mm/y] \cr -#' } -#**************************************************************************************************' CreateRunOptions <- function(FUN_MOD,InputsModel,IndPeriod_WarmUp=NULL,IndPeriod_Run,IniStates=NULL,IniResLevels=NULL, Outputs_Cal=NULL,Outputs_Sim="all",RunSnowModule=TRUE,MeanAnSolidPrecip=NULL,quiet=FALSE){ @@ -166,8 +100,8 @@ CreateRunOptions <- function(FUN_MOD,InputsModel,IndPeriod_WarmUp=NULL,IndPeriod if("CemaNeige" %in% ObjectClass){ NLayers <- length(InputsModel$LayerPrecip); } else { NLayers <- 0; } NState <- NULL; if("GR" %in% ObjectClass | "CemaNeige" %in% ObjectClass){ - if("hourly" %in% ObjectClass){ NState <- 3*24*20; } - if("daily" %in% ObjectClass){ NState <- 3*20 + 2*NLayers; } + if("hourly" %in% ObjectClass){ NState <- 3*24*20 + 7; } + if("daily" %in% ObjectClass){ if (identical(FUN_MOD,RunModel_GR5J)){NState <- 2*20 + 2*NLayers + 7; } else {NState <- 3*20 + 2*NLayers + 7; }} if("monthly" %in% ObjectClass){ NState <- 2; } if("yearly" %in% ObjectClass){ NState <- 1; } } @@ -204,7 +138,7 @@ CreateRunOptions <- function(FUN_MOD,InputsModel,IndPeriod_WarmUp=NULL,IndPeriod if(identical(FUN_MOD,RunModel_GR6J) | identical(FUN_MOD,RunModel_CemaNeigeGR6J)){ Outputs_all <- c(Outputs_all,"PotEvap","Precip","Prod","AE","Perc","PR","Q9","Q1","Rout","Exch","AExch","QR","QR1","Exp","QD","Qsim"); } if(identical(FUN_MOD,RunModel_GR2M)){ - Outputs_all <- c(Outputs_all,"PotEvap","Precip","Qsim"); } + Outputs_all <- c(Outputs_all,"PotEvap","Precip","AE","Perc","P3","Exch","Prod","Rout","Qsim"); } if(identical(FUN_MOD,RunModel_GR1A)){ Outputs_all <- c(Outputs_all,"PotEvap","Precip","Qsim"); } if("CemaNeige" %in% ObjectClass){