diff --git a/results/ecs_initial_comparison_plots.jpeg b/results/ecs_initial_comparison_plots.jpeg new file mode 100644 index 0000000..8d52e85 Binary files /dev/null and b/results/ecs_initial_comparison_plots.jpeg differ diff --git a/results/ecs_unc_nmse.txt b/results/ecs_unc_nmse.txt new file mode 100644 index 0000000..1a31618 --- /dev/null +++ b/results/ecs_unc_nmse.txt @@ -0,0 +1,45 @@ +parameters values +beta 0.732 +q10_rh 2.23750367260462 +diff 2.4 +S 5 + +Objective Function Value: 0.00057 +Counts: 50 +Counts: 50 +Convergence: 0 +Messages: CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH + +CO2 MSE: 44.5 +T MSE: 0.0542 +RMSE: 6.67 +T MSE accounting for unc: 0.0214 + +***Key Metrics*** +TCRE: 2.29 +TCR: 2.32 + +***Historical Warming and ERF*** +GSAT Warming: 0.837 +Ocean Heat Content Change: 533 +Total Aerosol ERF: -1.24 +WMGHG ERF: 3.66 +Methane ERF: 0.541 + +***Future Warming*** +scenario start end GSAT +ssp119 2021 2040 0.94 +ssp119 2041 2060 1.24 +ssp119 2081 2100 1.23 +ssp126 2021 2040 0.956 +ssp126 2041 2060 1.46 +ssp126 2081 2100 1.71 +ssp245 2021 2040 0.962 +ssp245 2041 2060 1.7 +ssp245 2081 2100 2.8 +ssp370 2021 2040 0.972 +ssp370 2041 2060 1.86 +ssp370 2081 2100 3.99 +ssp585 2021 2040 1.11 +ssp585 2041 2060 2.26 +ssp585 2081 2100 5.11 diff --git a/results/ecs_unc_nmse_big_box.txt b/results/ecs_unc_nmse_big_box.txt new file mode 100644 index 0000000..cf393d1 --- /dev/null +++ b/results/ecs_unc_nmse_big_box.txt @@ -0,0 +1,45 @@ +parameters values +beta 1.06933813506042 +q10_rh 3.52 +diff 2 +S 5 + +Objective Function Value: 0.000408 +Counts: 16 +Counts: 16 +Convergence: 0 +Messages: CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH + +CO2 MSE: 228 +T MSE: 0.0422 +RMSE: 15.1 +T MSE accounting for unc: 0.0151 + +***Key Metrics*** +TCRE: 2.41 +TCR: 2.42 + +***Historical Warming and ERF*** +GSAT Warming: 0.702 +Ocean Heat Content Change: 436 +Total Aerosol ERF: -1.24 +WMGHG ERF: 3.35 +Methane ERF: 0.538 + +***Future Warming*** +scenario start end GSAT +ssp119 2021 2040 0.911 +ssp119 2041 2060 1.17 +ssp119 2081 2100 1.17 +ssp126 2021 2040 0.927 +ssp126 2041 2060 1.39 +ssp126 2081 2100 1.62 +ssp245 2021 2040 0.933 +ssp245 2041 2060 1.64 +ssp245 2081 2100 2.72 +ssp370 2021 2040 0.943 +ssp370 2041 2060 1.8 +ssp370 2081 2100 3.96 +ssp585 2021 2040 1.09 +ssp585 2041 2060 2.23 +ssp585 2081 2100 5.15 diff --git a/scripts/ecs_unc_nmse.R b/scripts/ecs_unc_nmse.R new file mode 100644 index 0000000..1bf31ce --- /dev/null +++ b/scripts/ecs_unc_nmse.R @@ -0,0 +1,76 @@ +# Script to use normalized the T and CO2 MSEs while accounting for T uncertainty +# Also includes ECS as a param to optimize over +# Author: Peter Scully +# Date: 6/20/24 + +### Constants and Imports ### + +# Importing libraries +library(hector) + +# 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()) + +OUTPUT <- file.path(RESULTS_DIR, "ecs_unc_nmse_big_box.txt") + + +source(file.path(SCRIPTS_DIR, "major_functions.R")) + +### Getting observational data ### +co2_data <- get_co2_data(CO2_PATH, include_unc = TRUE) +temp_data <- get_temp_data(TEMP_PATH, include_unc = TRUE) +obs_data <- rbind(co2_data, temp_data) + +### Calling optim ### +best_pars <- run_optim(obs_data = obs_data, + ini_file = INI_FILE, + params = PARAMS, + lower = c(0, 2.2 - 0.44 * 3, 2.3 - 0.1 * 3, 2), + upper = c(0.5 + 0.232 * 3, 2.2 + 0.44 * 3, 2.3 + 0.1 * 3, 5), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2()), + error_fn = mean_T_CO2_nmse_unc, + include_unc = T, + method = "L-BFGS-B", + output_file = OUTPUT) + +### Outputting individual MSEs ### +hector_data <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = best_pars, + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) + +T_mse <- get_var_mse(obs_data = obs_data, + hector_data = hector_data, + var = GMST(), + yrs = 1850:2014) +CO2_mse <- get_var_mse(obs_data = obs_data, + hector_data = hector_data, + var = CONCENTRATIONS_CO2(), + yrs = c(1750, 1850:2014)) +T_mse_unc <- get_var_mse_unc(obs_data = obs_data, + hector_data = hector_data, + var = GMST(), + yrs = 1850:2014, + mse_fn = mse_unc) + +write_metric("CO2 MSE:", CO2_mse, OUTPUT) +write_metric("T MSE: ", T_mse, OUTPUT) +write_metric("RMSE: ", sqrt(mean(CO2_mse, T_mse)), OUTPUT) # not 100% sure this is how we want to calculate this +write_metric("T MSE accounting for unc:", T_mse_unc, OUTPUT) +write("", OUTPUT, append = TRUE) + +### Outputting table metrics ### +calc_table_metrics(PARAMS, best_pars, OUTPUT) \ No newline at end of file diff --git a/scripts/graph_comparison_plots.R b/scripts/graph_comparison_plots.R index a0ee210..96ae0f5 100644 --- a/scripts/graph_comparison_plots.R +++ b/scripts/graph_comparison_plots.R @@ -20,9 +20,9 @@ TEMP_PATH <- "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()) +PARAMS <- c(BETA(), Q10_RH(), DIFFUSIVITY(), ECS()) -OUTPUT <- file.path(RESULTS_DIR, "nmse_box_comparison_plots.jpeg") +OUTPUT <- file.path(RESULTS_DIR, "ecs_initial_comparison_plots.jpeg") source(file.path(SCRIPTS_DIR, "major_functions.R")) @@ -47,27 +47,34 @@ default_data$scenario <- "Hector - Default Fit" nmse_data <- run_hector(ini_file = INI_FILE, params = PARAMS, - vals = c(0.732, 2.64, 2.4), + vals = c(0.732, 2.64, 2.4, 3), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -nmse_data$scenario <- "Hector - Fit to NMSEs" +nmse_data$scenario <- "Hector - Fit to NMSEs w/ unc" nmse_bb_data <- run_hector(ini_file = INI_FILE, params = PARAMS, - vals = c(1.196, 3.52, 2), + vals = c(1.084, 3.52, 2, 3), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -nmse_bb_data$scenario <- "Hector - Fit to NMSEs, Big Box" +nmse_bb_data$scenario <- "Hector - Fit to NMSEs w/ unc, big box" -nmse_bb_smooth_data <- run_hector(ini_file = INI_FILE, +nmse_ecs_data <- run_hector(ini_file = INI_FILE, params = PARAMS, - vals = c(1.147, 3.52, 2), + vals = c(0.732, 2.24, 2.4, 5), yrs = 1750:2014, vars = c(GMST(), CONCENTRATIONS_CO2())) -nmse_bb_smooth_data$scenario <- "Hector - NMSEs, Big Box, Smoothed" +nmse_ecs_data$scenario <- "Hector - NMSEs w/ unc & Tuning S" -hector_data <- rbind(default_data, nmse_data, nmse_bb_data, nmse_bb_smooth_data) +nmse_bb_ecs_data <- run_hector(ini_file = INI_FILE, + params = PARAMS, + vals = c(1.069, 3.52, 2, 5), + yrs = 1750:2014, + vars = c(GMST(), CONCENTRATIONS_CO2())) +nmse_bb_ecs_data$scenario <- "Hector - NMSEs w/ unc, big box & Tuning S" + +hector_data <- rbind(default_data, nmse_data, nmse_bb_data, nmse_ecs_data, nmse_bb_ecs_data) hector_data$lower <- hector_data$value hector_data$upper <- hector_data$value