diff --git a/DESCRIPTION b/DESCRIPTION index 1ca85a00c44ee3b5b2acae90f51b9ad71cd23c74..e85ba193e90fb1f6a5df74f0bc8b5273a7cbf261 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.0.9.9 +Version: 1.0.9.10 Date: 2017-07-11 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl")), diff --git a/R/CreateRunOptions.R b/R/CreateRunOptions.R index 3ea7904d179ed50204449a15b551965f6379697f..16a5aa5b92434f334067a82d17f55d65b0d9410d 100644 --- a/R/CreateRunOptions.R +++ b/R/CreateRunOptions.R @@ -1,6 +1,9 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, IniStates = NULL, IniResLevels = NULL, - Outputs_Cal = NULL, Outputs_Sim = "all", RunSnowModule = TRUE, MeanAnSolidPrecip = NULL, verbose = TRUE) { - + Outputs_Cal = NULL, Outputs_Sim = "all", RunSnowModule, MeanAnSolidPrecip = NULL, verbose = TRUE) { + + if (!missing(RunSnowModule)) { + warning("argument RunSnowModule is deprecated; please adapt FUN_MOD instead.", call. = FALSE) + } ObjectClass <- NULL @@ -234,14 +237,6 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP Outputs_Cal <- Outputs_Cal[!duplicated(Outputs_Cal)]; - ##check_RunSnowModule - if("CemaNeige" %in% ObjectClass){ - if(!is.vector( RunSnowModule)){ stop("RunSnowModule must be a single boolean \n"); return(NULL); } - if(!is.logical(RunSnowModule)){ stop("RunSnowModule must be either TRUE or FALSE \n"); return(NULL); } - if(length(RunSnowModule)!=1 ){ stop("RunSnowModule must be either TRUE or FALSE \n"); return(NULL); } - } - - ##check_MeanAnSolidPrecip if("CemaNeige" %in% ObjectClass & is.null(MeanAnSolidPrecip)){ NLayers <- length(InputsModel$LayerPrecip); @@ -265,7 +260,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP ##check_PliqAndMelt - if(RunSnowModule & "GR" %in% ObjectClass & "CemaNeige" %in% ObjectClass){ + if("GR" %in% ObjectClass & "CemaNeige" %in% ObjectClass){ if("PliqAndMelt" %in% Outputs_Cal == FALSE & "all" %in% Outputs_Cal == FALSE){ WTxt <- NULL; WTxt <- paste(WTxt,"\t PliqAndMelt was not defined in Outputs_Cal but is needed to feed the hydrological model with the snow modele outputs \n",sep=""); @@ -285,7 +280,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP RunOptions <- list(IndPeriod_WarmUp=IndPeriod_WarmUp,IndPeriod_Run=IndPeriod_Run,IniStates=IniStates,IniResLevels=IniResLevels, Outputs_Cal=Outputs_Cal,Outputs_Sim=Outputs_Sim); if("CemaNeige" %in% ObjectClass){ - RunOptions <- c(RunOptions,list(RunSnowModule=RunSnowModule,MeanAnSolidPrecip=MeanAnSolidPrecip)); } + RunOptions <- c(RunOptions,list(MeanAnSolidPrecip=MeanAnSolidPrecip)); } class(RunOptions) <- c("RunOptions",ObjectClass); return(RunOptions); diff --git a/R/RunModel_CemaNeigeGR4J.R b/R/RunModel_CemaNeigeGR4J.R index 2001faed1954eeaaf2df3198388fd0cbc1816854..ddf926737d0ad6c9e627fc939b5347bd1f02ecee 100644 --- a/R/RunModel_CemaNeigeGR4J.R +++ b/R/RunModel_CemaNeigeGR4J.R @@ -47,7 +47,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ ##SNOW_MODULE________________________________________________________________________________## - if(RunOptions$RunSnowModule==TRUE){ + if(inherits(RunOptions,"CemaNeige")==TRUE){ if("all" %in% RunOptions$Outputs_Sim){ IndOutputsCemaNeige <- as.integer(1:length(FortranOutputsCemaNeige)); } else { IndOutputsCemaNeige <- which(FortranOutputsCemaNeige %in% RunOptions$Outputs_Sim); } CemaNeigeLayers <- list(); CemaNeigeStateEnd <- NULL; NameCemaNeigeLayers <- "CemaNeigeLayers"; @@ -87,7 +87,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ } ###ENDFOR_iLayer names(CemaNeigeLayers) <- paste("Layer",formatC(1:NLayers,width=2,flag="0"),sep=""); } ###ENDIF_RunSnowModule - if(RunOptions$RunSnowModule==FALSE){ + if(inherits(RunOptions,"CemaNeige")==FALSE){ CemaNeigeLayers <- list(); CemaNeigeStateEnd <- NULL; NameCemaNeigeLayers <- NULL; CatchMeltAndPliq <- InputsModel$Precip[IndPeriod1]; } @@ -130,7 +130,7 @@ RunModel_CemaNeigeGR4J <- function(InputsModel,RunOptions,Param){ verbose = FALSE) } - if(RunOptions$RunSnowModule & "Precip" %in% RunOptions$Outputs_Sim){ RESULTS$Outputs[,which(FortranOutputsMod[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]; } + if(inherits(RunOptions,"CemaNeige")==TRUE & "Precip" %in% RunOptions$Outputs_Sim){ RESULTS$Outputs[,which(FortranOutputsMod[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]; } ##Output_data_preparation ##OutputsModel_only diff --git a/R/RunModel_CemaNeigeGR5J.R b/R/RunModel_CemaNeigeGR5J.R index 3f2cbdd73b930021771d12c362b8cae2774a5c76..d585d05ee3d7b6ef3aa6122d9305e003b90d0f62 100644 --- a/R/RunModel_CemaNeigeGR5J.R +++ b/R/RunModel_CemaNeigeGR5J.R @@ -47,7 +47,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ ##SNOW_MODULE________________________________________________________________________________## - if(RunOptions$RunSnowModule==TRUE){ + if(inherits(RunOptions,"CemaNeige")==TRUE){ if("all" %in% RunOptions$Outputs_Sim){ IndOutputsCemaNeige <- as.integer(1:length(FortranOutputsCemaNeige)); } else { IndOutputsCemaNeige <- which(FortranOutputsCemaNeige %in% RunOptions$Outputs_Sim); } CemaNeigeLayers <- list(); CemaNeigeStateEnd <- NULL; NameCemaNeigeLayers <- "CemaNeigeLayers"; @@ -86,7 +86,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ } ###ENDFOR_iLayer names(CemaNeigeLayers) <- paste("Layer",formatC(1:NLayers,width=2,flag="0"),sep=""); } ###ENDIF_RunSnowModule - if(RunOptions$RunSnowModule==FALSE){ + if(inherits(RunOptions,"CemaNeige")==FALSE){ CemaNeigeLayers <- list(); CemaNeigeStateEnd <- NULL; NameCemaNeigeLayers <- NULL; CatchMeltAndPliq <- InputsModel$Precip[IndPeriod1]; } @@ -129,7 +129,7 @@ RunModel_CemaNeigeGR5J <- function(InputsModel,RunOptions,Param){ verbose = FALSE) } - if(RunOptions$RunSnowModule & "Precip" %in% RunOptions$Outputs_Sim){ RESULTS$Outputs[,which(FortranOutputsMod[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]; } + if(inherits(RunOptions,"CemaNeige")==TRUE & "Precip" %in% RunOptions$Outputs_Sim){ RESULTS$Outputs[,which(FortranOutputsMod[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]; } ##Output_data_preparation ##OutputsModel_only diff --git a/R/RunModel_CemaNeigeGR6J.R b/R/RunModel_CemaNeigeGR6J.R index e7c7dbbe59ca1a4daad57ab4ce5d72ac23fa50c3..ee5b6ca997aaec0d5a7ab8488632a16ba0e241a3 100644 --- a/R/RunModel_CemaNeigeGR6J.R +++ b/R/RunModel_CemaNeigeGR6J.R @@ -52,7 +52,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ ##SNOW_MODULE________________________________________________________________________________## - if(RunOptions$RunSnowModule==TRUE){ + if(inherits(RunOptions,"CemaNeige")==TRUE){ if("all" %in% RunOptions$Outputs_Sim){ IndOutputsCemaNeige <- as.integer(1:length(FortranOutputsCemaNeige)); } else { IndOutputsCemaNeige <- which(FortranOutputsCemaNeige %in% RunOptions$Outputs_Sim); } CemaNeigeLayers <- list(); CemaNeigeStateEnd <- NULL; NameCemaNeigeLayers <- "CemaNeigeLayers"; @@ -91,7 +91,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ } ###ENDFOR_iLayer names(CemaNeigeLayers) <- paste("Layer",formatC(1:NLayers,width=2,flag="0"),sep=""); } ###ENDIF_RunSnowModule - if(RunOptions$RunSnowModule==FALSE){ + if(inherits(RunOptions,"CemaNeige")==FALSE){ CemaNeigeLayers <- list(); CemaNeigeStateEnd <- NULL; NameCemaNeigeLayers <- NULL; CatchMeltAndPliq <- InputsModel$Precip[IndPeriod1]; } @@ -135,7 +135,7 @@ RunModel_CemaNeigeGR6J <- function(InputsModel,RunOptions,Param){ verbose = FALSE) } - if(RunOptions$RunSnowModule & "Precip" %in% RunOptions$Outputs_Sim){ RESULTS$Outputs[,which(FortranOutputsMod[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]; } + if(inherits(RunOptions,"CemaNeige")==TRUE & "Precip" %in% RunOptions$Outputs_Sim){ RESULTS$Outputs[,which(FortranOutputsMod[IndOutputsMod]=="Precip")] <- InputsModel$Precip[IndPeriod1]; } ##Output_data_preparation ##OutputsModel_only diff --git a/man/CreateRunOptions.Rd b/man/CreateRunOptions.Rd index f113e377c85cf09a1b0817943208946363063cc1..4da6dace378f6afcc8b001347b9f4b65c2f15a88 100644 --- a/man/CreateRunOptions.Rd +++ b/man/CreateRunOptions.Rd @@ -5,7 +5,7 @@ \usage{ CreateRunOptions(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, IniStates = NULL, IniResLevels = NULL, Outputs_Cal = NULL, - Outputs_Sim = "all", RunSnowModule = TRUE, MeanAnSolidPrecip = NULL, + Outputs_Sim = "all", RunSnowModule, MeanAnSolidPrecip = NULL, verbose = TRUE) } \arguments{ @@ -26,8 +26,9 @@ CreateRunOptions(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, \item{Outputs_Sim}{(optional) [character] vector giving the requested outputs \cr (e.g. c("DatesR", "Qsim", "SnowPack")), default = "all"} -\item{RunSnowModule}{(optional) [boolean] option indicating whether CemaNeige should be activated, \code{default = TRUE}} +\item{RunSnowModule}{(deprecated) [boolean] option indicating whether CemaNeige should be activated. Please adapt \code{FUN_MOD} instead} + \item{MeanAnSolidPrecip}{(optional) [numeric] vector giving the annual mean of average solid precipitation for each layer (computed from InputsModel if not defined) [mm/y]} \item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, \code{default = TRUE}} @@ -41,7 +42,6 @@ CreateRunOptions(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, \emph{IniResLevels } \tab [numeric] vector of initial filling rates for production and routing stores [-] and level fothe the exponential store for GR6J [mm]\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 } }