Skip to content

Commit

Permalink
Fix scenario name in plot
Browse files Browse the repository at this point in the history
  • Loading branch information
stephpenn1 committed Dec 18, 2023
1 parent 26020e2 commit 662a896
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion h2/components/functions/func_graph_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ graph_plots <- function(r6) {
} else if(r6$save == FALSE) {

{ggplot(r6$no_save_output) +
geom_line(aes(x = year, y = value, color = ssp)) +
geom_line(aes(x = year, y = value, color = Scenario)) +
labs(x = "Year", y = r6$no_save_output$variable[1],
title = paste0("Run Name: Unsaved Run\n", "Variable: ", r6$no_save_output$variable[1]))} %>%
plotly::ggplotly() %>%
Expand Down
13 changes: 3 additions & 10 deletions h2/components/modules/mod_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ run_ui <- function(id) {
tabPanel(class = "params", "Standard Scenarios",
chooseSliderSkin(skin = "Flat", color = "#375a7f"),
selectInput(ns("ssp_path"), label="Select SSP:",
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",
"SSP 3-7.0"="input/hector_ssp370.ini",
"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"),
choices = scenarios,
selected = "input/hector_ssp245.ini"),
sliderInput(ns("time"), label="Select dates:",
min = 1750, max = 2300, value = c(1900,2100), sep="", width = "90%", step=5),
Expand Down Expand Up @@ -127,14 +120,14 @@ run_server <- function(id, r6) {
if (r6$save == TRUE) {

r6$output[[r6$run_name()]] <- fetchvars(core(), r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
mutate(run = r6$run_name(), Scenario = input$ssp_path)
mutate(run = r6$run_name(), Scenario = names(which(scenarios == input$ssp_path, arr.ind = FALSE)))

updateSwitchInput(session = session, "savetoggle", value = FALSE)

} else if (r6$save == FALSE) {

r6$no_save_output <- fetchvars(core(), r6$time()[1]:r6$time()[2], vars = list(r6$selected_var())) %>%
mutate(ssp = input$ssp_path)
mutate(Scenario = names(which(scenarios == input$ssp_path, arr.ind = FALSE)))

}

Expand Down
9 changes: 9 additions & 0 deletions h2/global.r
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ HectorInputs <- R6Class(
)
)

scenarios <- 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",
"SSP 3-7.0"="input/hector_ssp370.ini",
"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")

title <- list("CO2_concentration" = "Atmospheric CO2",
"atmos_co2" = "Atmospheric Carbon Pool",
"ffi_emissions" = "FFI Emissions",
Expand Down

0 comments on commit 662a896

Please sign in to comment.