Commit 8f0ecd4f authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.2.16.29 CLEAN: warning msg management improved in plot.OutputsModel fun

Showing with 13 additions and 15 deletions
+13 -15
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.2.16.28 Version: 1.2.16.29
Date: 2019-06-07 Date: 2019-06-07
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")), person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
...@@ -14,7 +14,7 @@ output: ...@@ -14,7 +14,7 @@ output:
### 1.2.16.28 Release Notes (2019-06-07) ### 1.2.16.29 Release Notes (2019-06-07)
#### New features #### New features
......
...@@ -77,7 +77,10 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = ...@@ -77,7 +77,10 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
whichTS <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows" ) whichTS <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows" )
whichPerf <- c( "Error", "Regime", "CumFreq", "CorQQ") whichPerf <- c( "Error", "Regime", "CumFreq", "CorQQ")
whichCN <- c( "Temp", "SnowPack" ) whichCN <- c( "Temp", "SnowPack" )
warnMsgWhich <- "'which' must be a vector of character" warnMsgWhich <- "'which' must be a vector of character"
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 = ", "))
if (is.null(which)) { if (is.null(which)) {
stop(warnMsgWhich) stop(warnMsgWhich)
} }
...@@ -88,21 +91,15 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = ...@@ -88,21 +91,15 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
stop(warnMsgWhich) stop(warnMsgWhich)
} }
if (any(!which %in% c(whichDashboard, whichAll))) { if (any(!which %in% c(whichDashboard, whichAll))) {
stop("incorrect element found in argument 'which': ", paste0(shQuote(which[!which %in% c(whichDashboard, whichAll)])), stop(sprintf("incorrect element found in argument 'which': %s\nit can only contain %s",
"\nit can only contain ", paste0(shQuote(which[!which %in% c(whichDashboard, whichAll)])),
paste0(shQuote(c(whichDashboard, whichAll)), collapse = ", ")) paste0(shQuote(c(whichDashboard, whichAll)), collapse = ", ")))
} }
if (all(which %in% whichCN) & !inherits(OutputsModel, "CemaNeige")) { if (all(which %in% whichCN) & !inherits(OutputsModel, "CemaNeige")) {
stop("incorrect element found in argument 'which':", stop(warnMsgWhichCN)
"\n\twithout CemaNeige, ", paste0(shQuote(whichCN), collapse = " and "), " are not available",
"\n\tit can only contain ",
paste0(shQuote(c(whichDashboard, whichAll[!whichAll %in% whichCN])), collapse = ", "))
} }
if (length(unique(which %in% whichCN)) == 2 & !inherits(OutputsModel, "CemaNeige")) { if (length(unique(which %in% whichCN)) == 2 & !inherits(OutputsModel, "CemaNeige")) {
warning("incorrect element found in argument 'which':", warning(warnMsgWhichCN)
"\n\twithout CemaNeige, ", paste0(shQuote(whichCN), collapse = " and "), " are not available",
"\n\tit can only contain ",
paste0(shQuote(c(whichDashboard, whichAll[!whichAll %in% whichCN])), collapse = ", "))
} }
if ("perf" %in% which) { if ("perf" %in% which) {
which <- c(which, whichPerf) which <- c(which, whichPerf)
...@@ -118,7 +115,8 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = ...@@ -118,7 +115,8 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
} }
if (is.null(Qobs)) { if (is.null(Qobs)) {
if (length(which) == 1 & any(which %in% whichNeedQobs)) { if (length(which) == 1 & any(which %in% whichNeedQobs)) {
stop(sprintf("the %s plot(s) cannot be drawn if there is no 'Qobs'", shQuote(which))) stop(sprintf("the %s plot(s) cannot be drawn if there is no 'Qobs'",
shQuote(which)))
} }
if (length(which) != 1 & any(which %in% whichNeedQobs)) { if (length(which) != 1 & any(which %in% whichNeedQobs)) {
BOOL_CorQQ <- FALSE BOOL_CorQQ <- FALSE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment