Skip to content

Commit

Permalink
Permafrost status in title of plot
Browse files Browse the repository at this point in the history
Plot title shows whether permafrost is included or not
  • Loading branch information
ciara-donegan committed Feb 1, 2024
1 parent ab14cd4 commit b054fbb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions h2/components/functions/func_graph_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ graph_plots <- function(r6) {
{ggplot(last(r6$output)) +
geom_line(aes(x = year, y = value, color = Scenario)) +
labs(x = "Year", y = last(r6$output)$variable[1],
title = paste0("Run Name: ", last(r6$output)$run[1], "\n", "Variable: ", last(r6$output)$variable[1])) +
title = paste0("Run Name: ", last(r6$output)$run[1], "\n", "Variable: ", last(r6$output)$variable[1],"\nPermafrost: ",r6$permafrost)) +
theme(legend.position = "bottom")} %>%
plotly::ggplotly()

Expand All @@ -17,7 +17,7 @@ graph_plots <- function(r6) {
{ggplot(r6$no_save_output) +
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]))} %>%
title = paste0("Run Name: Unsaved Run\n", "Variable: ", r6$no_save_output$variable[1],"\nPermafrost: ",r6$permafrost))} %>%
plotly::ggplotly() %>%
layout(
legend = list(
Expand Down
15 changes: 6 additions & 9 deletions h2/components/modules/mod_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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),
materialSwitch(ns("permafrost"), "Include Permafrost Carbon", value = FALSE),
h5("Model Parameters"),
sliderInput(ns("alpha"), label="Aerosol forcing scaling factor", # AERO_SCALE()
min = 0.01, max = 1, value = 1, width = "90%"),
Expand All @@ -24,8 +25,7 @@ run_ui <- function(id) {
sliderInput(ns("q10_rh"), label="Heterotrophic temperature sensitivity", # Q10_RH()
min = 1, max = 5, value = 2, step=0.1, width = "90%"),
sliderInput(ns("volscl"), label="Volcanic forcing scaling factor", # VOLCANIC_SCALE()
min = 0, max = 1, value = 1, width = "90%"),
materialSwitch(ns("permafrost"), "Include Permafrost Carbon", value = FALSE)
min = 0, max = 1, value = 1, width = "90%")
)
)

Expand Down Expand Up @@ -104,6 +104,9 @@ run_server <- function(id, r6) {
# Set parameters using inputs (function to only call setvar once in final version)
if (input$permafrost == TRUE) {
setvar(core(),0,PERMAFROST_C(),865,"Pg C")
r6$permafrost <- "On"
} else if (input$permafrost == FALSE) {
r6$permafrost <- "Off"
}
setvar(core(),NA,AERO_SCALE(),input$alpha,"(unitless)")
setvar(core(),NA,BETA(),input$beta,"(unitless)")
Expand Down Expand Up @@ -168,10 +171,4 @@ run_server <- function(id, r6) {


})
}

# might be worth it to just run the core with all selectable variables. how much time would that add?
# issue seems to be that mod_run goes first, so input$variable just doesn't exist yet... maybe having
# that module containing all choices is a good idea

# fetchvars(core,1745:2300,vars=list(CONCENTRATIONS_CO2(),FFI_EMISSIONS(),LUC_EMISSIONS(),CONCENTRATIONS_N2O,EMISSIONS_BC(),EMISSIONS_OC(),RF_TOTAL(),RF_ALBEDO(),RF_N2O(),RF_CO2(),RF_BC(),RF_OC(),RF_SO2(),RF_CH4(),RF_VOL()))
}
1 change: 1 addition & 0 deletions h2/global.r
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ HectorInputs <- R6Class(
no_save_output = NULL,
no_save = NULL,
run_name = NA,
permafrost = NULL,
save = NULL,
inputs = NULL,
selected_var = NULL,
Expand Down

0 comments on commit b054fbb

Please sign in to comment.