...
 
Commits (2)
......@@ -2,7 +2,5 @@
.Rproj.user
local_settings.R
plumber_settings.R
shiny/packrat/lib*/
shiny/packrat/src/
shiny/shiny.Rproj
updateip.sh
......@@ -3,10 +3,12 @@ add_MMM <- function(datin) {
grouping <- c("Var", "Scenario", "Ensemble")
if (has_name(datin, "Month")) grouping <- c(grouping, "Month")
if (has_name(datin, "Season")) grouping <- c(grouping, "Season")
drop <- "Model"
if (has_name(datin, "Note")) drop <- c(drop, "Note")
bind_rows(
datin,
dplyr::select(datin,-Model) %>%
dplyr::select(datin, -drop) %>%
group_by_at(grouping) %>%
summarize_all(mean) %>%
add_column(Model = "MMM", .before = which(names(datin) == "Model"))
......
......@@ -14,4 +14,4 @@ _Conjuntool_ is a free, open source platform for the accessing and processing Ge
## Why "_Conjuntool_"?:
The _Conjuntool_ is an open-source "re-imagining" of the UTSC Ensemble tool, a closed, limited-access platform has been used in the UTSC Climate Lab. The restricted nature of the Ensemble tool runs counter to my commitment to use only open-source software and open methodology in my research. I started writing the code that underlies this tool in Tarapoto, Peru. _Conjuntool_ is a portmanteau of "_conjunto_" (the Spanish word for "ensemble") and "tool".
The _Conjuntool_ (roughly: <a href="https://ipa.vpzom.click/api/synthesize/[ko%C5%8B%CB%88xuntu:l]" target="_blank">[koŋˈxuntu:l]</a>) is an open-source "re-imagining" of the UTSC Ensemble tool, a closed, limited-access platform has been used in the UTSC Climate Lab. The restricted nature of the Ensemble tool runs counter to my commitment to use only open-source software and open methodology in my research. I started writing the code that underlies this tool in Tarapoto, Peru. _Conjuntool_ is a portmanteau of "_conjunto_" (the Spanish word for "ensemble") and "tool".
......@@ -79,14 +79,16 @@ shinyServer(function(input, output, session) {
validate(need(plot_model_in(), "Continue filtering to a single model."))
plot_data <- get_plot_data()
if (input$period_in == "Annual") {
agg <- if (input$var_filter_plot %in% c("tas", "tasmax", "tasmin") ||
!input$convert_units_plot) mean else sum
plot_data <- plot_data %>%
group_by(Time = as.integer(format(plot_data$Time, format = "%Y"))) %>%
summarize(Value = mean(Value, na.rm = TRUE))
summarize(Value = agg(Value, na.rm = TRUE))
}
validate(need(input$types_in, "Select at least one plot type, below."))
isolate({
if (input$convert_units_plot) {
label <- ifelse((input$var_filter_plot %in% c("tas", "tasmax", "tasmin")), "Temperature (°C)", "Precipitation (mm)")
label <- ifelse((input$var_filter_plot %in% c("tas", "tasmax", "tasmin")), "Temperature (°C)", "Total Precipitation (mm)")
} else {
label <- ifelse((input$var_filter_plot %in% c("tas", "tasmax", "tasmin")), "Temperature (K)", "Precipitation Flux (kg·m⁻²·s⁻¹)")
}
......@@ -189,7 +191,7 @@ shinyServer(function(input, output, session) {
tas = "Mean Temperature",
tasmin = "Minimum Temperature",
tasmax = "Maximum Temperature",
pr = "Precipitation",
pr = "Total Precipitation",
prc = "Convective Precipitation",
"Nothing here yet!")
if (isTRUE(input$convert_units)) {
......@@ -259,7 +261,7 @@ shinyServer(function(input, output, session) {
## -- Get anom data and manipulate --- ##
generate_anom_data <- reactive({
time_series <- get_anom_ts()
if (isolate(isTRUE(input$convert_units))) time_series <- convert_units(time_series, input$var_filter)
if (isolate(isTRUE(input$convert_units))) time_series <- convert_units(time_series, isolate(input$var_filter))
process_raw_anom_ts(time_series, reac$anom_period_in,
baseline = isolate(input$baseline_in[1]:input$baseline_in[2]),
projection = isolate(input$projection_in[1]:input$projection_in[2]))
......@@ -276,6 +278,13 @@ shinyServer(function(input, output, session) {
if (reac$anom_period_in == "Seasonal" && !is.null(reac$anom_selected_periods)) {
anom_data <- filter(anom_data, Season %in% reac$anom_selected_periods)
}
if (isolate(input$var_filter) %in% c("pr", "prc") && isolate(isTRUE(input$convert_units))) {
if (reac$anom_period_in == "Seasonal") {
anom_data <- mutate_at(anom_data, vars(contains("-")), funs(. * 3))
} else if (reac$anom_period_in == "Annual") {
anom_data <- mutate_at(anom_data, vars(contains("-")), funs(. * 12))
}
}
anom_data
})
......@@ -308,7 +317,7 @@ shinyServer(function(input, output, session) {
# Ideally I could move this to a conditional panel.
output$precip_anom_note <- renderUI({
validate(need(input$anom_go, FALSE))
if (isolate(input$var_filter %in% c("pr", "prc")) &&
if (isolate(input$var_filter) %in% c("pr", "prc") &&
!is.null(input$add_proc) &&
is.element("Calculate Anomalies", input$add_proc)) {
out <- "<i>Precipitation anomalies are expresed as percentage change (%)</i><br><br>"
......@@ -348,7 +357,7 @@ shinyServer(function(input, output, session) {
output$download_anom_ts <- downloadHandler(
filename = "time_series.csv", content = function(file) {
time_series <- get_anom_ts()
if (isolate(isTRUE(input$convert_units))) time_series <- convert_units(time_series, input$var_filter)
if (isolate(isTRUE(input$convert_units))) time_series <- convert_units(time_series, isolate(input$var_filter))
time_series <- filter(time_series,
(grep("historical", Scenario) & Year %in% isolate(input$baseline_in[1]:input$baseline_in[2])) |
(!grep("historical", Scenario) & Year %in% isolate(input$projection_in[1]:input$projection_in[2])))
......