Commit 9a16e155 authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.2.16.9 CLEAN: new msgmanagement for the "which" argument in the plot.OutputsModel fun

Showing with 43 additions and 20 deletions
+43 -20
Package: airGR
Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.2.16.8
Version: 1.2.16.9
Date: 2019-05-24
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl"), comment = c(ORCID = "0000-0002-1503-6204")),
......
......@@ -14,7 +14,7 @@ output:
### 1.2.16.8 Release Notes (2019-05-23)
### 1.2.16.9 Release Notes (2019-05-23)
#### New features
......
......@@ -70,37 +70,60 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
## check 'which'
whichDashboard <- c("all", "synth", "ts", "perf")
whichAll <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows", "Error", "Regime", "CumFreq", "CorQQ")
whichSynth <- c("Precip" , "Temp", "SnowPack", "Flows" , "Regime", "CumFreq", "CorQQ")
whichTS <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows" )
whichPerf <- c( "Error", "Regime", "CumFreq", "CorQQ")
whichCN <- c( "Temp", "SnowPack" )
warnMsgWhich <- "'which' must be a vector of character"
if (is.null(which)) {
stop("'which' must be a vector of character")
stop(warnMsgWhich)
}
if (!is.vector(which)) {
stop("'which' must be a vector of character")
stop(warnMsgWhich)
}
if (!is.character(which)) {
stop("'which' must be a vector of character")
stop(warnMsgWhich)
}
if (any(!which %in% c("all", "synth", "ts", "perf", "Precip", "PotEvap", "Temp", "SnowPack", "Flows", "Error", "Regime", "CumFreq", "CorQQ"))) {
stop("incorrect element found in argument 'which':\nit can only contain 'all', 'synth', 'ts', 'perf', 'Precip', 'PotEvap', 'Temp', 'SnowPack', 'Error', 'Flows', 'Regime', 'CumFreq' or 'CorQQ'")
if (any(!which %in% c(whichDashboard, whichAll))) {
stop("incorrect element found in argument 'which': ", paste0(shQuote(which[!which %in% c(whichDashboard, whichAll)])),
"\nit can only contain ",
paste0(shQuote(c(whichDashboard, whichAll)), collapse = ", "))
}
if (all(which %in% c("Temp", "SnowPack")) & !inherits(OutputsModel, "CemaNeige")) {
stop("Incorrect element found in argument 'which':\nwithout CemaNeige it can only contain 'all', 'synth', 'ts', 'perf', 'Precip', 'PotEvap', 'Flows', 'Error', 'Regime', 'CumFreq' or 'CorQQ'")
if (all(which %in% whichCN) & !inherits(OutputsModel, "CemaNeige")) {
stop("incorrect element found in argument 'which':",
"\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% c("Temp", "SnowPack"))) == 2 & !inherits(OutputsModel, "CemaNeige")) {
warning("Incorrect element found in argument 'which':\nit can only contain 'all', 'synth', 'ts', 'perf', 'Precip', 'PotEvap', 'Flows', 'Error', 'Regime', 'CumFreq' or 'CorQQ'\nwithout CemaNeige 'Temp' and 'SnowPack' are not available")
}
if ("all" %in% which) {
which <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows", "Error", "Regime", "CumFreq", "CorQQ")
if (length(unique(which %in% whichCN)) == 2 & !inherits(OutputsModel, "CemaNeige")) {
warning("incorrect element found in argument 'which':",
"\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 ("synth" %in% which) {
which <- c("Precip", "Temp", "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ")
if (any(which %in% whichAll) & any(which %in% whichDashboard)) {
warning(sprintf("only %s will be used", whichDashboard[whichDashboard %in% which]))
}
if ("ts" %in% which) {
which <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows")
if (sum(which %in% whichDashboard) > 1) {
warning(sprintf("only %s will be used", whichDashboard[whichDashboard %in% which]))
}
if ("perf" %in% which) {
which <- c("Error", "Regime", "CumFreq", "CorQQ")
which <- whichPerf
}
if ("ts" %in% which) {
which <- whichTS
}
if ("synth" %in% which) {
which <- whichSynth
}
if ("all" %in% which) {
which <- whichAll
}
if (is.null(Qobs)) {
if (length(which) == 1 & any(which %in% "Error")) {
......
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