From 332390b86927fe70b1211a8e5bd723fc8ada539c Mon Sep 17 00:00:00 2001
From: unknown <olivier.delaigue@ANPI1430.antony.irstea.priv>
Date: Wed, 6 Sep 2017 09:16:47 +0200
Subject: [PATCH] v0.1.5.9 in ShinyGR, TypeModel inputIds renamed into
 HydroModel

---
 DESCRIPTION           |  2 +-
 inst/ShinyGR/server.R | 36 ++++++++++++++++++------------------
 inst/ShinyGR/ui.R     | 15 ++++++++-------
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 4ae325e..dc33c36 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
 Package: airGRteaching
 Type: Package
 Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (Including a Shiny Interface)
-Version: 0.1.5.8
+Version: 0.1.5.9
 Date: 2017-09-06
 Authors@R: c(person("Olivier", "Delaigue", role = c("aut", "cre"), email = "airGR@irstea.fr"), person("Laurent", "Coron", role = c("aut")), person("Pierre", "Brigode", role = c("aut")), person("Guillaume", "Thirel", role = c("ctb")))
 Depends: airGR (>= 1.0.8.0)
diff --git a/inst/ShinyGR/server.R b/inst/ShinyGR/server.R
index c23c38d..f5458d2 100644
--- a/inst/ShinyGR/server.R
+++ b/inst/ShinyGR/server.R
@@ -7,15 +7,15 @@ shinyServer(function(input, output, session) {
   
   getPrep <- reactive({
     
-    TMGR  <- .TypeModelGR(input$TypeModel)
+    TMGR  <- .TypeModelGR(input$HydroModel)
     PARAM <- c(input$X1, input$X2, input$X3, input$X4, input$X5, input$X6)[seq_len(TMGR$NbParam)]
     
-    if (input$CemaNeige == "CemaNeige") {
+    if (input$SnowModel == "CemaNeige") {
       PARAM <- c(PARAM, input$C1, input$C2)
     }
     
-    OBS <- ObsGR(ObsBV = get(input$Dataset), TypeModel = input$TypeModel,
-                 CemaNeige = input$CemaNeige == "CemaNeige",
+    OBS <- ObsGR(ObsBV = get(input$Dataset), HydroModel = input$HydroModel,
+                 CemaNeige = input$SnowModel == "CemaNeige",
                  Precip = .ShinyGR.args$Precip, PotEvap = .ShinyGR.args$PotEvap,
                  Qobs = get(input$Dataset), TempMean = .ShinyGR.args$TempMean, 
                  ZInputs = .ShinyGR.args$ZInputs, HypsoData = .ShinyGR.args$HypsoData,
@@ -52,7 +52,7 @@ shinyServer(function(input, output, session) {
     if (getPrep()$TMGR$NbParam >= 6) {
       updateSliderInput(session, inputId = "X6", value = PARAM[6L])
     }
-    if (input$CemaNeige == "CemaNeige") {
+    if (input$SnowModel == "CemaNeige") {
       updateSliderInput(session, inputId = "C1", value = PARAM[length(PARAM)-1])
       updateSliderInput(session, inputId = "C2", value = PARAM[length(PARAM)])
     }
@@ -62,7 +62,7 @@ shinyServer(function(input, output, session) {
   
   
   ## Manual calibration
-  observeEvent({input$Dataset ; input$TypeModel ; input$CemaNeige ;
+  observeEvent({input$Dataset ; input$HydroModel ; input$SnowModel ;
     input$X1 ; input$X2 ; input$X3 ; input$X4 ; input$X5 ; input$X6 ;
     input$TypeCrit ; input$Period}, {
       
@@ -81,7 +81,7 @@ shinyServer(function(input, output, session) {
   getRES <- reactive({
     
     PARAM <- c(input$X1, input$X2, input$X3, input$X4, input$X5, input$X6)[seq_len(getPrep()$TMGR$NbParam)]
-    if (input$CemaNeige == "CemaNeige") {
+    if (input$SnowModel == "CemaNeige") {
       PARAM <- c(PARAM, input$C1, input$C2)
     }
     
@@ -136,18 +136,18 @@ shinyServer(function(input, output, session) {
   ## Models available considering the plot type
   observe({
   if (getPlotType() == 4) {
-      updateSelectInput(session, inputId = "TypeModel", choice = c("GR4J", "GR5J"), selected = input$TypeModel)
-      updateSelectInput(session, inputId = "CemaNeige", choice = c("None"))
+      updateSelectInput(session, inputId = "HydroModel", choice = c("GR4J", "GR5J"), selected = input$HydroModel)
+      updateSelectInput(session, inputId = "SnowModel", choice = c("None"))
   } else {
-      updateSelectInput(session, inputId = "TypeModel", choice = c("GR4J", "GR5J", "GR6J"), selected = input$TypeModel)
-      updateSelectInput(session, inputId = "CemaNeige", choice = c("None", "CemaNeige")   , selected = input$CemaNeige)
+      updateSelectInput(session, inputId = "HydroModel", choice = c("GR4J", "GR5J", "GR6J"), selected = input$HydroModel)
+      updateSelectInput(session, inputId = "SnowModel", choice = c("None", "CemaNeige")   , selected = input$SnowModel)
     }
   })
   
   
   ## Plots available considering the model type
   observe({
-    if (input$TypeModel == "GR6J") {
+    if (input$HydroModel == "GR6J") {
       updateSelectInput(session, inputId = "PlotType",
                         choice = c("Flow time series", "Model performance", "State variables"),
                         selected = input$PlotType)
@@ -172,7 +172,7 @@ shinyServer(function(input, output, session) {
     }
     if (exists("dateWindow")) {
       updateSliderInput(session, inputId = "Period",
-                        value = dateWindow + .TypeModelGR(input$TypeModel)$TimeLag)
+                        value = dateWindow + .TypeModelGR(input$HydroModel)$TimeLag)
     }
   })
   
@@ -207,7 +207,7 @@ shinyServer(function(input, output, session) {
   ## Target date slider
   observe({
     updateSliderInput(session, inputId = "Event",
-                      min = input$Period[1L] + .TypeModelGR(input$TypeModel)$TimeLag,
+                      min = input$Period[1L] + .TypeModelGR(input$HydroModel)$TimeLag,
                       max = input$Period[2L])
   })  
   
@@ -275,7 +275,7 @@ shinyServer(function(input, output, session) {
     IndPlot <- which(OutputsModel$DatesR >= input$Period[1L] & OutputsModel$DatesR <= input$Period[2L])
     OutputsModel2 <- sapply(OutputsModel[seq_len(which(names(OutputsModel) == "Qsim"))], function(x) x[IndPlot])
     OutputsModel2 <- c(OutputsModel2, Qobs = list(getRES()$SIM$Qobs[IndPlot]))
-    if (input$TypeModel == "GR6J") {
+    if (input$HydroModel == "GR6J") {
       Qd <- OutputsModel2$QR + OutputsModel2$QD + OutputsModel2$QR1
     } else {
       Qd <- OutputsModel2$QR + OutputsModel2$QD
@@ -321,10 +321,10 @@ shinyServer(function(input, output, session) {
   output$dyPlotMDe <- renderDygraph({
     op <- getPlotPar()$par
     data <- data.frame(DatesR = getRES()$SIM$OutputsModel$DatesR,
-                       evapo. = getRES()$SIM$OutputsModel$PotEvap)
+                       PET    = getRES()$SIM$OutputsModel$PotEvap)
     data.xts <- xts(data[, -1L, drop = FALSE], order.by = data$DatesR)
     
-    dg5 <- dygraph(data.xts, group = "mod_diag", ylab = "evapo. [mm/d]", main = " ")
+    dg5 <- dygraph(data.xts, group = "mod_diag", ylab = "PET [mm/d]", main = " ")
     dg5 <- dyOptions(dg5, colors = "#A4C400", drawPoints = TRUE,
                      strokeWidth = 0, pointSize = 2, drawXAxis = FALSE,
                      axisLineColor = op$fg, axisLabelColor = op$fg,
@@ -369,7 +369,7 @@ shinyServer(function(input, output, session) {
     par(getPlotPar()$par)
     airGRteaching:::DiagramGR(OutputsModel = OutputsModel2, Param = getRES()$PARAM,
                               SimPer = input$Period, EventDate = input$Event,
-                              TypeModel = input$TypeModel)
+                              HydroModel = input$HydroModel)
   })
   
   
diff --git a/inst/ShinyGR/ui.R b/inst/ShinyGR/ui.R
index 6670fd6..07fd5cb 100644
--- a/inst/ShinyGR/ui.R
+++ b/inst/ShinyGR/ui.R
@@ -36,15 +36,15 @@ navbarPage(title       = div("airGRteaching",
                                                
                                                h4("Choose a model:"),
                                                fluidRow(
-                                                 column(width = 6, selectInput("TypeModel", label = "Hydrological model",
+                                                 column(width = 6, selectInput("HydroModel", label = "Hydrological model",
                                                                                choices = c("GR4J", "GR5J", "GR6J"))),
-                                                 column(width = 6, selectInput("CemaNeige", label = "Snow module",
+                                                 column(width = 6, selectInput("SnowModel", label = "Snow model",
                                                                                choices = c("None", "CemaNeige")))
                                                ),
                                                
                                                
                                                h4("Parameters values:"),
-                                               conditionalPanel(condition = "input.TypeModel == 'GR4J' || input.TypeModel =='GR5J' || input.TypeModel =='GR6J'",
+                                               conditionalPanel(condition = "input.HydroModel == 'GR4J' || input.HydroModel =='GR5J' || input.HydroModel =='GR6J'",
                                                                 sliderInput("X1", label = "X1  (production store capacity)",
                                                                             post = "  [mm]",
                                                                             min = 0, 
@@ -69,21 +69,21 @@ navbarPage(title       = div("airGRteaching",
                                                                             max = 10, 
                                                                             step = 0.1, 
                                                                             value = 5.2)),
-                                               conditionalPanel(condition = "input.TypeModel == 'GR5J' || input.TypeModel =='GR6J'",
+                                               conditionalPanel(condition = "input.HydroModel == 'GR5J' || input.HydroModel =='GR6J'",
                                                                 sliderInput("X5", label = "X5  (intercatchment exchange threshold)",
                                                                             post = "  [-]",
                                                                             min = -4, 
                                                                             max = 4, 
                                                                             step = 0.05, 
                                                                             value = 0)),
-                                               conditionalPanel(condition = "input.TypeModel == 'GR6J'",
+                                               conditionalPanel(condition = "input.HydroModel == 'GR6J'",
                                                                 sliderInput("X6", label = "X6  (coeff. for emptying exponential store)", 
                                                                             post = "  [mm]",
                                                                             min = 0, 
                                                                             max = 20, 
                                                                             step = 0.5, 
                                                                             value = 10)),
-                                               conditionalPanel(condition = "input.CemaNeige == 'CemaNeige'",
+                                               conditionalPanel(condition = "input.SnowModel == 'CemaNeige'",
                                                                 sliderInput("C1", label = "C1  (weighting coeff. for snow pack thermal state)", 
                                                                             post = "  [-]",
                                                                             min = 0, 
@@ -127,7 +127,7 @@ navbarPage(title       = div("airGRteaching",
                                                                  timezone = "+0000",
                                                                  animate = FALSE)
                                               ),
-                                              conditionalPanel(condition = "input.PlotType == 'Model diagram' & (input.TypeModel == 'GR4J' || input.TypeModel == 'GR5J' || input.TypeModel == 'GR6J')",
+                                              conditionalPanel(condition = "input.PlotType == 'Model diagram' & (input.HydroModel == 'GR4J' || input.HydroModel == 'GR5J' || input.HydroModel == 'GR6J')",
                                                                column(width = 4, offset = 0,
                                                                       sliderInput("Event", label = "Select the target date:", 
                                                                                   min = as.POSIXct(.ShinyGR.args$SimPer[1L], tz = "UTC"),
@@ -146,6 +146,7 @@ navbarPage(title       = div("airGRteaching",
                                             fluidRow(conditionalPanel(condition = "input.PlotType == 'Model performance'",
                                                                       column(width = 10,
                                                                              plotOutput("stPlotMP", width = "100%", height = "665px"))),
+
                                                      conditionalPanel(condition = "input.PlotType == 'Flow time series'",
                                                                       column(width = 10,
                                                                              dygraphOutput("dyPlotTS", width = "100%", height = "400px"))),
-- 
GitLab