From f5873d84c431a93a1f531f45b7e4181688da3069 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.priv>
Date: Fri, 3 May 2019 09:06:54 +0200
Subject: [PATCH] v1.2.15.6 CLEAN: minor simplification of the
 plot.OutputsModel code

---
 DESCRIPTION           |  2 +-
 NEWS.rmd              |  2 +-
 R/plot.OutputsModel.R | 13 +++++--------
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index af836ffd..3f2866c1 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.5
+Version: 1.2.15.6
 Date: 2019-05-03
 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 9e4c3422..ea556ae1 100644
--- a/NEWS.rmd
+++ b/NEWS.rmd
@@ -14,7 +14,7 @@ output:
 
 
 
-### 1.2.15.5 Release Notes (2019-05-03)
+### 1.2.15.6 Release Notes (2019-05-03)
 
 
 #### New features
diff --git a/R/plot.OutputsModel.R b/R/plot.OutputsModel.R
index 9b4a2d3c..ecb73e3a 100644
--- a/R/plot.OutputsModel.R
+++ b/R/plot.OutputsModel.R
@@ -286,14 +286,11 @@ plot.OutputsModel <- function(x, Qobs = NULL, IndPeriod_Plot = NULL, BasinArea =
     }
     
     if (!is.null(BasinArea)) {
-      Factor_MMH_M3S <- 60 * 60
-      Factor_MMD_M3S <- 60 * 60 * 24
-      Factor_MMM_M3S <- 60 * 60 * 24 * 365.25 / 12
-      Factor_MMY_M3S <- 60 * 60 * 24 * 365.25
-      if (NameTS == "hour" ) Factor_UNIT_M3S <- Factor_MMH_M3S
-      if (NameTS == "day"  ) Factor_UNIT_M3S <- Factor_MMD_M3S
-      if (NameTS == "month") Factor_UNIT_M3S <- Factor_MMM_M3S
-      if (NameTS == "year" ) Factor_UNIT_M3S <- Factor_MMY_M3S
+      Factor_UNIT_M3S <- switch(NameTS,
+                                hour  = 60 * 60,
+                                day   = 60 * 60 * 24,
+                                month = 60 * 60 * 24 * 365.25 / 12,
+                                year  = 60 * 60 * 24 * 365.25)
       Factor_UNIT_M3S <- BasinArea / (Factor_UNIT_M3S / 1000)
     }
   }
-- 
GitLab