From 05dd6d8aa7e6b0ee1b7b48da0fef4a290ca15ca5 Mon Sep 17 00:00:00 2001 From: Delaigue Olivier <olivier.delaigue@irstea.priv> Date: Fri, 7 Jun 2019 16:25:00 +0200 Subject: [PATCH] v1.2.16.31 BUG: which argument of plot.OutputsModel now take into account outputs of RunModel_CemaNeige --- DESCRIPTION | 2 +- NEWS.rmd | 2 +- R/plot.OutputsModel.R | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b73e218a..42c4d1f8 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.2.16.30 +Version: 1.2.16.31 Date: 2019-06-07 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), diff --git a/NEWS.rmd b/NEWS.rmd index 0c8767fa..6c7dc082 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -14,7 +14,7 @@ output: -### 1.2.16.30 Release Notes (2019-06-07) +### 1.2.16.31 Release Notes (2019-06-07) #### New features diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R index a14c1d7c..deca5dc5 100644 --- a/R/plot.OutputsModel.R +++ b/R/plot.OutputsModel.R @@ -78,6 +78,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = whichPerf <- c( "Error", "Regime", "CumFreq", "CorQQ") whichCN <- c( "Temp", "SnowPack" ) warnMsgWhich <- "'which' must be a vector of character" + warnMsgNoQobs <- "the %s plot(s) cannot be drawn if there is no 'Qobs'" warnMsgWhichCN <- sprintf("incorrect element found in argument 'which':\n\twithout CemaNeige, %s are not available \n\tit can only contain %s", paste0(shQuote(whichCN), collapse = " and "), paste0(shQuote(c(whichDashboard, whichAll[!whichAll %in% whichCN])), collapse = ", ")) @@ -101,6 +102,14 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = if (length(unique(which %in% whichCN)) == 2 & !inherits(OutputsModel, "CemaNeige")) { warning(warnMsgWhichCN) } + if (all(!which %in% c("all", "synth", "ts", whichCN)) & !inherits(OutputsModel, "GR")) { + stop(sprintf("incorrect element found in argument 'which': \nwith CemaNeige alone, only %s are available", + paste0(shQuote(c("all", "synth", "ts", "Temp", "SnowPack")), collapse = ", "))) + } + if (any(!which %in% c("all", "synth", "ts", whichCN)) & !inherits(OutputsModel, "GR")) { + warning(sprintf("incorrect element found in argument 'which': \nwith CemaNeige alone, only %s are available", + paste0(shQuote(c("all", "synth", "ts", "Temp", "SnowPack")), collapse = ", "))) + } if ("perf" %in% which) { which <- c(which, whichPerf) } @@ -113,18 +122,17 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = if ("all" %in% which) { which <- c(which, whichAll) } - if (is.null(Qobs)) { - if (length(which) == 1 & any(which %in% whichNeedQobs)) { - stop(sprintf("the %s plot(s) cannot be drawn if there is no 'Qobs'", - shQuote(which))) + if (is.null(Qobs) & inherits(OutputsModel, "GR")) { + if (length(which) == 1 & (any(which %in% whichNeedQobs))) { + stop(sprintf(warnMsgNoQobs, shQuote(which))) } if (length(which) != 1 & any(which %in% whichNeedQobs)) { BOOL_CorQQ <- FALSE BOOL_Error <- FALSE - warning(sprintf("the %s plot(s) cannot be drawn if there is no 'Qobs'", - paste0(shQuote(whichNeedQobs), collapse = " and "))) + warning(sprintf(warnMsgNoQobs, paste0(shQuote(whichNeedQobs), collapse = " and "))) } } + ## check dates if (!BOOL_Dates) { -- GitLab