Skip to content

Commit

Permalink
tried fixing S but not alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrscll committed Jun 25, 2024
1 parent 1ae22d4 commit f943710
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
46 changes: 46 additions & 0 deletions results/14_alpha_ohc_unc_nmse.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
parameters values
beta 0.732
q10_rh 1.76
diff 1.042
alpha 0.61285349058506

Objective Function Value: 5.85e-05
Counts: 13
Counts: 13
Convergence: 0
Messages: CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH

CO2 MSE: 27.1
T MSE: 0.0134
RMSE: 5.2
T MSE accounting for unc: 0.00301
OHC MSE accounting for unc: 29.6

***Key Metrics***
TCRE: 1.55
TCR: 2

***Historical Warming and ERF***
GSAT Warming: 1.04
Ocean Heat Content Change: 451
Total Aerosol ERF: -1.24
WMGHG ERF: 3.69
Methane ERF: 0.546

***Future Warming***
scenario start end GSAT
ssp119 2021 2040 0.678
ssp119 2041 2060 0.721
ssp119 2081 2100 0.389
ssp126 2021 2040 0.71
ssp126 2041 2060 0.947
ssp126 2081 2100 0.787
ssp245 2021 2040 0.758
ssp245 2041 2060 1.27
ssp245 2081 2100 1.84
ssp370 2021 2040 0.8
ssp370 2041 2060 1.51
ssp370 2081 2100 3.08
ssp585 2021 2040 0.88
ssp585 2041 2060 1.77
ssp585 2081 2100 3.91
46 changes: 46 additions & 0 deletions results/14_alpha_ohc_unc_nmse_big_box.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
parameters values
beta 0.903540335704792
q10_rh 0.88
diff 0.806
alpha 0.459527640832312

Objective Function Value: 4.63e-05
Counts: 31
Counts: 31
Convergence: 0
Messages: CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH

CO2 MSE: 119
T MSE: 0.0125
RMSE: 10.9
T MSE accounting for unc: 0.00248
OHC MSE accounting for unc: 0.529

***Key Metrics***
TCRE: 1.24
TCR: 2.07

***Historical Warming and ERF***
GSAT Warming: 1.08
Ocean Heat Content Change: 413
Total Aerosol ERF: -1.24
WMGHG ERF: 3.39
Methane ERF: 0.546

***Future Warming***
scenario start end GSAT
ssp119 2021 2040 0.549
ssp119 2041 2060 0.464
ssp119 2081 2100 0.0238
ssp126 2021 2040 0.588
ssp126 2041 2060 0.702
ssp126 2081 2100 0.384
ssp245 2021 2040 0.655
ssp245 2041 2060 1.06
ssp245 2081 2100 1.42
ssp370 2021 2040 0.712
ssp370 2041 2060 1.34
ssp370 2081 2100 2.7
ssp585 2021 2040 0.77
ssp585 2041 2060 1.57
ssp585 2081 2100 3.48
88 changes: 88 additions & 0 deletions scripts/alpha_fix_S_ohc_unc_nmse.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Script for experiment 14
# Script to use normalized T, OHC and CO2 MSEs while accounting for T, OHC unc
# Also includes alpha as param to optimize over (but ECS is fixed at 3)
# Uses OHC range from Matilda table rather than manuscript script
# Author: Peter Scully
# Date: 6/25/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")

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(), AERO_SCALE())

OUTPUT <- file.path(RESULTS_DIR, "14_alpha_ohc_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)
ohc_data <- get_ohc_data(OHC_PATH, include_unc = T)
obs_data <- rbind(co2_data, temp_data, ohc_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, 1.16 - 0.118 * 3, 0),
upper = c(0.5 + 0.232 * 3, 2.2 + 0.44 * 3, 1.16 + 0.118 * 3, 3),
yrs = 1750:2014,
vars = c(GMST(), CONCENTRATIONS_CO2(), HEAT_FLUX()),
error_fn = mean_T_CO2_OHC_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(), HEAT_FLUX()))

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)
OHC_mse_unc <- get_var_mse_unc(obs_data = obs_data,
hector_data = hector_data,
var = "OHC",
yrs = 1957: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_metric("OHC MSE accounting for unc:", OHC_mse_unc, OUTPUT)
write("", OUTPUT, append = TRUE)

### Outputting table metrics ###
calc_table_metrics(PARAMS, best_pars, OUTPUT)

0 comments on commit f943710

Please sign in to comment.