From 8c788a1329369753525a375a68a86a4953c3ef1e Mon Sep 17 00:00:00 2001 From: Delaigue Olivier <olivier.delaigue@irstea.priv> Date: Wed, 17 Oct 2018 10:20:30 +0200 Subject: [PATCH] v1.0.15.13 NEW: add warnings argument in CreateRunOptions --- DESCRIPTION | 4 ++-- NEWS.rmd | 11 ++++++----- R/CreateRunOptions.R | 23 +++++++++++++---------- man/CreateRunOptions.Rd | 12 ++++++++---- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b4594d95..b68c9b8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.0.15.12 -Date: 2018-10-16 +Version: 1.0.15.13 +Date: 2018-10-17 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Charles", "Perrin", role = c("aut", "ths"), comment = c(ORCID = "0000-0001-8552-1881")), diff --git a/NEWS.rmd b/NEWS.rmd index a1e16be4..30004949 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -13,10 +13,11 @@ output: -### 1.0.15.12 Release Notes (2018-10-16) - +### 1.0.15.13 Release Notes (2018-10-17) +#### New features +- <code>CreateRunOptions()</code> now presents a <code>warnings</code> argument to replace the verbose action (the <code>verbose</code> argument is keep to print messages). ____________________________________________________________________________________ @@ -217,7 +218,7 @@ ________________________________________________________________________________ #### New features -- <code>ErrorCrit*()</code> functions gain a warnings argument to replace the verbose action and the verbose argument now prints the criterion value(s). +- <code>ErrorCrit*()</code> functions gain a <code>warnings</code> argument to replace the verbose action and the <code>verbose</code> argument now prints the criterion value(s). #### Bug fixes @@ -241,7 +242,7 @@ ________________________________________________________________________________ #### New features - <code>SeriesAggreg()</code> gains a TimeLag argument that corresponds to a numeric value indicating a time lag (in seconds) for the time series aggregation (useful to aggregate hourly time series to the daily time step for instance). - In addition, the function now accepts input dates in both POSIXt formats (POSIXct and POSIXlt). The output is in POSIXct format. + In addition, the function now accepts input dates in both <code>POSIXt</code> formats (<code>POSIXct</code> and <code>POSIXlt</code>). The output is in <code>POSIXct</code> format. - <code>plot_OutputsModel()</code> gains a <code>log_scale</code> argument in order to plot the flow with a log scale. @@ -271,7 +272,7 @@ ________________________________________________________________________________ #### Minor user-visible changes -- <code>CreateInputsModel()</code> and <code>DataAltiExtrapolation_Valery()</code> functions now allow both POSIXt formats (POSIXct and POSIXlt). +- <code>CreateInputsModel()</code> and <code>DataAltiExtrapolation_Valery()</code> functions now allow both <code>POSIXt</code> formats (<code>POSIXct</code> and <code>POSIXlt</code>). ____________________________________________________________________________________ diff --git a/R/CreateRunOptions.R b/R/CreateRunOptions.R index 66c5539f..415faf36 100644 --- a/R/CreateRunOptions.R +++ b/R/CreateRunOptions.R @@ -1,5 +1,8 @@ -CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, IniStates = NULL, IniResLevels = NULL, - Outputs_Cal = NULL, Outputs_Sim = "all", RunSnowModule, MeanAnSolidPrecip = NULL, verbose = TRUE) { +CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, + IniStates = NULL, IniResLevels = NULL, + Outputs_Cal = NULL, Outputs_Sim = "all", + RunSnowModule, MeanAnSolidPrecip = NULL, + warnings = TRUE, verbose = TRUE) { if (!missing(RunSnowModule)) { warning("argument RunSnowModule is deprecated; please adapt FUN_MOD instead.", call. = FALSE) @@ -143,14 +146,14 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP stop("IndPeriod_Run should be of type integer \n") return(NULL) } - if (identical(IndPeriod_WarmUp, as.integer(0))) { - WTxt <- paste0(WTxt, "\t No warm up period is used! \n") + if (identical(IndPeriod_WarmUp, as.integer(0)) & verbose) { + message(paste0(WTxt, "\t No warm up period is used \n")) } if ((IndPeriod_Run[1] - 1) != tail(IndPeriod_WarmUp, 1) & !identical(IndPeriod_WarmUp, as.integer(0))) { WTxt <- paste0(WTxt, "\t Model warm up period is not directly before the model run period \n") } } - if (!is.null(WTxt) & verbose) { + if (!is.null(WTxt) & warnings) { warning(WTxt) } @@ -188,10 +191,10 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP } } ## check IniStates - if (is.null(IniStates) & is.null(IniResLevels) & verbose) { + if (is.null(IniStates) & is.null(IniResLevels) & warnings) { warning("\t Model states initialisation not defined -> default configuration used \n") } - if (!is.null(IniStates) & !is.null(IniResLevels) & verbose) { + if (!is.null(IniStates) & !is.null(IniResLevels) & warnings) { warning("\t IniStates and IniResLevels are both defined -> Store levels are taken from IniResLevels \n") } if ("CemaNeige" %in% ObjectClass) { @@ -390,7 +393,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP } MeanAnSolidPrecip <- rep(mean(SolidPrecip) * Factor, NLayers) ### default value: same Gseuil for all layers - if (verbose) { + if (warnings) { warning("\t MeanAnSolidPrecip not defined -> it was automatically set to c(", paste(round(MeanAnSolidPrecip), collapse = ","), ") \n") } @@ -417,7 +420,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP WTxt <- NULL WTxt <- paste0(WTxt, "\t PliqAndMelt was not defined in Outputs_Cal but is needed to feed the hydrological model with the snow modele outputs \n") WTxt <- paste0(WTxt, "\t -> it was automatically added \n") - if (!is.null(WTxt) & verbose) { + if (!is.null(WTxt) & warnings) { warning(WTxt) } Outputs_Cal <- c(Outputs_Cal, "PliqAndMelt") @@ -426,7 +429,7 @@ CreateRunOptions <- function(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndP WTxt <- NULL WTxt <- paste0(WTxt, "\t PliqAndMelt was not defined in Outputs_Sim but is needed to feed the hydrological model with the snow modele outputs \n") WTxt <- paste0(WTxt, "\t -> it was automatically added \n") - if (!is.null(WTxt) & verbose) { + if (!is.null(WTxt) & warnings) { warning(WTxt) } Outputs_Sim <- c(Outputs_Sim, "PliqAndMelt") diff --git a/man/CreateRunOptions.Rd b/man/CreateRunOptions.Rd index 4c5e5e59..c5ec5f19 100644 --- a/man/CreateRunOptions.Rd +++ b/man/CreateRunOptions.Rd @@ -9,10 +9,12 @@ \usage{ -CreateRunOptions(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, - IniStates = NULL, IniResLevels = NULL, Outputs_Cal = NULL, - Outputs_Sim = "all", RunSnowModule, MeanAnSolidPrecip = NULL, - verbose = TRUE) +CreateRunOptions(FUN_MOD, InputsModel, + IndPeriod_WarmUp = NULL, IndPeriod_Run, + IniStates = NULL, IniResLevels = NULL, + Outputs_Cal = NULL, Outputs_Sim = "all", + RunSnowModule, MeanAnSolidPrecip = NULL, + warnings = TRUE, verbose = TRUE) } @@ -39,6 +41,8 @@ CreateRunOptions(FUN_MOD, InputsModel, IndPeriod_WarmUp = NULL, IndPeriod_Run, \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{warnings}{(optional) [boolean] boolean indicating if the warning messages are shown, default = \code{TRUE}} + \item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}} } -- GitLab