Skip to content

Commit

Permalink
Move to main folder
Browse files Browse the repository at this point in the history
  • Loading branch information
stephpenn1 committed May 31, 2024
1 parent a0216e5 commit 6783699
Show file tree
Hide file tree
Showing 84 changed files with 71 additions and 17,466 deletions.
Binary file removed h2/outfile_area.jpeg
Binary file not shown.
Binary file removed h2/outfile_bar.gif
Binary file not shown.
12 changes: 0 additions & 12 deletions h2/www/images/GCIMS_logo_alt.svg

This file was deleted.

Binary file removed h2/www/images/GitHub-logo.png
Binary file not shown.
Binary file removed h2/www/images/Hector-sm.png
Binary file not shown.
Binary file removed h2/www/images/earth-header.png
Binary file not shown.
35 changes: 0 additions & 35 deletions h2/www/images/hectorcal-doi.svg

This file was deleted.

Binary file removed h2/www/images/line.png
Binary file not shown.
4 changes: 2 additions & 2 deletions h2/app.r → inst/shinyApp/app.r
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ui <- fluidPage(theme = shinythemes::shinytheme("readable"),
))
)
),
tabPanel(title = "Run Hector",
tabPanel(title = "Explore Hector",
fluidRow(
run_ui("run_1")
)
Expand Down Expand Up @@ -214,7 +214,7 @@ server <- function(input, output, session) {
r6 <- HectorInputs$new() # r6 class
r6_tracking <- HectorInputs$new() # separate r6 class for carbon tracking
r6_custom <- HectorInputs$new()
observeEvent(input$launch_scenario, updateTabsetPanel(session, "nav", selected = "Run Hector"), ignoreInit = TRUE)
observeEvent(input$launch_scenario, updateTabsetPanel(session, "nav", selected = "Explore Hector"), ignoreInit = TRUE)

run_server("run_1", r6 = r6)
summary_server("summary_1", r6 = r6)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ run_ui <- function(id) {
selected = "input/hector_ssp245.ini"),
sliderInput(ns("time"), label="Select dates:",
min = 1750, max = 2300, value = c(1900,2100), sep="", width = "90%", step=5),
h6("Include permafrost thaw:", id = "perm-lab"),
h5("Include permafrost thaw:", id = "perm-lab"),
switchInput(ns("permafrost"), "Permafrost", value = TRUE, size = 'small', onStatus = "danger"),
h5("Model Parameters"),
sliderInput(ns("alpha"), label="Aerosol forcing scaling factor", # AERO_SCALE()
Expand Down Expand Up @@ -48,34 +48,35 @@ run_ui <- function(id) {
placement = "top", trigger = "hover", options = NULL)
),
mainPanel(
fluidRow(
selectInput(ns("variable"), "Output Variable:",
list("Carbon Cycle" = list("Atmospheric CO2" = CONCENTRATIONS_CO2(),
"FFI Emissions" = FFI_EMISSIONS(),
"LUC Emissions" = LUC_EMISSIONS()),
"Concentrations" = list("N2O Concentration" = CONCENTRATIONS_N2O()),
"Emissions" = list("Black Carbon Emissions" = EMISSIONS_BC(),
"Organic Carbon Emissions" = EMISSIONS_OC()),
"Forcings" = list("RF - Total" = RF_TOTAL(),
"RF - Albedo" = RF_ALBEDO(),
"RF - CO2" = RF_CO2(),
"RF - N2O" = RF_N2O(),
"RF - Black Carbon" = RF_BC(),
"RF - Organic Carbon" = RF_OC(),
"RF - Total SO2" = RF_SO2(),
"RF - Volcanic Activity" = RF_VOL(),
"RF - CH4" = RF_CH4())),
selected = "Atmospheric CO2", multiple = FALSE)
),
fluidRow(
actionButton(ns("run"), label="Load Graphs", width = '150px', style = "background: #0B3F8F; color: white;"),
downloadButton(ns("downloadData"), label="Download Data", style = "background: #B8B8B8; color: black;"),
downloadButton(ns("downloadParam"), label="Download Parameters", style = "background: #B8B8B8; color: black;")
),
fluidRow(
br(),
plotlyOutput(ns("graph"))
)
fluidRow(
actionButton(ns("run"), label="Load Graphs", width = '150px', style = "background: #0B3F8F; color: white;"),
downloadButton(ns("downloadData"), label="Download Data", style = "background: #B8B8B8; color: black;"),
downloadButton(ns("downloadParam"), label="Download Parameters", style = "background: #B8B8B8; color: black;")
),
fluidRow(
br(),
selectInput(ns("variable"), "Output Variable:",
list("Carbon Cycle" = list("Atmospheric CO2" = CONCENTRATIONS_CO2(),
"FFI Emissions" = FFI_EMISSIONS(),
"LUC Emissions" = LUC_EMISSIONS()),
"Concentrations" = list("N2O Concentration" = CONCENTRATIONS_N2O()),
"Emissions" = list("Black Carbon Emissions" = EMISSIONS_BC(),
"Organic Carbon Emissions" = EMISSIONS_OC()),
"Forcings" = list("RF - Total" = RF_TOTAL(),
"RF - Albedo" = RF_ALBEDO(),
"RF - CO2" = RF_CO2(),
"RF - N2O" = RF_N2O(),
"RF - Black Carbon" = RF_BC(),
"RF - Organic Carbon" = RF_OC(),
"RF - Total SO2" = RF_SO2(),
"RF - Volcanic Activity" = RF_VOL(),
"RF - CH4" = RF_CH4())),
selected = "Atmospheric CO2", multiple = FALSE)
),
fluidRow(
br(),
plotlyOutput(ns("graph"))
)
)
)

Expand All @@ -87,6 +88,7 @@ run_server <- function(id, r6) {
observe({

runs <- list()
cores <- list()

for(i in 1:length(input$ssp_path)) {

Expand Down Expand Up @@ -117,11 +119,17 @@ run_server <- function(id, r6) {
reset(core())
run(core())

cores[[i]] <- core()
incProgress(1/1, detail = paste("Load complete."))
Sys.sleep(0.2)
})
#put cores in a list and fetchvars outsite
}

r6$core <- cores

runs[[i]] <- fetchvars(core(), r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
for(i in 1:length(input$ssp_path)) {
runs[[i]] <- fetchvars(r6$core[[i]], r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
mutate(Scenario = names(which(scenarios == input$ssp_path[i], arr.ind = FALSE)))
}

Expand All @@ -131,6 +139,23 @@ run_server <- function(id, r6) {
}) %>%
bindEvent(input$run, ignoreNULL = FALSE, ignoreInit = TRUE)

observe({
r6$selected_var <- reactive({input$variable})
runs <- list()

for(i in 1:length(input$ssp_path)) {
runs[[i]] <- fetchvars(r6$core[[i]], r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
mutate(Scenario = names(which(scenarios == input$ssp_path[i], arr.ind = FALSE)))
}

r6$output <- bind_rows(runs)

output$graph <- renderPlotly({
graph_plots(r6 = r6)
})
}) %>%
bindEvent(input$variable, ignoreInit = TRUE)

observe({

output$graph <- renderPlotly({
Expand Down Expand Up @@ -164,19 +189,23 @@ run_server <- function(id, r6) {
output$downloadParam <- downloadHandler(
filename = function()
{
paste0('HectorUI_Parameters_', Sys.Date(), '.txt')
paste0('HectorUI_Parameters_', format(Sys.time(), "%Y-%m-%d_%H%M%S"), '.txt')
},

content = function(file)
{

if(!is.null(r6$output))
{
header_text <- paste0("File created with Hector UI - https://github.com/JGCRI/hector-ui\n" ,
header_text <- paste0("File created with Hector UI - https://github.com/JGCRI/hector-ui accessed on ", format(Sys.time(), "%Y-%m-%d %X"), "\n",
"Permafrost: ", r6$permafrost, "\n",
"Model Parameters: " , input$input_paramToggle ,
"Alpha: ", input$alpha, " Beta: ", input$beta, " Diff: ", input$diff,
" ECS: ", input$S, " Q10: ", input$q10_rh, " Volc: ", input$volscl)
"Model Parameters: " , input$input_paramToggle , "\n",
"Alpha: ", input$alpha, "\n",
"Beta: ", input$beta, "\n",
"Diff: ", input$diff, "\n",
"ECS: ", input$S, "\n",
"Q10: ", input$q10_rh, "\n",
"Volc: ", input$volscl)

writeLines(header_text, file)
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ tracking_server <- function(id) {
labs(title=paste0(selectedPool()," Carbon Sources"),
subtitle="Year: {closest_state}")

anim_save("outfile_bar.gif", animate(anim, height = 500, width = 800,
end_pause=30))
anim_save("outfile_bar.gif", animate(anim, height = 350, width = 650,
end_pause=30, renterer = gifski_renderer()))
list(src = 'outfile_bar.gif',
contentType = 'image/gif'
# width = 800,
# height = 500,
# alt = "An animation tracking the sources of carbon in a chosen pool"
)}, deleteFile = TRUE)
)}, deleteFile = FALSE)

incProgress(0.25, detail = "Complete")
Sys.sleep(0.2)
Expand Down
File renamed without changes.
92 changes: 0 additions & 92 deletions inst/shinyApp/core.r

This file was deleted.

2 changes: 2 additions & 0 deletions h2/global.r → inst/shinyApp/global.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ library(shinycssloaders)
library(plotly)
library(DT)
library(shinyWidgets)
library(gifski)
library(gganimate)
library(tidyverse)
library(shinyBS)
Expand All @@ -33,6 +34,7 @@ HectorInputs <- R6Class(
run_name = NA,
permafrost = NULL,
inputs = NULL,
core = NULL,
selected_var = NULL#,
# initialize = function(ini_file = system.file("input/hector_ssp245.ini",
# package = "hector")) {
Expand Down
Loading

0 comments on commit 6783699

Please sign in to comment.