Skip to content

Commit 8c13760

Browse files
author
JMGilbert
committed
Add ssp gdp timeseries and make compatible with new configs
1 parent 4c27340 commit 8c13760

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

dscim/diagnostics/var_timeseries.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def get_ssp_id(
9494
output,
9595
results_root,
9696
discrate=0.02,
97+
pulse_year=2020,
9798
):
9899

99100
sccs = (
@@ -142,6 +143,7 @@ def rff_timeseries(
142143
output,
143144
config,
144145
runid_root,
146+
USA,
145147
discrate=0.02,
146148
pulse_year=2020,
147149
):
@@ -213,23 +215,24 @@ def rff_timeseries(
213215
# gmst
214216
with open(config) as config_file:
215217
params = yaml.full_load(config_file)
216-
params["climate"].update(
218+
params["rff_climate"].update(
217219
{
218-
"gmst_fair_path": "/shares/gcp/integration/rff2/climate/ar6_rff_fair162_control_pulse_all_gases_2020-2030-2040-2050-2060-2070-2080_emis_conc_rf_temp_lambdaeff_ohc_emissions-driven_naturalfix_v5.03_Feb072022.nc"
220+
"gmst_fair_path": "/shares/gcp/integration/rff2/climate/ar6_rff_fair162_control_pulse_all_gases_2020-2030-2040-2050-2060-2070-2080_emis_conc_rf_temp_lambdaeff_ohc_emissions-driven_naturalfix_v5.03_Feb072022.nc",
221+
"pulse_year": pulse_year,
219222
}
220223
)
221224
gmst = (
222-
Climate(**params["climate"])
225+
Climate(**params["rff_climate"])
223226
.fair_pulse.temperature.sel(gas=gas, drop=True)
224227
.rename("gmst")
225228
)
226229
gmst_pulse = (
227-
Climate(**params["climate"])
230+
Climate(**params["rff_climate"])
228231
.fair_pulse.temperature.sel(gas=gas, drop=True)
229232
.rename("gmst")
230233
)
231234
gmst_control = (
232-
Climate(**params["climate"])
235+
Climate(**params["rff_climate"])
233236
.fair_control.temperature.sel(gas=gas, drop=True)
234237
.rename("gmst")
235238
)
@@ -239,14 +242,15 @@ def rff_timeseries(
239242
)
240243

241244
# gdp
242-
gdp = (
243-
xr.open_dataset(
245+
if USA:
246+
gdp = xr.open_dataset(
247+
"/shares/gcp/integration_replication/inputs/econ/rff_USA_socioeconomics.nc4"
248+
)
249+
else:
250+
gdp = xr.open_dataset(
244251
"/shares/gcp/integration_replication/inputs/econ/rff_global_socioeconomics.nc4"
245252
)
246-
.drop("region")
247-
.rename({"runid": "rff_sp"})
248-
.gdp.sel(rff_sp=cw.rff_sp)
249-
)
253+
gdp = gdp.drop("region").rename({"runid": "rff_sp"}).gdp.sel(rff_sp=cw.rff_sp)
250254

251255
data = xr.combine_by_coords(
252256
[
@@ -402,10 +406,16 @@ def ssp_timeseries(
402406
# gmst
403407
with open(config) as config_file:
404408
params = yaml.full_load(config_file)
409+
params["AR6_ssp_climate"].update({"pulse_year": pulse_year})
410+
411+
# gdp
412+
gdp = xr.open_dataset(
413+
f"{results_root}/{recipe}_{disc}_eta{eta}_rho{rho}_global_consumption.nc4"
414+
).__xarray_dataarray_variable__.rename("gdp")
405415

406416
anom_var = "gmsl" if "coastal" in sector else "temperature"
407417

408-
anomaly = Climate(**params["climate"]).fair_pulse[anom_var]
418+
anomaly = Climate(**params["AR6_ssp_climate"]).fair_pulse[anom_var]
409419

410420
if "coastal" not in sector:
411421
anomaly = anomaly.sel(gas=gas, drop=True)
@@ -421,6 +431,7 @@ def ssp_timeseries(
421431
emissions,
422432
c_emissions,
423433
anomaly,
434+
gdp,
424435
]
425436
]
426437
)
@@ -443,6 +454,7 @@ def ssp_timeseries(
443454
"marginal_damages",
444455
"discount_factors",
445456
"discounted_damages",
457+
"gdp",
446458
]
447459
):
448460

0 commit comments

Comments
 (0)