-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from kdorheim/weighted_mse
Tried weighting MSEs
- Loading branch information
Showing
8 changed files
with
233 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
parameters values | ||
beta 0.732 | ||
q10_rh 2.64 | ||
diff 2.4 | ||
|
||
Objective Function Value: 0.00173 | ||
|
||
CO2 MSE: 58.5 | ||
T MSE: 0.0651 | ||
RMSE: 7.65 | ||
|
||
***Key Metrics*** | ||
TCRE: 1.53 | ||
TCR: 1.76 | ||
|
||
***Historical Warming and ERF*** | ||
GSAT Warming: 0.633 | ||
Ocean Heat Content Change: 423 | ||
Total Aerosol ERF: -1.24 | ||
WMGHG ERF: 3.63 | ||
Methane ERF: 0.538 | ||
|
||
***Future Warming*** | ||
scenario start end GSAT | ||
ssp119 2021 2040 0.694 | ||
ssp119 2041 2060 0.842 | ||
ssp119 2081 2100 0.693 | ||
ssp126 2021 2040 0.709 | ||
ssp126 2041 2060 1.02 | ||
ssp126 2081 2100 1.05 | ||
ssp245 2021 2040 0.715 | ||
ssp245 2041 2060 1.23 | ||
ssp245 2081 2100 1.9 | ||
ssp370 2021 2040 0.725 | ||
ssp370 2041 2060 1.37 | ||
ssp370 2081 2100 2.86 | ||
ssp585 2021 2040 0.842 | ||
ssp585 2041 2060 1.68 | ||
ssp585 2081 2100 3.71 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Script to compare plots that use different hector variables | ||
# Author: Peter Scully | ||
# Date: 6/13/24 | ||
|
||
### Constants and Imports ### | ||
|
||
# Importing libraries | ||
library(hector) | ||
library(ggplot2) | ||
|
||
# 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()) | ||
|
||
OUTPUT <- file.path(RESULTS_DIR, "comparison_plots.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_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" | ||
|
||
nmse_data <- run_hector(ini_file = INI_FILE, | ||
params = PARAMS, | ||
vals = c(0.732, 2.64, 2.4), | ||
yrs = 1750:2014, | ||
vars = c(GMST(), CONCENTRATIONS_CO2())) | ||
nmse_data$scenario <- "Hector - Fit to NMSEs" | ||
|
||
hector_data <- rbind(default_data, nmse_data) | ||
hector_data$lower <- hector_data$value | ||
hector_data$upper <- hector_data$value | ||
|
||
comb_data <- rbind(obs_data, hector_data) | ||
|
||
ggplot(data = comb_data, aes(x = year, y = value, color = scenario)) + | ||
geom_ribbon(data = | ||
filter(comb_data, scenario == "historical" & variable == GMST()), | ||
aes(ymin = lower, ymax = upper), | ||
fill = 'aquamarine1', | ||
color = NA) + | ||
geom_line() + | ||
facet_wrap(~ variable, scales = "free") + | ||
ggtitle("Comparing Parameterizations") | ||
ggsave(OUTPUT, width = 15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Script to try normalizing the T and CO2 MSEs | ||
# manuscript | ||
# Author: Peter Scully | ||
# Date: 6/13/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()) | ||
|
||
OUTPUT <- file.path(RESULTS_DIR, "initial_norm_exp.txt") | ||
|
||
|
||
source(file.path(SCRIPTS_DIR, "major_functions.R")) | ||
|
||
### Getting observational data ### | ||
co2_data <- get_co2_data(CO2_PATH) | ||
temp_data <- get_temp_data(TEMP_PATH) | ||
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.5 - 0.232, 2.2 - 0.44, 2.3 - 0.1), | ||
upper = c(0.5 + 0.232, 2.2 + 0.44, 2.3 + 0.1), | ||
yrs = 1750:2014, | ||
vars = c(GMST(), CONCENTRATIONS_CO2()), | ||
error_fn = mean_T_CO2_nmse, | ||
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)) | ||
|
||
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("", OUTPUT, append = TRUE) | ||
|
||
### Outputting table metrics ### | ||
calc_table_metrics(PARAMS, best_pars, OUTPUT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters