Skip to content

Commit

Permalink
ini22
Browse files Browse the repository at this point in the history
  • Loading branch information
RobelTakele committed Jul 3, 2024
1 parent 27044fe commit 99386d4
Show file tree
Hide file tree
Showing 15 changed files with 1,295 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docs
inst/doc
/doc/
/Meta/
.quarto
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Imports:
ncdf4
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
URL: https://github.com/RobelTakele/AquaBEHERgui,
https://robeltakele.github.io/AquaBEHERgui/
BugReports: https://github.com/RobelTakele/AquaBEHERgui/issues
Expand Down
759 changes: 759 additions & 0 deletions R/app_server.R

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ spWSCcolPal <- list(rev(c("#440154","#462777","#3D4988","#30678D","#25818E","#1
rev(c("#780085","#7F2FD1","#686DF9","#4C9ED9","#3FC29F","#53DA60","#85EB50","#C1EC58","#E4D05C","#F9965B")),
rev(c("#780085","#7F2FD1","#686DF9","#4C9ED9","#3FC29F","#53DA60","#85EB50","#C1EC58","#E4D05C","#F9965B")))

spFCSTnames <- c("onset", "cessation")

nc.att <- c("Institution=Sant’Anna School of Advanced Studies (SSSA)",
"Group=Center of Plant Sciences",
"Project=FOCUSafrica, Food security Case study-03 (CS3)",
"WP5=Develop end-user tailored climate services prototypes",
"Contact-1=Robel Takele [[email protected]]",
"Contact-2=Matteo Dell'Acqua [[email protected]]",
"Source=Generated by the AquaBEHER package (version 0.1.0)",
"Source.Reference=URL: https://github.com/RobelTakele/AquaBEHER",
"BugReports=https://github.com/RobelTakele/AquaBEHER/issues")

##################################################################################################################
##################################################################################################################

Expand Down Expand Up @@ -102,7 +114,14 @@ app_ui <- function(request) {

navbarMenu("Seasonal Calendar",
tabPanel("From Location Data", mod_locWSC_ui("locWSC_1")),
tabPanel("From Gridded Data", mod_spWSC_ui("spWSC_1")))
tabPanel("From Gridded Data", mod_spWSC_ui("spWSC_1"))),

navbarMenu("Preparing Data",
tabPanel("CPT to NetCDF", mod_cpt2nc_ui("cpt2nc_1"))),

navbarMenu("Seasonal Forecast",
tabPanel("From Location Data", mod_locFCST_ui("locFCST_1")),
tabPanel("From Gridded Data", mod_spFCST_ui("spFCST_1")))

)
)
Expand Down
141 changes: 141 additions & 0 deletions R/mod_cpt2nc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#' cpt2nc UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_cpt2nc_ui <- function(id){
ns <- NS(id)
tagList(


tabPanel(title = " ",

titlePanel("Convert CPT file to NetCDF"),

# shinyjs::useShinyjs(),

sidebarLayout(
sidebarPanel(
title = " ",

tags$head(
# this changes the size of the popovers
tags$style(".popover{width:500px;height:200px;}")
),


fileInput(inputId = "cpt2nc_xlsxInput",
label = h4( span("Select CPT Tercile Probability File to Import: ",),
style = "color: #4d3a7d;"

),

accept = ".xlsx",
width = '100%',
buttonLabel = "Browse...",
placeholder = "No file selected",
capture = NULL),

numericInput(inputId = "LONGlengthInput",
label = "Input the number of longitudes",
value = 152,
min = 1,
max = 10000,
width = '100%'),

numericInput(inputId = "LATlengthInput",
label = "Input the number of latitudes",
value = 234,
min = 1,
max = 10000,
width = '100%'),

shinyWidgets::airDatepickerInput(
inputId = "cpt2nc_date",
label = "Forecast Start Date (yyyy-MM-dd):",
separator = " - ",
dateFormat = "yyyy-MM-dd",
autoClose = TRUE,
view = c("days", "months", "years"),
value = Sys.Date() - 7),


p(strong("Select NetCDF output directory: ")),
shinyFiles::shinyDirButton(id = "dirCDF",
label = " Please select a folder to save NetCDF data ...",
icon = icon("save", lib = "glyphicon"),,
class = "shinyDirectories btn-default",
title = "Upload ",
type = "button "),
br(),
verbatimTextOutput(outputId = "dirCDF", placeholder = TRUE),
br(),

shinyWidgets::textInputIcon(inputId = "cdfFilePrefix",
label = "NetCDF data output file name prefix:",
placeholder = "NetCDF",
width = '100%'),

div(style="position:relative; left:calc(70%);",

shinyWidgets::actionBttn(inputId = "cpt2nc_runButton",
label = " Convert ",
color = "primary",
size = 'md',
style = "jelly",
# style = "color: #fff; background-color: #27ae60; border-color: #fff;",
icon = icon("play"),
block = FALSE)
)

),

mainPanel(
tabsetPanel(
tabPanel(
title = "Data Viewer",

shinyjs::useShinyjs(),

fluidPage(

br(),

leaflet::leafletOutput(outputId = 'rainTERmap', width = "100%", height = 500),

br(),


)
)
)
)

)
)




)
}

#' cpt2nc Server Functions
#'
#' @noRd
mod_cpt2nc_server <- function(id){
moduleServer( id, function(input, output, session){
ns <- session$ns

})
}

## To be copied in the UI
# mod_cpt2nc_ui("cpt2nc_1")

## To be copied in the server
# mod_cpt2nc_server("cpt2nc_1")
159 changes: 159 additions & 0 deletions R/mod_locFCST.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#' locFCST UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_locFCST_ui <- function(id){
ns <- NS(id)
tagList(

tabPanel(title = " ",

titlePanel("Seasonal Forecast"),

# shinyjs::useShinyjs(),

sidebarLayout(
sidebarPanel(
title = " ",

tags$head(
# this changes the size of the popovers
tags$style(".popover{width:500px;height:200px;}")
),

fileInput(inputId = "rainTerc_xlsxInput",
label = h4( span("Select Tercile Probability File to Import: ",),
style = "color: #4d3a7d;"

),

accept = ".xlsx",
width = '100%',
buttonLabel = "Browse...",
placeholder = "No file selected",
capture = NULL),

fileInput(inputId = "sesRain_xlsxInput",
label = h4( span("Select Seasonal Rain File to Import: ",),
style = "color: #4d3a7d;"

),

accept = ".xlsx",
width = '100%',
buttonLabel = "Browse...",
placeholder = "No file selected",
capture = NULL),

fileInput(inputId = "fcstVarDF_xlsxInput",
label = h4( span("Select WSC Variable File to Import: ",),
style = "color: #4d3a7d;"

),

accept = ".xlsx",
width = '100%',
buttonLabel = "Browse...",
placeholder = "No file selected",
capture = NULL),

selectInput("FCSTvar", label = h4("Choose WSC Variable:"),
choices = list("Onset" = "onset",
"Cessation" = "cessation"),
selected = 1),

div(style="position:relative; left:calc(60%);",

shinyWidgets::actionBttn(inputId = "FCST_runButton",
label = " Run Forecast",
color = "primary",
size = 'md',
style = "jelly",
# style = "color: #fff; background-color: #27ae60; border-color: #fff;",
icon = icon("play"),
block = FALSE)
)

),

mainPanel(
tabsetPanel(
tabPanel(
title = "Data",

fluidPage(

DT::dataTableOutput("seasFCSTtable"),

br(),

div(style="position:relative; left:calc(5%);",
shinyWidgets::downloadBttn(outputId = 'downloadFCST',
label = "Download Forecast Data",
color = "success",
size = 'md',
style = "jelly",
icon = icon("download"),
block = FALSE)
)
)
),

tabPanel(
title = "Plot",

br( ),

shinyjs::useShinyjs(),

br( ),

div(style="position:relative; left:calc(5%);",

shinyWidgets::actionBttn(inputId = "seasFCST_plotButton",
label = " Plot Forecast",
color = "success",
size = 'lg',
style = "jelly",
# style = "color: #fff; background-color: #27ae60; border-color: #fff;",
icon = icon("chart-line"),
block = FALSE)
),

br( ),

plotly::plotlyOutput("seasFCSTplot"),

br( ),

)

)

)
)
)

)
}

#' locFCST Server Functions
#'
#' @noRd
mod_locFCST_server <- function(id){
moduleServer( id, function(input, output, session){
ns <- session$ns

})
}

## To be copied in the UI
# mod_locFCST_ui("locFCST_1")

## To be copied in the server
# mod_locFCST_server("locFCST_1")
Loading

0 comments on commit 99386d4

Please sign in to comment.