Skip to content

Commit 87d6dcb

Browse files
committed
Add CO2 emissions forcing for esm-hist
* Include aircraft emissions * Fix a function name * Fix a filepath * Read years 1849 and 2023 directly from the datasets
1 parent 7b5a283 commit 87d6dcb

File tree

5 files changed

+127
-18
lines changed

5 files changed

+127
-18
lines changed

CMIP7/esm1p6/atmosphere/aerosol/cmip7_HI_aerosol_anthro.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from aerosol.cmip7_aerosol_anthro import (
55
cmip7_aerosol_anthro_interpolate,
6+
load_cmip7_aerosol_air_anthro_list,
67
load_cmip7_aerosol_anthro_list,
78
)
89
from aerosol.cmip7_HI_aerosol import (
@@ -27,6 +28,20 @@ def parse_args(species):
2728
return parser.parse_args()
2829

2930

31+
def load_cmip7_hi_aerosol_air_anthro(
32+
args,
33+
species,
34+
beg_year=CMIP7_HI_BEG_YEAR,
35+
end_year=CMIP7_HI_END_YEAR,
36+
):
37+
return load_cmip7_aerosol_air_anthro_list(
38+
args,
39+
species,
40+
args.dataset_date_range_list,
41+
cmip7_date_constraint_from_years(beg_year, end_year),
42+
)
43+
44+
3045
def load_cmip7_hi_aerosol_anthro(
3146
args,
3247
species,

CMIP7/esm1p6/atmosphere/aerosol/cmip7_aerosol_anthro.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ def cmip7_aerosol_anthro_rootpath(args):
2424
)
2525

2626

27+
def cmip7_aerosol_air_anthro_filepath(args, species, date_range):
28+
rootpath = cmip7_aerosol_anthro_rootpath(args)
29+
filename = (
30+
f"{species}-em-AIR-anthro_input4MIPs_emissions_CMIP_"
31+
f"{args.dataset_version}_gn_"
32+
f"{date_range}.nc"
33+
)
34+
return (
35+
rootpath
36+
/ f"{species}_em_AIR_anthro"
37+
/ "gn"
38+
/ args.dataset_vdate
39+
/ filename
40+
)
41+
42+
2743
def cmip7_aerosol_anthro_filepath(args, species, date_range):
2844
rootpath = cmip7_aerosol_anthro_rootpath(args)
2945
filename = (
@@ -36,13 +52,6 @@ def cmip7_aerosol_anthro_filepath(args, species, date_range):
3652
)
3753

3854

39-
def cmip7_aerosol_anthro_filepath_list(args, species, date_range_list):
40-
return [
41-
cmip7_aerosol_anthro_filepath(args, species, date_range)
42-
for date_range in date_range_list
43-
]
44-
45-
4655
def load_cmip7_aerosol_anthro(args, species, date_range, constraint):
4756
cube = load_cmip7_aerosol(
4857
args, cmip7_aerosol_anthro_filepath, species, date_range, constraint
@@ -51,10 +60,24 @@ def load_cmip7_aerosol_anthro(args, species, date_range, constraint):
5160
return cube
5261

5362

63+
def load_cmip7_aerosol_air_anthro_list(
64+
args, species, date_range_list, constraint
65+
):
66+
cube = load_cmip7_aerosol_list(
67+
args,
68+
cmip7_aerosol_air_anthro_filepath,
69+
species,
70+
date_range_list,
71+
constraint,
72+
)
73+
fix_coords(args, cube)
74+
return cube
75+
76+
5477
def load_cmip7_aerosol_anthro_list(args, species, date_range_list, constraint):
5578
cube = load_cmip7_aerosol_list(
5679
args,
57-
cmip7_aerosol_anthro_filepath_list,
80+
cmip7_aerosol_anthro_filepath,
5881
species,
5982
date_range_list,
6083
constraint,

CMIP7/esm1p6/atmosphere/aerosol/cmip7_aerosol_biomass.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ def cmip7_aerosol_biomass_filepath(args, species, date_range):
3636
return rootpath / species / "gn" / args.dataset_vdate / filename
3737

3838

39-
def cmip7_aerosol_biomass_filepath_list(args, species, date_range_list):
40-
return [
41-
cmip7_aerosol_biomass_filepath(args, species, date_range)
42-
for date_range in date_range_list
43-
]
44-
45-
4639
def load_cmip7_aerosol_biomass(args, species, date_range, constraint):
4740
cube = load_cmip7_aerosol(
4841
args, cmip7_aerosol_biomass_filepath, species, date_range, constraint
@@ -56,7 +49,7 @@ def load_cmip7_aerosol_biomass(args, species, date_range, constraint):
5649
def load_cmip7_aerosol_biomass_list(args, species, date_range_list, constraint):
5750
cube = load_cmip7_aerosol_list(
5851
args,
59-
cmip7_aerosol_biomass_filepath_list,
52+
cmip7_aerosol_biomass_filepath,
6053
species,
6154
date_range_list,
6255
constraint,

CMIP7/esm1p6/atmosphere/aerosol/cmip7_aerosol_common.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ def load_cmip7_aerosol(args, filepath_fn, species, date_range, constraint):
88
return cube
99

1010

11+
def cmip7_aerosol_filepath_list(args, filepath_fn, species, date_range_list):
12+
return [
13+
filepath_fn(args, species, date_range) for date_range in date_range_list
14+
]
15+
16+
1117
def load_cmip7_aerosol_list(
12-
args, filepath_list_fn, species, date_range_list, constraint
18+
args, filepath_fn, species, date_range_list, constraint
1319
):
14-
filepath_list = filepath_list_fn(args, species, date_range_list)
20+
filepath_list = cmip7_aerosol_filepath_list(
21+
args, filepath_fn, species, date_range_list
22+
)
1523
cube_list = iris.load_raw(filepath_list, constraint)
1624
equalise_attributes(cube_list)
1725
unify_time_units(cube_list)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Interpolate CMIP7 EH CO2 emissions to ESM1.6 grid
2+
from pathlib import Path
3+
4+
import iris
5+
from aerosol.cmip7_aerosol_common import zero_poles
6+
from aerosol.cmip7_HI_aerosol_anthro import (
7+
load_cmip7_hi_aerosol_air_anthro,
8+
load_cmip7_hi_aerosol_anthro,
9+
parse_args,
10+
)
11+
from cmip7_ancil_common import (
12+
INTERPOLATION_SCHEME,
13+
esm_grid_mask_cube,
14+
save_ancil,
15+
)
16+
from cmip7_ancil_constants import ANCIL_TODAY
17+
from cmip7_HI import CMIP7_HI_BEG_YEAR, CMIP7_HI_END_YEAR
18+
19+
SPECIES = "CO2"
20+
STASH_ITEM = 251
21+
# The CO2 time series includes 1849 and 2023,
22+
# so use these years directly from the datasets.
23+
CMIP7_HI_CO2_BEG_YEAR = CMIP7_HI_BEG_YEAR - 1
24+
CMIP7_HI_CO2_END_YEAR = CMIP7_HI_END_YEAR + 1
25+
26+
27+
def esm_eh_co2_save_dirpath(args):
28+
return (
29+
Path(args.ancil_target_dirname)
30+
/ "modern"
31+
/ "historical-emissions"
32+
/ "atmosphere"
33+
/ "forcing"
34+
/ args.esm_grid_rel_dirname
35+
/ ANCIL_TODAY
36+
)
37+
38+
39+
def cmip7_eh_co2_anthro_interpolate(args):
40+
cube = load_cmip7_hi_aerosol_anthro(
41+
args,
42+
SPECIES,
43+
beg_year=CMIP7_HI_CO2_BEG_YEAR,
44+
end_year=CMIP7_HI_CO2_END_YEAR,
45+
)
46+
cube_sum = cube.collapsed(["sector"], iris.analysis.SUM)
47+
cube_air = load_cmip7_hi_aerosol_air_anthro(
48+
args,
49+
SPECIES,
50+
beg_year=CMIP7_HI_CO2_BEG_YEAR,
51+
end_year=CMIP7_HI_CO2_END_YEAR,
52+
)
53+
cube_air_sum = cube_air.collapsed(["altitude"], iris.analysis.SUM)
54+
cube_tot = cube_sum + cube_air_sum
55+
56+
esm_cube = cube_tot.regrid(esm_grid_mask_cube(args), INTERPOLATION_SCHEME)
57+
esm_cube.data = esm_cube.data.filled(0.0)
58+
zero_poles(esm_cube)
59+
esm_cube.attributes["STASH"] = iris.fileformats.pp.STASH(
60+
model=1, section=0, item=STASH_ITEM
61+
)
62+
63+
save_dirpath = esm_eh_co2_save_dirpath(args)
64+
save_ancil(esm_cube, save_dirpath, args.save_filename)
65+
66+
67+
if __name__ == "__main__":
68+
args = parse_args(species=SPECIES)
69+
70+
cmip7_eh_co2_anthro_interpolate(args)

0 commit comments

Comments
 (0)