diff --git a/h2/components/modules/mod_custom.r b/h2/components/modules/mod_custom.r index 1929905..3f4c60a 100644 --- a/h2/components/modules/mod_custom.r +++ b/h2/components/modules/mod_custom.r @@ -16,7 +16,7 @@ custom_ui <- function(id) { tags$table( tags$tr(width = "100%", tags$td(width = "145", "Baseline Scenario:"), - tags$td(width = "155", selectInput(ns("input_custom_SSP"), label = NULL, + tags$td(width = "155", selectInput(ns("input_custom_SSP"), label = NULL, choices = list("SSP 1-1.9"="input/hector_ssp119.ini", "SSP 1-2.6"="input/hector_ssp126.ini", "SSP 2-4.5"="input/hector_ssp245.ini", @@ -24,7 +24,7 @@ custom_ui <- function(id) { "SSP 4-3.4"="input/hector_ssp434.ini", "SSP 4-6.0"="input/hector_ssp460.ini", "SSP 5-3.4OS"="input/hector_ssp534-over.ini", - "SSP 5-8.5"="input/hector_ssp585.ini"), + "SSP 5-8.5"="input/hector_ssp585.ini"), width=150, selected = "SSP 2-4.5")) ), tags$tr(width = "100%", @@ -36,52 +36,52 @@ custom_ui <- function(id) { conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp119.ini'", a(h6("Download SSP 1-1.9 Emissions File Template"), - href="inputs/ssp119_emiss-constraints_rf.csv"), + href="inputs/ssp119_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp126.ini'", - a(h6("Download SSP 1-2.6 Emissions File Template"), - href="inputs/ssp126_emiss-constraints_rf.csv"), + a(h6("Download SSP 1-2.6 Emissions File Template"), + href="inputs/ssp126_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp245.ini'", - a(h6("Download SSP 2-4.5 Emissions File Template"), - href="inputs/ssp245_emiss-constraints_rf.csv"), + a(h6("Download SSP 2-4.5 Emissions File Template"), + href="inputs/ssp245_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp370.ini'", - a(h6("Download SSP 3-7.0 Emissions File Template"), - href="inputs/ssp370_emiss-constraints_rf.csv"), + a(h6("Download SSP 3-7.0 Emissions File Template"), + href="inputs/ssp370_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp434.ini'", - a(h6("Download SSP 4-3.4 Emissions File Template"), - href="inputs/ssp434_emiss-constraints_rf.csv"), + a(h6("Download SSP 4-3.4 Emissions File Template"), + href="inputs/ssp434_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp460.ini'", - a(h6("Download SSP 4-6.0 Emissions File Template"), - href="inputs/ssp460_emiss-constraints_rf.csv"), + a(h6("Download SSP 4-6.0 Emissions File Template"), + href="inputs/ssp460_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp534-over.ini'", - a(h6("Download SSP 5-3.4OS Emissions File Template"), - href="inputs/ssp534-over_emiss-constraints_rf.csv"), + a(h6("Download SSP 5-3.4OS Emissions File Template"), + href="inputs/ssp534-over_emissions.csv"), ns=NS(id) ), conditionalPanel( condition = "input.input_custom_SSP == 'input/hector_ssp585.ini'", - a(h6("Download SSP 5-8.5 Emissions File Template"), - href="inputs/ssp585_emiss-constraints_rf.csv"), + a(h6("Download SSP 5-8.5 Emissions File Template"), + href="inputs/ssp585_emissions.csv"), ns=NS(id) ), - fileInput(ns("input_custom_emissions_file"), "Upload Custom Emissions File:", width=275, + fileInput(ns("input_custom_emissions_file"), "Upload Custom Emissions File:", width=275, buttonLabel = "Choose File", accept = c("text/csv", ".csv", "text/comma-separated-values,text/plain")), selectInput(ns("variable"), "Choose Output Variable:", list("Carbon Cycle" = list("Atmospheric CO2" = CONCENTRATIONS_CO2(), @@ -113,7 +113,7 @@ custom_ui <- function(id) { custom_server <- function(id, r6) { moduleServer(id, function(input, output, session) { observe({ - + # Require all inputs to exist if (is.null(input$input_custom_emissions_file) | (is.na(input$input_custom_scenarioName) | is.null(input$input_custom_scenarioName) | (input$input_custom_scenarioName == ""))) { @@ -121,7 +121,7 @@ custom_server <- function(id, r6) { return(NULL) } r6$run_name <- input$input_custom_scenarioName - + # Read in input data inifile <- system.file(input$input_custom_SSP,package="hector") emifile <- input$input_custom_emissions_file @@ -136,26 +136,26 @@ custom_server <- function(id, r6) { incProgress(1/1, detail = paste("Load complete.")) Sys.sleep(0.2) }) - + # get data from base SSP run base_output <- fetchvars(core, 1745:2300, vars = list(r6$selected_var)) %>% mutate(run = names(which(scenarios == input$input_custom_SSP, arr.ind = FALSE)), Scenario = names(which(scenarios == input$input_custom_SSP, arr.ind = FALSE))) #browser() - + # set vars and rerun core for(i in c(2:ncol(emissions_data))) { setvar(core = core, dates = emissions_data[, 1],var = colnames(emissions_data)[i], values = emissions_data[, i], unit = as.character(emissions_headers[[paste0("V",i)]][[1]])) } - + reset(core) run(core) - + # get custom output custom_output <- fetchvars(core, 1745:2300, vars = list(r6$selected_var)) %>% mutate(run = r6$run_name, Scenario = names(which(scenarios == input$input_custom_SSP, arr.ind = FALSE))) r6$output <- bind_rows(list(base_output,custom_output)) - + # Plot # replace following with graph plots function in future output$graph <- renderPlotly({ @@ -165,12 +165,12 @@ custom_server <- function(id, r6) { title = paste0("Variable: ", last(r6$output)$variable[1])) + theme(legend.position = "bottom") }) - + }) %>% bindEvent(input$input_load_emissions) - + output$download_file <- downloadHandler( - + ) - + }) -} \ No newline at end of file +} diff --git a/h2/www/inputs/ssp119_emiss-constraints_rf.csv b/h2/www/inputs/ssp119_emissions.csv similarity index 100% rename from h2/www/inputs/ssp119_emiss-constraints_rf.csv rename to h2/www/inputs/ssp119_emissions.csv diff --git a/h2/www/inputs/ssp126_emiss-constraints_rf.csv b/h2/www/inputs/ssp126_emissions.csv similarity index 100% rename from h2/www/inputs/ssp126_emiss-constraints_rf.csv rename to h2/www/inputs/ssp126_emissions.csv diff --git a/h2/www/inputs/ssp245_emiss-constraints_rf.csv b/h2/www/inputs/ssp245_emissions.csv similarity index 100% rename from h2/www/inputs/ssp245_emiss-constraints_rf.csv rename to h2/www/inputs/ssp245_emissions.csv diff --git a/h2/www/inputs/ssp370_emiss-constraints_rf.csv b/h2/www/inputs/ssp370_emissions.csv similarity index 100% rename from h2/www/inputs/ssp370_emiss-constraints_rf.csv rename to h2/www/inputs/ssp370_emissions.csv diff --git a/h2/www/inputs/ssp434_emiss-constraints_rf.csv b/h2/www/inputs/ssp434_emissions.csv similarity index 100% rename from h2/www/inputs/ssp434_emiss-constraints_rf.csv rename to h2/www/inputs/ssp434_emissions.csv diff --git a/h2/www/inputs/ssp460_emiss-constraints_rf.csv b/h2/www/inputs/ssp460_emissions.csv similarity index 100% rename from h2/www/inputs/ssp460_emiss-constraints_rf.csv rename to h2/www/inputs/ssp460_emissions.csv diff --git a/h2/www/inputs/ssp534-over_emiss-constraints_rf.csv b/h2/www/inputs/ssp534-over_emissions.csv similarity index 100% rename from h2/www/inputs/ssp534-over_emiss-constraints_rf.csv rename to h2/www/inputs/ssp534-over_emissions.csv diff --git a/h2/www/inputs/ssp585_emiss-constraints_rf.csv b/h2/www/inputs/ssp585_emissions.csv similarity index 100% rename from h2/www/inputs/ssp585_emiss-constraints_rf.csv rename to h2/www/inputs/ssp585_emissions.csv