ui.R 19.98 KiB
# ui.R
#library(markdown)
navbarPage(title       = div("airGRteaching", 
                             a(href = "https://hydrogr.github.io/airGRteaching/",
                               title = "airGRteaching",
                               target = "_blank", rel = "noopener noreferrer",
                               img(src = "fig/logo_airGRteaching_CMJN_square_0125x0121.png", height = 350 / 9)),
                             a(href = "https://webgr.inrae.fr/en/home/",
                              title = "webgr.inrae.fr",
                              target = "_blank", rel = "noopener noreferrer",
                              img(src = "fig/logo_inrae_hydro_CMJN_square.svg", height = 350 / 9)),
                             a(href = "https://www.inrae.fr/en/",
                               title = "inrae.fr",
                               target = "_blank", rel = "noopener noreferrer",
                               img(src = "fig/logo_inrae_CMJN_square.svg", height = 350 / 9)),
                             style = "position:relative; top:-9px;"),
           windowTitle = "airGRteaching",
           theme       = switch(.GlobalEnv$.ShinyGR.args$theme,
                                Rstudio   = "",
                                Cyborg    = "css/bootstrap.min_Cyborg.css",
                                Cerulean  = "css/bootstrap.min_Cerulean.css",
                                Flatly    = "css/bootstrap.min_Flatly.css",
                                United    = "css/bootstrap.min_United.css",
                                Yeti      = "css/bootstrap.min_Yeti.css",
                                Inrae     = "css/bootstrap.min_Inrae.css",
                                Saclay    = "css/bootstrap.min_Saclay.css"
           tabPanel(title = "Modelling",
                    icon  = icon("area-chart"),
                    shinyjs::useShinyjs(), # set up shinyjs
                    sidebarLayout(position = "left", 
                                  sidebarPanel(width = 3,
                                               h4("Choose a dataset:"),
                                               fluidRow(
                                                 column(width = 12, selectInput("Dataset", label = NULL, choices = .ShinyGR.args$NamesObsBV))
                                               h4("Choose a model:"),
                                               fluidRow(
                                                 column(width = 6, selectInput("HydroModel", label = "Hydrological model",
                                                                               choices = c("GR4J", "GR5J", "GR6J", "GR2M"))),
                                                 column(width = 6, selectInput("SnowModel", label = "Snow model",
                                                                               choices = c("None", "CemaNeige")))
                                               h4("Parameters values:"),
                                               sliderInput("X1", label = "X1  (production store capacity)",
                                                           post = "  [mm]",
                                                           min = 0, 
                                                           max = 2500, 
                                                           step = 10, 
                                                           value = 1250),
                                               conditionalPanel(condition = "input.HydroModel == 'GR2M'",
                                                                sliderInput("X2GR2M", label = "X2  (groundwater exchange coeff.)",
                                                                            post = "  [-]",
                                                                            min = +0.05, 
                                                                            max = +4, 
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
step = 0.05, value = 2)), conditionalPanel(condition = "input.HydroModel != 'GR2M'", sliderInput("X2", label = "X2 (intercatchment exchange coeff.)", post = " [mm/d]", min = -5, max = +5, step = 0.05, value = 0), sliderInput("X3", label = "X3 (routing store capacity)", post = " [mm]", min = 0, max = 1000, step = 5, value = 500), sliderInput("X4", label = "X4 (unit hydrograph time constant)", post = " [d]", min = 0.5, max = 10, step = 0.1, value = 5.2)), 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.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.SnowModel == 'CemaNeige'", sliderInput("C1", label = "C1 (weighting coeff. for snow pack thermal state)", post = " [-]", min = 0, max = 1, step = 0.01, value = 0.5), sliderInput("C2", label = "C2 (degree-day melt coefficient)", post = " [mm/°C/d]", min = 0, max = 10, step = 0.5, value = 5)), h4("Automatic calibration:"), fluidRow( column(width = 6, selectInput("TypeCrit", label = "Objective function", choices = c("NSE [Q]", "NSE [sqrt(Q)]", "NSE [1/Q]", "KGE [Q]", "KGE [sqrt(Q)]", "KGE [1/Q]"))), column(width = 6, actionButton("CalButton", label = "Run", width = "100%", icon = icon("refresh"), style = ifelse(.GlobalEnv$.ShinyGR.args$theme != "Cerulean", "color:#ffffff; background-color:#A4C400; border-color:#A4C400; margin-top:25px; padding:6px;", "color:#565656; background-color:#ECF0F1; border-color:#DCDCDC; margin-top:25px; padding:6px;"))) ) ), mainPanel(width = 9, fluidRow( column(width = 2, selectInput("PlotType", label = "Choose a plot:", choices = c("Flow time series", "Model performance", "State variables", "Model diagram")) ),
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
column(width = 4, offset = 1, sliderInput("Period", label = "Select the time window:", min = as.POSIXct(.ShinyGR.args$SimPer[[1]][1L], tz = "UTC"), max = as.POSIXct(.ShinyGR.args$SimPer[[1]][2L], tz = "UTC"), value = as.POSIXct(.ShinyGR.args$SimPer[[1]], tz = "UTC"), timeFormat = "%F", timezone = "+0000", animate = FALSE) ), conditionalPanel(condition = "input.PlotType == 'Model diagram'", column(width = 4, offset = 0, sliderInput("Event", label = "Select the target date:", min = as.POSIXct(.ShinyGR.args$SimPer[[1]][1L], tz = "UTC"), max = as.POSIXct(.ShinyGR.args$SimPer[[1]][2L], tz = "UTC"), value = as.POSIXct(.ShinyGR.args$SimPer[[1]][1L], tz = "UTC"), timeFormat = "%F", timezone = "+0000", animate = animationOptions(interval = 500), step = 3600 * 24) ) ) ), fluidRow(conditionalPanel(condition = "input.PlotType == 'Model performance'", column(width = 09, plotOutput("stPlotMP", width = "100%", height = "900px"))), conditionalPanel(condition = "input.PlotType == 'Flow time series'", column(width = 09, dygraphs::dygraphOutput("dyPlotTSq", width = "100%", height = "400px"), dygraphs::dygraphOutput("dyPlotTSe", width = "100%", height = "300px"))), conditionalPanel(condition = "input.PlotType == 'State variables'", column(width = 09, dygraphs::dygraphOutput("dyPlotSVs", width = "100%", height = "325px"), dygraphs::dygraphOutput("dyPlotSVq", width = "100%", height = "355px"))), conditionalPanel(condition = "input.PlotType == 'Model diagram'", column(width = 05, dygraphs::dygraphOutput("dyPlotMDp", width = "100%", height = "190px"), dygraphs::dygraphOutput("dyPlotMDe", width = "100%", height = "215px"), dygraphs::dygraphOutput("dyPlotMDq", width = "100%", height = "235px")), column(width = 04, plotOutput("stPlotMD", width = "100%", height = "665px"))), column(width = 03, div(tableOutput("Criteria")), style = "font-size:90%", #conditionalPanel(condition = "input.PlotType == 'Flow time series' || input.PlotType == 'Model diagram'", radioButtons("ShowOldQsim", label = "Show previous simulation (Qold)", choices = c("No", "Yes"), inline = TRUE),#), downloadButton("DownloadTab" , label = "Download sim. as csv", style = "color:#565656; background-color:#ECF0F1; border-color:#DCDCDC; width:170px; height:25px; font-size:95%; padding-top:2px; margin-top:20px;"), #conditionalPanel(condition = "input.PlotType == 'Model performance' || input.PlotType == 'Flow time series' || input.PlotType == 'State variables'", downloadButton("DownloadPlot", label = "Download plot as png", style = "color:#565656; background-color:#ECF0F1; border-color:#DCDCDC; width:170px; height:25px; font-size:95%; padding-top:2px; margin-top:10px;") #) ) ) ) ) ), tabPanel(title = "Summary sheet", icon = icon("th"), sidebarLayout(position = "left", sidebarPanel(width = 3, h4("Choose a dataset:"), fluidRow(column(width = 12, selectInput("DatasetSheet", label = NULL, choices = .ShinyGR.args$NamesObsBV)), style = "height:720px;")), mainPanel(width = 9, fluidRow(uiOutput("Sheet"))) )
211212213214215216217218219220221222223224225226227228229230231232233234235236237
), navbarMenu(title = "Help", icon = icon("question-circle"), tabPanel(title = "Get started", icon = icon("cog", lib = "glyphicon"), fluidRow(column(width = 12, includeMarkdown("www/tab_fun.md"))) ), #! horrible code to avoid fake item when a tabpanel contains an external hyperlink #! (cf.https://gitlab.irstea.fr/HYCAR-Hydro/airgrteaching/-/issues/11) tabPanel(title = HTML("GUI help </a></li><li><a href='https://CRAN.R-project.org/package=airGRteaching' , target = '_blank', rel = 'noopener noreferrer'><i class='fab fa-r-project'></i>&nbsp;CRAN </a></li><li><a href='https://hydrogr.github.io/airGRteaching/' , target = '_blank', rel = 'noopener noreferrer'><i class='fas fa-at'></i>&nbsp;Website </a></li><li><a href='https://gitlab.irstea.fr/HYCAR-Hydro/airgrteaching/', target = '_blank', rel = 'noopener noreferrer'><i class='fab fa-gitlab'></i>&nbsp;GitLab"), icon = icon("question"), fluidRow(column(width = 12, a(href = "https://hydrogr.github.io/airGRteaching/fig/airGRteaching_ShinyUi_description.png", target = "_blank", rel = "noopener noreferrer", img(src = "https://hydrogr.github.io/airGRteaching/fig/airGRteaching_ShinyUi_description.png", height = "770px", alt = "If the image does not appear, click on this link.", title = "Click to open in a new window")))), ), tabPanel(title = "About", icon = icon("navicon"), fluidRow(column(width = 6, includeMarkdown("www/tab_about.md")), column(width = 5, includeMarkdown("www/tab_authors.md"))), ) ) )