From a85a881a95e464ae14175198ffe19e27253c725f Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.priv>
Date: Thu, 2 May 2019 18:20:21 +0200
Subject: [PATCH] 1.2.15.2 NEW: which argument of plot.OutputsModel fun now
 allows "synth", "ts" an "perf" values

---
 DESCRIPTION           |  2 +-
 NEWS.rmd              |  4 +++-
 R/plot.OutputsModel.R | 25 ++++++++++++++++++-------
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 2b8e3710..65e33ba9 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.15.1
+Version: 1.2.15.2
 Date: 2019-05-02
 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 07b54258..28947444 100644
--- a/NEWS.rmd
+++ b/NEWS.rmd
@@ -14,7 +14,7 @@ output:
 
 
 
-### 1.2.15.1 Release Notes (2019-05-02)
+### 1.2.15.2 Release Notes (2019-05-02)
 
 
 #### New features
@@ -26,6 +26,8 @@ output:
 
 - <code>plot.OutputsModel()</code> can no drawn PET or error time serie if <code>which = "all"</code> or <code>"PotEvap"</code> or <code>"Error"</code>.
 
+- <code>plot.OutputsModel()</code> now allowed new values for the which argument : <code>"all"</code> corresponds to all graphs, <code>"synth"</code> corresponds to the main graphs (correspondinf to <code>"all"</code> in the previous versions of the pcakage) (<code>c("Precip", "Temp", "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ")</code>), "ts" corresponds to the time serie graphs (<code>c("Precip", "PotEvap", "Temp", "SnowPack", "Flows")</code>) and <code>"perf"</code> corresponds to the perfomance graphs (<code>c("Error", "Regime", "CumFreq", "CorQQ")</code>).
+
 
 #### Minor user-visible changes
 
diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R
index 479edb7e..7a7ca69d 100644
--- a/R/plot.OutputsModel.R
+++ b/R/plot.OutputsModel.R
@@ -1,4 +1,4 @@
-plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = NULL, which = "all", log_scale = FALSE,
+plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea = NULL, which = "synth", log_scale = FALSE,
                               cex.axis = 1, cex.lab = 0.9, cex.leg = 0.9, lwd = 1, verbose = TRUE, ...) {
   
   OutputsModel <- x
@@ -66,19 +66,30 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
   if (!is.character(which)) {
     stop("'which' must be a vector of character")
   }
-  if (any(!which %in% c("all", "PotEvap", "Precip", 'Temp', "SnowPack", "Flows", "Error", "Regime", "CumFreq", "CorQQ"))) {
-    stop("incorrect element found in argument 'which':\nit can only contain 'all', 'Precip', 'PotEvap', 'Temp', 'SnowPack', 'Error', 'Flows', 'Regime', 'CumFreq' or 'CorQQ'")
+  if (any(!which %in% c("all", "synth", "ts", "perf", "PotEvap", "Precip", '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 (all(which %in% c("Temp", "SnowPack")) & !inherits(OutputsModel, "CemaNeige")) {
-    stop("Incorrect element found in argument 'which':\nwithout CemaNeige it can only contain 'all', 'Precip', 'PotEvap', 'Flows', 'Error', 'Regime', 'CumFreq' or 'CorQQ'")
+    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 (length(unique(which %in% c("Temp", "SnowPack"))) == 2 & !inherits(OutputsModel, "CemaNeige")) {
-    warning("Incorrect element found in argument 'which':\nit can only contain 'all', 'Precip', 'PotEvap', 'Flows', 'Error', 'Regime', 'CumFreq' or 'CorQQ'\nwithout CemaNeige 'Temp' and 'SnowPack' are not available")
+    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 ("synth" %in% which) {
+    which <- c("Precip", "Temp", "SnowPack", "Flows", "Regime", "CumFreq", "CorQQ")
+  }
+  if ("ts" %in% which) {
+    which <- c("Precip", "PotEvap", "Temp", "SnowPack", "Flows")
+  }
+  if ("perf" %in% which) {
+    which <- c("Error", "Regime", "CumFreq", "CorQQ")
+  }
+  
   
   if (is.null(Qobs)) {
     if (length(which) == 1 & any(which %in% "Error")) {
@@ -204,7 +215,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
     Sum1 <- sum(c(BOOLPLOT_Precip, BOOLPLOT_SnowPack, BOOLPLOT_Flows))
     Sum2 <- sum(c(BOOLPLOT_Regime, BOOLPLOT_CumFreq, BOOLPLOT_CorQQ))
     if (BOOLPLOT_Precip) {
-      matlayout <- rbind(matlayout, c(iPlot+1, iPlot+1, iPlot+1))
+      matlayout <- rbind(matlayout, c(iPlot + 1, iPlot + 1, iPlot + 1))
       iPlot <- iPlot + 1
     }
     if (BOOLPLOT_PotEvap) {
@@ -212,7 +223,7 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
       iPlot <- iPlot + 1
     } 
     if (BOOLPLOT_Temp) {
-      matlayout <- rbind(matlayout, c(iPlot+1, iPlot+1, iPlot+1), c(iPlot+1, iPlot+1, iPlot+1))
+      matlayout <- rbind(matlayout, c(iPlot + 1, iPlot + 1, iPlot + 1), c(iPlot + 1, iPlot + 1, iPlot + 1))
       iPlot <- iPlot + 1
     }      
     if (BOOLPLOT_SnowPack) {
-- 
GitLab