diff --git a/DESCRIPTION b/DESCRIPTION index b73e218a7a7b989e4182196d10cc39076dbd88ea..42c4d1f81a3fb077d7dbb91e773213d019fd885a 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 0c8767facfcc766143290287e6da3bb23066ffdb..6c7dc0826aaac151a7d2de967dd2489cfe520b0a 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 a14c1d7c91428588df5966e4b3fcf2215b7a2001..deca5dc582c0d3b5491c10bb10021581941a9f3a 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) {