Skip to content

Commit 50b8a36

Browse files
authored
Merge pull request #13 from ihmeuw/feature/rmbarber/gbd2025-preprocess-raking
update preprocess functionality to run for GBD2025 (mostly updates fo…
2 parents 81f88bf + 3e56abd commit 50b8a36

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

src/rra_population_model/postprocess/raking_factors/runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def load_admin_populations(
3131
year, quarter = (int(s) for s in time_point.split("q"))
3232
if RAKING_VERSION == "gbd_2023":
3333
next_year = min(year + 1, 2024)
34+
elif RAKING_VERSION == "gbd_2025":
35+
next_year = min(year + 1, 2026)
3436
else:
3537
next_year = min(year + 1, 2100)
3638
weight = (int(quarter) - 1) / 4

src/rra_population_model/preprocess/raking_data/metadata.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class SUPPLEMENT:
9292
ZERO_POPULATION = "zero_population"
9393

9494

95-
def load_supplmental_metadata() -> pd.DataFrame:
96-
return pd.DataFrame(
95+
def load_supplmental_metadata(gbd_version: str) -> pd.DataFrame:
96+
supplmental_metadata = pd.DataFrame(
9797
[
9898
# This is a manual mapping of locations not present in the GBD hierarchy to the
9999
# GBD region in which they reside. We grab the additional iso3 and location name
@@ -345,3 +345,20 @@ def load_supplmental_metadata() -> pd.DataFrame:
345345
"category",
346346
],
347347
)
348+
349+
if gbd_version == "2025":
350+
# added French data in GBD 2025
351+
is_fra_admin0 = supplmental_metadata["location_id"].isin(
352+
[
353+
338, # French Guiana
354+
350, # Guadaloupe
355+
363, # Martinique
356+
364, # Mayotte
357+
387, # Reunion
358+
]
359+
)
360+
supplmental_metadata = supplmental_metadata.loc[~is_fra_admin0].reset_index(
361+
drop=True
362+
)
363+
364+
return supplmental_metadata

src/rra_population_model/preprocess/raking_data/runner.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ def raking_data_main(
2626
hierarchies = utils.load_hierarchies(pm_data, gbd_version=gbd_version)
2727
populations = utils.load_ihme_populations(pm_data, gbd_version=gbd_version)
2828
shapes = utils.load_shapes(pm_data, gbd_version=gbd_version)
29-
supplemental_metadata = load_supplmental_metadata()
29+
supplemental_metadata = load_supplmental_metadata(gbd_version=gbd_version)
3030

3131
print("Building WPP data...")
32-
wpp_version = "2024" if out_version == "gbd_2023" else "2022"
33-
wpp = utils.load_wpp_populations(pm_data, wpp_version=wpp_version)
32+
wpp_version = "2022" if out_version in ["gbd_2021", "fhs_2021"] else "2024"
33+
wpp = utils.load_wpp_populations(
34+
pm_data, wpp_version=wpp_version, gbd_version=gbd_version
35+
)
3436
# Add GBD location and region ids to the WPP data by mapping on iso3 codes
3537
wpp = utils.add_gbd_metadata_to_wpp(
3638
wpp=wpp,
@@ -86,7 +88,9 @@ def raking_data_main(
8688
@click.command()
8789
@clio.with_output_directory(pmc.MODEL_ROOT)
8890
@clio.with_choice(
89-
"out_version", allow_all=False, choices=["gbd_2023", "gbd_2021", "fhs_2021"]
91+
"out_version",
92+
allow_all=False,
93+
choices=["gbd_2025", "gbd_2023", "gbd_2021", "fhs_2021"],
9094
)
9195
def raking_data(
9296
output_dir: str,

src/rra_population_model/preprocess/raking_data/utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
def load_wpp_populations(
21-
pm_data: PopulationModelData, wpp_version: str
21+
pm_data: PopulationModelData, wpp_version: str, gbd_version: str
2222
) -> pd.DataFrame:
2323
if wpp_version in ["2022", "2024"]:
2424
wpp = pm_data.load_gbd_raking_input("population", f"wpp_{wpp_version}")
@@ -29,6 +29,18 @@ def load_wpp_populations(
2929
# GBD treats Kosovo as part of Serbia at the admin0 level
3030
"SRB": ["SRB", "XKX"],
3131
}
32+
if gbd_version == "2025":
33+
# Starting in 2025, GBD separates Metropolitan France and overseas departments (DROM-COMs)
34+
merge_map.update(
35+
{
36+
"FRA_97896": ["FRA"], # Metropolitan France
37+
"FRA_338": ["GUF"], # French Guiana
38+
"FRA_350": ["GLP"], # Guadeloupe
39+
"FRA_363": ["MTQ"], # Martinique
40+
"FRA_364": ["MYT"], # Mayotte
41+
"FRA_387": ["REU"], # Reunion Island
42+
}
43+
)
3244
for target, sources in merge_map.items():
3345
mask = wpp["iso3"].isin(sources)
3446
merged = (

0 commit comments

Comments
 (0)