diff --git a/results/all_run_CO2_comparison.jpeg b/results/all_run_CO2_comparison.jpeg new file mode 100644 index 0000000..4e4ec90 Binary files /dev/null and b/results/all_run_CO2_comparison.jpeg differ diff --git a/results/all_run_OHC_comparison.jpeg b/results/all_run_OHC_comparison.jpeg new file mode 100644 index 0000000..14cb52e Binary files /dev/null and b/results/all_run_OHC_comparison.jpeg differ diff --git a/results/all_run_T_comparison.jpeg b/results/all_run_T_comparison.jpeg new file mode 100644 index 0000000..2a860ec Binary files /dev/null and b/results/all_run_T_comparison.jpeg differ diff --git a/results/all_run_comparison_plots.jpeg b/results/all_run_comparison_plots.jpeg new file mode 100644 index 0000000..913c735 Binary files /dev/null and b/results/all_run_comparison_plots.jpeg differ diff --git a/results/default_stats.txt b/results/default_stats.txt index 9853d15..e7f3c41 100644 --- a/results/default_stats.txt +++ b/results/default_stats.txt @@ -18,6 +18,7 @@ Mean of smooth T, CO2 NMSEs (k = 5 ): 0.000846 Mean of smooth T, CO2 MSEs (k = 10 ): 2.3 Mean of smooth T, CO2 NMSEs (k = 10 ): 0.000836 + CO2 MSE: 4.58 T MSE: 0.0358 T MSE w/ unc: 0.0118 diff --git a/results/future_T_comparison.jpeg b/results/future_T_comparison.jpeg new file mode 100644 index 0000000..06364fc Binary files /dev/null and b/results/future_T_comparison.jpeg differ diff --git a/results/ohc_plot.jpeg b/results/ohc_plot.jpeg index 34949be..5821161 100644 Binary files a/results/ohc_plot.jpeg and b/results/ohc_plot.jpeg differ diff --git a/results/roundtable_comparison_plots.jpeg b/results/roundtable_comparison_plots.jpeg new file mode 100644 index 0000000..b528f0b Binary files /dev/null and b/results/roundtable_comparison_plots.jpeg differ diff --git a/scripts/graph_comparison_plots.R b/scripts/graph_comparison_plots.R index 0a9dee7..df69770 100644 --- a/scripts/graph_comparison_plots.R +++ b/scripts/graph_comparison_plots.R @@ -7,6 +7,7 @@ # Importing libraries library(hector) library(ggplot2) +theme_set(theme_bw(base_size = 20)) # Setting up file paths COMP_DATA_DIR <- file.path(here::here(), "comparison_data") @@ -22,7 +23,7 @@ TEMP_PATH <- INI_FILE <- system.file("input/hector_ssp245.ini", package = "hector") PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS(), AERO_SCALE()) -OUTPUT <- file.path(RESULTS_DIR, "nmae_comparison_plots.jpeg") +OUTPUT <- file.path(RESULTS_DIR, "all_run_comparison_plots.jpeg") source(file.path(SCRIPTS_DIR, "major_functions.R")) @@ -38,84 +39,170 @@ temp_data <- filter(temp_data, year <= 2014) obs_data <- rbind(co2_data, temp_data) ### Running Hector ### +# Default (and initial smoothing) Results [Exp. 1-4] default_data <- run_hector(ini_file = INI_FILE, params = NULL, vals = NULL, yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -default_data$scenario <- "Hector - Default Fit" +default_data$scenario <- "Hector - Default" - -nmse_data <- run_hector(ini_file = INI_FILE, +# NMSE 3-Parameter Results [Exp.5-9] +exp5_9A <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.268, 2.64, 2.2, 3, 1), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -nmse_data$scenario <- "Hector - NMSE w/ unc Fit" +exp5_9A$scenario <- "Hector - NMSE" -nmse_bb_data <- run_hector(ini_file = INI_FILE, +exp5B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.5, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp5B$scenario <- "Hector - NMSE \nBig Box" + +exp6B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.58, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp6B$scenario <- "Hector - NMSE, Smoothing (k = 3) \nBig Box" + +exp8B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.95, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp8B$scenario <- "Hector - NMSE, Smoothing (k = 10) \nBig Box" + +exp9B <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.028, 1.76, 2.6, 3, 1), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -nmse_bb_data$scenario <- "Hector - NMSE w/ unc, Big Box Fit" +exp9B$scenario <- "Hector - NMSE w/ unc \nBig Box" + -ecs_data <- run_hector(ini_file = INI_FILE, +# Optimizing S, Alpha [Exp. 10-11] +exp10A <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.268, 1.95, 2.6, 3.97, 1), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -ecs_data$scenario <- "Hector - NMSE w/ unc, Fit w/ S" +exp10A$scenario <- "Hector - NMSE w/ unc \nTuning S" -ecs_bb_data <- run_hector(ini_file = INI_FILE, +exp10B <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.006, 1, 2.6, 3.16, 1), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -ecs_bb_data$scenario <- "Hector - NMSE w/ unc, Big Box Fit w/ S" +exp10B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S" -alpha_data <- run_hector(ini_file = INI_FILE, +exp11A <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.57, 1.76, 2.38, 2.96, 0.492), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -alpha_data$scenario <- "Hector - NMSE w/ unc, Fit w/ S, Alpha" +exp11A$scenario <- "Hector - NMSE w/ unc \nTuning S, Alpha" -alpha_bb_data <- run_hector(ini_file = INI_FILE, +exp11B <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.502, 0.99, 2, 2.88, 0.5), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -alpha_bb_data$scenario <- "Hector - NMSE w/ unc, Big Box Fit w/ S, Alpha" +exp11B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S, Alpha" -alpha_ohc_data <- run_hector(ini_file = INI_FILE, +# Optimizing for OHC & Further Refinements [Exp. 12-16] +exp12 <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.65, 1.76, 1.04, 2.33, 0.438), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -alpha_ohc_data$scenario <- "Hector - NMSE w/ unc (incl. OHC), Fit w/ S, Alpha" - -nmae_data <- run_hector(ini_file = INI_FILE, +exp12$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning S, Alpha" + +exp13 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.53, 2.31, 1.04, 2.83, 1.405), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp13$scenario <- "Hector - MVSSE, incl. OHC \nTuning S, Alpha" + +exp14A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.732, 1.76, 1.04, 3, 0.613), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp14A$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning Alpha" + +exp14B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.904, 0.88, 0.806, 3, 0.46), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp14B$scenario <- "Hector - NMSE w/ unc, incl. OHC \nBig Box, Tuning Alpha" + +exp15 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 2.49, 1.06, 3.14, 1.08), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp15$scenario <- "Hector - MAE w/ unc, incl. OHC \nTuning S, Alpha" + +exp16 <- run_hector(ini_file = INI_FILE, params = PARAMS, vals = c(0.59, 1.76, 1.04, 2.17, 0.411), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -nmae_data$scenario <- "Hector - NMAE w/ unc (incl. OHC), Fit w/ S, Alpha" - -#hector_data <- rbind(default_data, nmse_data, nmse_bb_data, ecs_data, ecs_bb_data, alpha_data, alpha_bb_data) -hector_data <- rbind(default_data, alpha_ohc_data, nmae_data) +exp16$scenario <- "Hector - NMAE w/ unc, incl. OHC \nTuning S, Alpha" + +# Coloring all unimportant runs grey +grey_data <- rbind(exp5_9A, exp5B, exp6B, exp8B, exp9B, # NMSEs + exp10A, exp10B, # Add S + exp11B, # Add alpha + exp12, # Add OHC, Mat Diff + exp13, # Try MVSSE + exp14A, exp14B, # Try remove S + exp15) # Try MAE +grey_data$exp <- "Hector - Other Experiments" + +# Coloring important runs +key_data <- rbind(default_data, exp11A, exp16) # Best Runs +key_data$exp <- key_data$scenario + +#Combining all Hector data +hector_data <- rbind(grey_data, key_data) hector_data$lower <- hector_data$value hector_data$upper <- hector_data$value +# Filtering data to look nice for graph +hector_data <- filter(hector_data, variable == CONCENTRATIONS_CO2() | + (year >= 1850 & variable == GMST())) + +obs_data$exp <- "Historical" comb_data <- rbind(obs_data, hector_data) -ggplot(data = comb_data, aes(x = year, y = value, color = scenario)) + +ggplot(data = comb_data, aes(x = year, y = value, color = exp)) + + # Plotting uncertainty in Temperature geom_ribbon(data = filter(comb_data, scenario == "historical" & variable == GMST()), aes(ymin = lower, ymax = upper), - fill = 'orchid1', - color = NA) + - geom_line() + + fill = 'hotpink2', + color = NA, + alpha = 0.5) + + # Plotting background runs + geom_line(data = filter(comb_data, exp == "Hector - Other Experiments" | + (scenario == "historical" & year >= 1850)), + aes(group = scenario)) + + # Plotting foreground runs + geom_line(data = filter(comb_data, exp != "Hector - Other Experiments" & + scenario != "historical")) + + # Plotting 1750 CO2 data point + geom_point(data = filter(comb_data, scenario == "historical" & year < 1850)) + + + # Cleaning up plot facet_wrap(~ variable, scales = "free") + - ggtitle("Comparing Parameterizations") -ggsave(OUTPUT, width = 16) \ No newline at end of file + ggtitle("Comparing Parameterizations") + + scale_color_manual(values = c("blue", "#009E73","#D55E00", "grey", "#CC79A7")) + + theme(legend.text = element_text(size = 15), legend.key.height = unit(2, "cm")) +ggsave(OUTPUT, width = 16, height = 16) \ No newline at end of file diff --git a/scripts/other/CO2_comparison.R b/scripts/other/CO2_comparison.R new file mode 100644 index 0000000..aff1dad --- /dev/null +++ b/scripts/other/CO2_comparison.R @@ -0,0 +1,218 @@ +# Script to compare runs that use different hector parameterizations +# This script only makes a CO2 plot +# However, since it's based on a script to plot both CO2 and T, it +# (inefficiently) also records T data +# Author: Peter Scully +# Date: 6/13/24 + +### Constants and Imports ### + +# Importing libraries +library(hector) +library(ggplot2) +theme_set(theme_bw(base_size = 20)) + +# Setting up file paths +COMP_DATA_DIR <- file.path(here::here(), "comparison_data") +SCRIPTS_DIR <- file.path(here::here(), "scripts") +RESULTS_DIR <- file.path(here::here(), "results") + +CO2_PATH <- file.path(COMP_DATA_DIR, + "Supplementary_Table_UoM_GHGConcentrations-1-1-0_annualmeans_v23March2017.csv") +TEMP_PATH <- + file.path(COMP_DATA_DIR, + "HadCRUT.5.0.2.0.analysis.summary_series.global.annual.csv") + +INI_FILE <- system.file("input/hector_ssp245.ini", package = "hector") +PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS(), AERO_SCALE()) + +OUTPUT <- file.path(RESULTS_DIR, "all_run_CO2_comparison.jpeg") + + +source(file.path(SCRIPTS_DIR, "major_functions.R")) + +### Getting observational data ### +co2_data <- get_co2_data(CO2_PATH) +co2_data$lower <- co2_data$value +co2_data$upper <- co2_data$value + +temp_data <- get_temp_data(TEMP_PATH, include_unc = T) +temp_data <- filter(temp_data, year <= 2014) + +obs_data <- rbind(co2_data, temp_data) + +### Running Hector ### +# Default (and initial smoothing) Results [Exp. 1-4] +default_data <- run_hector(ini_file = INI_FILE, + params = NULL, + vals = NULL, + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +default_data$scenario <- "Hector - Default" + +# NMSE 3-Parameter Results [Exp.5-9] +exp5_9A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 2.64, 2.2, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp5_9A$scenario <- "Hector - NMSE" + +exp5B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.5, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp5B$scenario <- "Hector - NMSE \nBig Box" + +exp6B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.58, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp6B$scenario <- "Hector - NMSE, Smoothing (k = 3) \nBig Box" + +exp8B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.95, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp8B$scenario <- "Hector - NMSE, Smoothing (k = 10) \nBig Box" + +exp9B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.028, 1.76, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp9B$scenario <- "Hector - NMSE w/ unc \nBig Box" + + +# Optimizing S, Alpha [Exp. 10-11] +exp10A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 1.95, 2.6, 3.97, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp10A$scenario <- "Hector - NMSE w/ unc \nTuning S" + +exp10B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.006, 1, 2.6, 3.16, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp10B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S" + +exp11A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 1.76, 2.38, 2.96, 0.492), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp11A$scenario <- "Hector - NMSE w/ unc \nTuning S, Alpha" + +exp11B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.502, 0.99, 2, 2.88, 0.5), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp11B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S, Alpha" + +# Optimizing for OHC & Further Refinements [Exp. 12-16] +exp12 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.65, 1.76, 1.04, 2.33, 0.438), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp12$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning S, Alpha" + +exp13 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.53, 2.31, 1.04, 2.83, 1.405), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp13$scenario <- "Hector - MVSSE, incl. OHC \nTuning S, Alpha" + +exp14A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.732, 1.76, 1.04, 3, 0.613), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp14A$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning Alpha" + +exp14B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.904, 0.88, 0.806, 3, 0.46), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp14B$scenario <- "Hector - NMSE w/ unc, incl. OHC \nBig Box, Tuning Alpha" + +exp15 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 2.49, 1.06, 3.14, 1.08), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp15$scenario <- "Hector - MAE w/ unc, incl. OHC \nTuning S, Alpha" + +exp16 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.59, 1.76, 1.04, 2.17, 0.411), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp16$scenario <- "Hector - NMAE w/ unc, incl. OHC \nTuning S, Alpha" + +# Coloring all unimportant runs grey +grey_data <- rbind(exp5_9A, exp5B, exp6B, exp8B, exp9B, # NMSEs + exp10A, exp10B, # Add S + exp11B, # Add alpha + exp12, # Add OHC, Mat Diff + exp13, # Try MVSSE + exp14A, exp14B, # Try remove S + exp15) # Try MAE +grey_data$exp <- "Hector - Other Experiments" + +# Coloring important runs +key_data <- rbind(default_data, exp11A, exp16) # Best Runs +key_data$exp <- key_data$scenario + +#Combining all Hector data +hector_data <- rbind(grey_data, key_data) +hector_data$lower <- hector_data$value +hector_data$upper <- hector_data$value + +# Filtering data to look nice for graph +hector_data <- filter(hector_data, variable == CONCENTRATIONS_CO2() | + (year >= 1850 & variable == GMST())) + +obs_data$exp <- "Historical" +comb_data <- rbind(obs_data, hector_data) + +#Filtering for CO2 data +comb_data <- filter(comb_data, variable == CONCENTRATIONS_CO2()) + +ggplot(data = comb_data, aes(x = year, y = value, color = exp)) + + # Plotting uncertainty in Temperature + geom_ribbon(data = + filter(comb_data, scenario == "historical" & variable == GMST()), + aes(ymin = lower, ymax = upper), + fill = 'grey', + color = NA, + alpha = 0.5) + + # Plotting background runs + geom_line(data = filter(comb_data, exp == "Hector - Other Experiments"), + aes(group = scenario)) + + # Plotting foreground runs + geom_line(data = filter(comb_data, exp != "Hector - Other Experiments" & + (year >= 1850 | scenario != "historical")), + aes(linetype = exp), + linewidth = 1.5) + + # Plotting 1750 CO2 data point + geom_point(data = filter(comb_data, scenario == "historical" & year < 1850)) + + + # Cleaning up plot + scale_color_manual(name = "Experiments", + values = c("orange", "blue", "#009E73", "snow4", "black")) + + scale_linetype(guide = F) + + theme(legend.text = element_text(size = 15), + legend.key.height = unit(2, "cm")) + + ylab(expression('CO'[2]*' Concentration (ppmv)')) + + xlab("Year") +ggsave(OUTPUT, width = 12) \ No newline at end of file diff --git a/scripts/other/OHC_comparison_pretty.R b/scripts/other/OHC_comparison_pretty.R new file mode 100644 index 0000000..8f0538c --- /dev/null +++ b/scripts/other/OHC_comparison_pretty.R @@ -0,0 +1,203 @@ +# Script to compare runs that use different hector parameterizations +# This script only makes an OHC plot +# However, since it's based on a script to plot both CO2 and T, it +# may (inefficiently) also record T and CO2 data +# Author: Peter Scully +# Date: 7/1/24 + +### Constants and Imports ### + +# Importing libraries +library(hector) +library(ggplot2) +theme_set(theme_bw(base_size = 20)) + +# Setting up file paths +COMP_DATA_DIR <- file.path(here::here(), "comparison_data") +SCRIPTS_DIR <- file.path(here::here(), "scripts") +RESULTS_DIR <- file.path(here::here(), "results") + +OHC_PATH <- file.path(COMP_DATA_DIR, "OHC_ensemble_Kuhlbrodt_etal_2022.csv") + +INI_FILE <- system.file("input/hector_ssp245.ini", package = "hector") +PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS(), AERO_SCALE()) + +OUTPUT <- file.path(RESULTS_DIR, "all_run_OHC_comparison.jpeg") + + +source(file.path(SCRIPTS_DIR, "major_functions.R")) + +### Getting observational data ### +obs_data <- get_ohc_data(OHC_PATH, include_unc = T) + +### Running Hector ### +# Default (and initial smoothing) Results [Exp. 1-4] +default_data <- run_hector(ini_file = INI_FILE, + params = NULL, + vals = NULL, + yrs = 1750:2014, + vars = HEAT_FLUX()) +default_data$scenario <- "Hector - Default" + +# NMSE 3-Parameter Results [Exp.5-9] +exp5_9A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 2.64, 2.2, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp5_9A$scenario <- "Hector - NMSE" + +exp5B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.5, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp5B$scenario <- "Hector - NMSE \nBig Box" + +exp6B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.58, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp6B$scenario <- "Hector - NMSE, Smoothing (k = 3) \nBig Box" + +exp8B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.95, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp8B$scenario <- "Hector - NMSE, Smoothing (k = 10) \nBig Box" + +exp9B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.028, 1.76, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp9B$scenario <- "Hector - NMSE w/ unc \nBig Box" + + +# Optimizing S, Alpha [Exp. 10-11] +exp10A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 1.95, 2.6, 3.97, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp10A$scenario <- "Hector - NMSE w/ unc \nTuning S" + +exp10B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.006, 1, 2.6, 3.16, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp10B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S" + +exp11A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 1.76, 2.38, 2.96, 0.492), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp11A$scenario <- "Hector - NMSE w/ unc \nTuning S, Alpha" + +exp11B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.502, 0.99, 2, 2.88, 0.5), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp11B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S, Alpha" + +# Optimizing for OHC & Further Refinements [Exp. 12-16] +exp12 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.65, 1.76, 1.04, 2.33, 0.438), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp12$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning S, Alpha" + +exp13 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.53, 2.31, 1.04, 2.83, 1.405), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp13$scenario <- "Hector - MVSSE, incl. OHC \nTuning S, Alpha" + +exp14A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.732, 1.76, 1.04, 3, 0.613), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp14A$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning Alpha" + +exp14B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.904, 0.88, 0.806, 3, 0.46), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp14B$scenario <- "Hector - NMSE w/ unc, incl. OHC \nBig Box, Tuning Alpha" + +exp15 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 2.49, 1.06, 3.14, 1.08), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp15$scenario <- "Hector - MAE w/ unc, incl. OHC \nTuning S, Alpha" + +exp16 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.59, 1.76, 1.04, 2.17, 0.411), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp16$scenario <- "Hector - NMAE w/ unc, incl. OHC \nTuning S, Alpha" + +# Coloring all unimportant runs grey +grey_data <- rbind(exp5_9A, exp5B, exp6B, exp8B, exp9B, # NMSEs + exp10A, exp10B, # Add S + exp11B, # Add alpha + exp12, # Add OHC, Mat Diff + exp13, # Try MVSSE + exp14A, exp14B, # Try remove S + exp15) # Try MAE +grey_data$exp <- "Hector - Other Experiments" + +# Coloring important runs +key_data <- rbind(default_data, exp11A, exp16) # Best Runs +key_data$exp <- key_data$scenario + +#Combining all Hector data +hector_data <- rbind(grey_data, key_data) +hector_data$lower <- hector_data$value +hector_data$upper <- hector_data$value + +# Filtering data to look nice for graph +hector_data <- filter(hector_data, variable == "OHC") + +obs_data$exp <- "Historical" +comb_data <- rbind(obs_data, hector_data) + +#Filtering for OHC data +comb_data <- filter(comb_data, variable == "OHC") + +ggplot(data = comb_data, aes(x = year, y = value, color = exp)) + + # Plotting uncertainty in Temperature + geom_ribbon(data = + filter(comb_data, scenario == "historical" & variable == "OHC"), + aes(ymin = lower, ymax = upper), + fill = 'grey', + color = NA, + alpha = 0.5) + + # Plotting background runs + geom_line(data = filter(comb_data, exp == "Hector - Other Experiments"), + aes(group = scenario)) + + # Plotting foreground runs + geom_line(data = filter(comb_data, exp != "Hector - Other Experiments"), + linewidth = 1.0) + + # Plotting 1750 CO2 data point + geom_point(data = filter(comb_data, scenario == "historical" & year < 1850)) + + + # Cleaning up plot + scale_color_manual(name = "Experiments", + values = c("orange", "blue", "#009E73", "snow4", "black")) + + theme(legend.text = element_text(size = 15), + legend.key.height = unit(2, "cm")) + + ylab(expression('Global Ocean Heat Content Anomaly (ZJ)')) + + xlab("Year") +ggsave(OUTPUT, width = 12) \ No newline at end of file diff --git a/scripts/other/T_comparison.R b/scripts/other/T_comparison.R new file mode 100644 index 0000000..3732851 --- /dev/null +++ b/scripts/other/T_comparison.R @@ -0,0 +1,218 @@ +# Script to compare plots that use different hector parameterizations +# This script only makes a temperature plot +# However, since it's based on a script to plot both CO2 and T, it +# (inefficiently) also records CO2 data +# Author: Peter Scully +# Date: 6/13/24 + +### Constants and Imports ### + +# Importing libraries +library(hector) +library(ggplot2) +theme_set(theme_bw(base_size = 20)) + +# Setting up file paths +COMP_DATA_DIR <- file.path(here::here(), "comparison_data") +SCRIPTS_DIR <- file.path(here::here(), "scripts") +RESULTS_DIR <- file.path(here::here(), "results") + +CO2_PATH <- file.path(COMP_DATA_DIR, + "Supplementary_Table_UoM_GHGConcentrations-1-1-0_annualmeans_v23March2017.csv") +TEMP_PATH <- + file.path(COMP_DATA_DIR, + "HadCRUT.5.0.2.0.analysis.summary_series.global.annual.csv") + +INI_FILE <- system.file("input/hector_ssp245.ini", package = "hector") +PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS(), AERO_SCALE()) + +OUTPUT <- file.path(RESULTS_DIR, "all_run_T_comparison.jpeg") + + +source(file.path(SCRIPTS_DIR, "major_functions.R")) + +### Getting observational data ### +co2_data <- get_co2_data(CO2_PATH) +co2_data$lower <- co2_data$value +co2_data$upper <- co2_data$value + +temp_data <- get_temp_data(TEMP_PATH, include_unc = T) +temp_data <- filter(temp_data, year <= 2014) + +obs_data <- rbind(co2_data, temp_data) + +### Running Hector ### +# Default (and initial smoothing) Results [Exp. 1-4] +default_data <- run_hector(ini_file = INI_FILE, + params = NULL, + vals = NULL, + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +default_data$scenario <- "Hector - Default" + +# NMSE 3-Parameter Results [Exp.5-9] +exp5_9A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 2.64, 2.2, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp5_9A$scenario <- "Hector - NMSE" + +exp5B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.5, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp5B$scenario <- "Hector - NMSE \nBig Box" + +exp6B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.58, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp6B$scenario <- "Hector - NMSE, Smoothing (k = 3) \nBig Box" + +exp8B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.95, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp8B$scenario <- "Hector - NMSE, Smoothing (k = 10) \nBig Box" + +exp9B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.028, 1.76, 2.6, 3, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp9B$scenario <- "Hector - NMSE w/ unc \nBig Box" + + +# Optimizing S, Alpha [Exp. 10-11] +exp10A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 1.95, 2.6, 3.97, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp10A$scenario <- "Hector - NMSE w/ unc \nTuning S" + +exp10B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.006, 1, 2.6, 3.16, 1), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp10B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S" + +exp11A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 1.76, 2.38, 2.96, 0.492), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp11A$scenario <- "Hector - NMSE w/ unc \nTuning S, Alpha" + +exp11B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.502, 0.99, 2, 2.88, 0.5), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp11B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S, Alpha" + +# Optimizing for OHC & Further Refinements [Exp. 12-16] +exp12 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.65, 1.76, 1.04, 2.33, 0.438), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp12$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning S, Alpha" + +exp13 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.53, 2.31, 1.04, 2.83, 1.405), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp13$scenario <- "Hector - MVSSE, incl. OHC \nTuning S, Alpha" + +exp14A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.732, 1.76, 1.04, 3, 0.613), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp14A$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning Alpha" + +exp14B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.904, 0.88, 0.806, 3, 0.46), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp14B$scenario <- "Hector - NMSE w/ unc, incl. OHC \nBig Box, Tuning Alpha" + +exp15 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 2.49, 1.06, 3.14, 1.08), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp15$scenario <- "Hector - MAE w/ unc, incl. OHC \nTuning S, Alpha" + +exp16 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.59, 1.76, 1.04, 2.17, 0.411), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +exp16$scenario <- "Hector - NMAE w/ unc, incl. OHC \nTuning S, Alpha" + +# Coloring all unimportant runs grey +grey_data <- rbind(exp5_9A, exp5B, exp6B, exp8B, exp9B, # NMSEs + exp10A, exp10B, # Add S + exp11B, # Add alpha + exp12, # Add OHC, Mat Diff + exp13, # Try MVSSE + exp14A, exp14B, # Try remove S + exp15) # Try MAE +grey_data$exp <- "Hector - Other Experiments" + +# Coloring important runs +key_data <- rbind(default_data, exp11A, exp16) # Best Runs +key_data$exp <- key_data$scenario + +#Combining all Hector data +hector_data <- rbind(grey_data, key_data) +hector_data$lower <- hector_data$value +hector_data$upper <- hector_data$value + +# Filtering data to look nice for graph +hector_data <- filter(hector_data, variable == CONCENTRATIONS_CO2() | + (year >= 1850 & variable == GMST())) + +obs_data$exp <- "Historical" +comb_data <- rbind(obs_data, hector_data) + +#Filtering for temperature data only +comb_data <- filter(comb_data, variable == GMST()) + +ggplot(data = comb_data, aes(x = year, y = value, color = exp)) + + # Plotting uncertainty in Temperature + geom_ribbon(data = + filter(comb_data, scenario == "historical" & variable == GMST()), + aes(ymin = lower, ymax = upper), + fill = 'grey', + color = NA, + alpha = 0.5) + + # Plotting background runs + geom_line(data = filter(comb_data, exp == "Hector - Other Experiments"), + aes(group = scenario)) + + # Plotting foreground runs + geom_line(data = filter(comb_data, scenario == "historical" & year >= 1850), + linewidth = 1.25) + + geom_line(data = filter(comb_data, exp != "Hector - Other Experiments" & + scenario != "historical"), + linewidth = 1.5, + aes(linetype = exp)) + + + # Cleaning up plot + scale_color_manual(name = "Experiments", + values = c("orange", "blue", "#009E73", "snow4", "black")) + + scale_linetype(guide = "none") + + theme(legend.text = element_text(size = 15), + legend.key.height = unit(2, "cm")) + + ylab("Temperature Anomaly (\u00B0C)") + + xlab("Year") +ggsave(OUTPUT, width = 12) \ No newline at end of file diff --git a/scripts/other/T_future_comparison.R b/scripts/other/T_future_comparison.R new file mode 100644 index 0000000..f1f5898 --- /dev/null +++ b/scripts/other/T_future_comparison.R @@ -0,0 +1,77 @@ +# Script to compare future temperatures for different Hector parameterizations +# Author: Peter Scully +# Date: 6/13/24 + +### Constants and Imports ### + +# Importing libraries +library(hector) +library(ggplot2) +theme_set(theme_bw(base_size = 20)) + +# Setting up file paths +COMP_DATA_DIR <- file.path(here::here(), "comparison_data") +SCRIPTS_DIR <- file.path(here::here(), "scripts") +RESULTS_DIR <- file.path(here::here(), "results") + +INI_PREFIX <- system.file("input/hector_ssp", package = "hector") # +PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS(), AERO_SCALE()) + +OUTPUT <- file.path(RESULTS_DIR, "future_T_comparison.jpeg") + + +source(file.path(SCRIPTS_DIR, "major_functions.R")) + + +# Running Hector (modified from calc_table_metrics in major_functions.R) + +# Setting up variables +future_yrs <- 1850:2100 +future_vars <- GLOBAL_TAS() # Using global_tas to match IPCC AR6 future metrics + +# Getting the names of each scenario file +scenarios <- c("119", "245", "585") +scenario_names <- paste("input/hector_ssp", scenarios, ".ini", sep = "") +scenario_files <- system.file(scenario_names, package = "hector") + +# Setting up results data frame +future_results <- data.frame(matrix(nrow = 0, ncol = 5)) +colnames(future_results) <- c("scenario", "variable", "value", "units", "run") + +# Doing default run +for (scen_counter in 1:length(scenario_files)) { + # Adding default data + default_data <- run_hector(ini_file = scenario_files[scen_counter], + params = NULL, + vals = NULL, + yrs = future_yrs, + vars = future_vars) + default_data$scenario <- paste("ssp", scenarios[scen_counter], sep="") + default_data$run <- "Default Parameterization" + + # Adding best run data + new_data <- run_hector(ini_file = scenario_files[scen_counter], + params = PARAMS, + vals = c(0.59, 1.76, 1.04, 2.17, 0.411), + yrs = future_yrs, + vars = future_vars) + new_data$scenario <- paste("ssp", scenarios[scen_counter], sep="") + new_data$run <- "New Parameterization" + + # Adding both data frames to results data frame + future_results <- rbind(future_results, new_data, default_data) +} + +# Plot results +ggplot(data = future_results, aes(x = year, y = value, color = run)) + + geom_line(linewidth = 1.0) + + facet_wrap(~ scenario) + + + # Cleaning up plot + scale_color_manual(name = "", + values = c("orange", "blue")) + + theme(legend.text = element_text(size = 15), + legend.key.height = unit(2, "cm")) + + ylab("Temperature Anomaly (\u00B0C)") + + xlab("Year") +ggsave(OUTPUT, width = 20) \ No newline at end of file diff --git a/scripts/other/calc_OHC_RMSE.R b/scripts/other/calc_OHC_RMSE.R new file mode 100644 index 0000000..52c51fd --- /dev/null +++ b/scripts/other/calc_OHC_RMSE.R @@ -0,0 +1,162 @@ +# Script to calculate OHC RMSE for all runs (since we didn't calculate it +# automatically for most runs) +# Author: Peter Scully +# Date: 7/1/24 + +### Constants and Imports ### + +# Importing libraries +library(hector) +library(ggplot2) +theme_set(theme_bw(base_size = 20)) + +# Setting up file paths +COMP_DATA_DIR <- file.path(here::here(), "comparison_data") +SCRIPTS_DIR <- file.path(here::here(), "scripts") +RESULTS_DIR <- file.path(here::here(), "results") + +OHC_PATH <- file.path(COMP_DATA_DIR, "OHC_ensemble_Kuhlbrodt_etal_2022.csv") + +INI_FILE <- system.file("input/hector_ssp245.ini", package = "hector") +PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS(), AERO_SCALE()) + +OUTPUT <- file.path(RESULTS_DIR, "OHC_RMSE.txt") + + +source(file.path(SCRIPTS_DIR, "major_functions.R")) + +### Getting observational data ### +obs_data <- get_ohc_data(OHC_PATH, include_unc = T) + +### Running Hector ### +# Default (and initial smoothing) Results [Exp. 1-4] +default_data <- run_hector(ini_file = INI_FILE, + params = NULL, + vals = NULL, + yrs = 1750:2014, + vars = HEAT_FLUX()) +default_data$scenario <- "Hector - Default" + +# NMSE 3-Parameter Results [Exp.5-9] +exp5_9A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 2.64, 2.2, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp5_9A$scenario <- "Hector - NMSE" + +exp5B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.5, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp5B$scenario <- "Hector - NMSE \nBig Box" + +exp6B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.58, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp6B$scenario <- "Hector - NMSE, Smoothing (k = 3) \nBig Box" + +exp8B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0, 1.95, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp8B$scenario <- "Hector - NMSE, Smoothing (k = 10) \nBig Box" + +exp9B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.028, 1.76, 2.6, 3, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp9B$scenario <- "Hector - NMSE w/ unc \nBig Box" + + +# Optimizing S, Alpha [Exp. 10-11] +exp10A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.268, 1.95, 2.6, 3.97, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp10A$scenario <- "Hector - NMSE w/ unc \nTuning S" + +exp10B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.006, 1, 2.6, 3.16, 1), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp10B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S" + +exp11A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 1.76, 2.38, 2.96, 0.492), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp11A$scenario <- "Hector - NMSE w/ unc \nTuning S, Alpha" + +exp11B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.502, 0.99, 2, 2.88, 0.5), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp11B$scenario <- "Hector - NMSE w/ unc \nBig Box, Tuning S, Alpha" + +# Optimizing for OHC & Further Refinements [Exp. 12-16] +exp12 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.65, 1.76, 1.04, 2.33, 0.438), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp12$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning S, Alpha" + +exp13 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.53, 2.31, 1.04, 2.83, 1.405), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp13$scenario <- "Hector - MVSSE, incl. OHC \nTuning S, Alpha" + +exp14A <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.732, 1.76, 1.04, 3, 0.613), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp14A$scenario <- "Hector - NMSE w/ unc, incl. OHC \nTuning Alpha" + +exp14B <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.904, 0.88, 0.806, 3, 0.46), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp14B$scenario <- "Hector - NMSE w/ unc, incl. OHC \nBig Box, Tuning Alpha" + +exp15 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.57, 2.49, 1.06, 3.14, 1.08), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp15$scenario <- "Hector - MAE w/ unc, incl. OHC \nTuning S, Alpha" + +exp16 <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(0.59, 1.76, 1.04, 2.17, 0.411), + yrs = 1750:2014, + vars = HEAT_FLUX()) +exp16$scenario <- "Hector - NMAE w/ unc, incl. OHC \nTuning S, Alpha" + +# Calculating OHC RMSE +all_exp <- list(default_data, + exp5_9A, exp5B, exp6B, exp8B, exp9B, # NMSEs + exp10A, exp10B, # Add S + exp11A, exp11B, # Add alpha + exp12, # Add OHC, Mat Diff + exp13, # Try MVSSE + exp14A, exp14B, # Try remove S + exp15, exp16) # Try MAE/NMAE + +# TODO: clean up this output sorry +sapply(all_exp, get_var_mse_unc, + obs_data = obs_data, var = "OHC", yrs = 1957:2014, mse_fn = mse_unc) + diff --git a/scripts/other/ohc_comparison.R b/scripts/other/ohc_comparison.R index ed17473..219a006 100644 --- a/scripts/other/ohc_comparison.R +++ b/scripts/other/ohc_comparison.R @@ -8,6 +8,7 @@ # Importing libraries library(hector) library(ggplot2) +theme_set(theme_bw(base_size = 20)) # Setting up file paths COMP_DATA_DIR <- file.path(here::here(), "comparison_data") @@ -157,10 +158,10 @@ ohc_optim_data <- calc_ohc(PARAMS, c(0.65, 1.76, 1.04, 2.33, 0.44), include_unc= nmae_ohc_optim_data <- calc_ohc(PARAMS, c(0.59, 1.76, 1.04, 2.17, 0.411), include_unc= T) default_data$scenario <- "Hector - Default" -reg_box_data$scenario <- "Hector - All Params, Reg Box" -low_diff_data$scenario <- "Hector - All Params, Reg Box, Diff = 1.1" -ohc_optim_data$scenario <- "Hector - All Params, Reg Box, Matilda Diff, Optimize for OHC" -nmae_ohc_optim_data$scenario <- "Hector - All Params, Reg Box, Matilda Diff, Optimize for OHC w/ NMAE" +reg_box_data$scenario <- "Hector - Old Diff Range, \nNo OHC Optimization" +low_diff_data$scenario <- "Hector - Diff = 1.1, \nNo OHC Optimization" +ohc_optim_data$scenario <- "Hector - Matilda Diff, \nOptimize for OHC" +nmae_ohc_optim_data$scenario <- "Hector - Matilda Diff, \nOptimize for OHC w/ NMAE" comb_data <- rbind(obs_data, default_data, reg_box_data, low_diff_data, ohc_optim_data, nmae_ohc_optim_data) @@ -172,5 +173,6 @@ ggplot(data = comb_data, aes(x = year, y = value, color = scenario)) + color = NA) + geom_line() + facet_wrap(~ variable, scales = "free") + - ggtitle("Comparing Parameterizations") + ggtitle("Comparing Parameterizations") + + theme(legend.text = element_text(size = 15), legend.key.height = unit(2, "cm")) ggsave(OUTPUT, width = 15) \ No newline at end of file