Skip to content

Commit

Permalink
Add NMVOC into BB4CMIP processing
Browse files Browse the repository at this point in the history
  • Loading branch information
znichollscr committed Jan 9, 2025
1 parent 5379e14 commit 3e503b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
19 changes: 8 additions & 11 deletions notebooks/0103_GFED4-BB4CMIP-prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@
"unit_label": "Mt BC / yr",
"filename_label": "BC",
},
# TODO: check with Chris where this is mean to come from.
# There is no NMVOC_bulk in BB4CMIP.
# Maybe Higher_Alkenes?
# "NMVOC": {
# "unit_label": "Mt NMVOC / yr",
# "filename_label": "NMVOC_bulk",
# },
"NMVOC": {
"unit_label": "Mt NMVOC / yr",
"filename_label": "NMVOC_bulk",
},
"CO": {
"unit_label": "Mt CO / yr",
"filename_label": "CO",
Expand Down Expand Up @@ -167,7 +164,7 @@ def gfed_to_scmrun(in_da: xr.DataArray, *, unit_label: str, world: bool = False)

# %%
gfed_processed_output_dir.mkdir(exist_ok=True, parents=True)
for species in tqdm(species_data, desc="Species"):
for species, species_info in tqdm(species_data.items(), desc="Species"):
species_ds = xr.open_mfdataset(bb4cmip_file_groups[species], combine_attrs="drop_conflicts").rename(
{"latitude": "lat", "longitude": "lon"}
)
Expand Down Expand Up @@ -222,8 +219,8 @@ def gfed_to_scmrun(in_da: xr.DataArray, *, unit_label: str, world: bool = False)
country_emissions = ((regridded_annual_emissions_rate * cell_area * idxr).sum(["lat", "lon"])).compute() / 1e9
world_emissions = (regridded_annual_emissions_rate * cell_area).sum(["lat", "lon"]).compute() / 1e9

out_world_chunk = gfed_to_scmrun(world_emissions, unit_label=species_data[species]["unit_label"], world=True)
out_country_chunk = gfed_to_scmrun(country_emissions, unit_label=species_data[species]["unit_label"])
out_world_chunk = gfed_to_scmrun(world_emissions, unit_label=species_info["unit_label"], world=True)
out_country_chunk = gfed_to_scmrun(country_emissions, unit_label=species_info["unit_label"])

out_world_l.append(out_world_chunk)
out_country_l.append(out_country_chunk)
Expand All @@ -236,7 +233,7 @@ def gfed_to_scmrun(in_da: xr.DataArray, *, unit_label: str, world: bool = False)
for original_file in bb4cmip_file_groups[species]:
orig_ds = xr.open_dataset(original_file)
timerange = original_file.stem.split("_")[-1].split("-")
compare_unit = species_data[species]["unit_label"].replace("Mt", "Tg")
compare_unit = species_info["unit_label"].replace("Mt", "Tg")

for i, timestamp in enumerate(timerange):
year = int(timestamp[:4])
Expand Down
4 changes: 1 addition & 3 deletions notebooks/0104_GFED-BB4CMIP-postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
# %%
species = [
"BC",
# # Not sure where this is meant to come from yet,
# # see note in 0103
# "NMVOC",
"NMVOC",
"CO",
"CO2",
"CH4",
Expand Down

0 comments on commit 3e503b8

Please sign in to comment.