diff --git a/DESCRIPTION b/DESCRIPTION index 7719b701bc30a4592838facb159ea4ecb4a2709d..b4d3fec29fbb667fbeb814c07dc133e0e513b7c3 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.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")), diff --git a/NEWS.rmd b/NEWS.rmd index 4475cdeac0b1d46210e5b6ad28293b6211ccc1fd..db95eed77f6bbd40611fc6ec16d357b677308b58 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -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 diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R index d2bf53744da275247b1a9ac481aeb288b3d90704..a14dab5d04b3e317106b156de5b12fea1e7da4c3 100644 --- a/R/plot.OutputsModel.R +++ b/R/plot.OutputsModel.R @@ -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")) {