Skip to content

Commit

Permalink
Merge pull request #10 from ihmeuw/update_artifact_scaled_pop
Browse files Browse the repository at this point in the history
Update artifact to include scaling factor for population
  • Loading branch information
pletale authored Nov 20, 2024
2 parents fea0bf6 + 25c51b0 commit 7ed9b25
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/vivarium_gates_mncnh/constants/data_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class __Population(NamedTuple):
AGE_BINS: str = "population.age_bins"
DEMOGRAPHY: str = "population.demographic_dimensions"
TMRLE: str = "population.theoretical_minimum_risk_life_expectancy"
SCALING_FACTOR: str = "population.scaling_factor"

@property
def name(self):
Expand Down
31 changes: 31 additions & 0 deletions src/vivarium_gates_mncnh/data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_data(
data_keys.POPULATION.AGE_BINS: load_age_bins,
data_keys.POPULATION.DEMOGRAPHY: load_demographic_dimensions,
data_keys.POPULATION.TMRLE: load_theoretical_minimum_risk_life_expectancy,
data_keys.POPULATION.SCALING_FACTOR: load_scaling_factor,
# data_keys.POPULATION.ACMR: load_standard_data,
# TODO - add appropriate mappings
data_keys.PREGNANCY.ASFR: load_asfr,
Expand Down Expand Up @@ -170,6 +171,8 @@ def _load_em_from_meid(location, meid, measure):


# TODO - add project-specific data functions here


def load_asfr(
key: str, location: str, years: Optional[Union[int, str, List[int]]] = None
) -> pd.DataFrame:
Expand Down Expand Up @@ -210,6 +213,34 @@ def load_raw_incidence_data(
return vi_utils.sort_hierarchical_data(data).droplevel("location")


def load_scaling_factor(
key: str, location: str, years: Optional[Union[int, str, List[int]]] = None
) -> pd.DataFrame:

incidence_c995 = get_data(
data_keys.PREGNANCY.RAW_INCIDENCE_RATE_MISCARRIAGE, location, years
).reset_index()
incidence_c374 = get_data(
data_keys.PREGNANCY.RAW_INCIDENCE_RATE_ECTOPIC, location, years
).reset_index()
asfr = get_data(data_keys.PREGNANCY.ASFR, location).reset_index()
sbr = get_data(data_keys.PREGNANCY.SBR, location).reset_index()

asfr = asfr.set_index(metadata.ARTIFACT_INDEX_COLUMNS)
incidence_c995 = incidence_c995.set_index(metadata.ARTIFACT_INDEX_COLUMNS)
incidence_c374 = incidence_c374.set_index(metadata.ARTIFACT_INDEX_COLUMNS)
sbr = (
sbr.set_index("year_start")
.drop(columns=["year_end"])
.reindex(asfr.index, level="year_start")
)

# Calculate pregnancy incidence
preg_inc = asfr + asfr.multiply(sbr["value"], axis=0) + incidence_c995 + incidence_c374

return preg_inc


def load_lbwsg_exposure(
key: str, location: str, years: Optional[Union[int, str, list[int]]] = None
) -> pd.DataFrame:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
input_draw_count: 10
random_seed_count: 5
random_seed_count: 10

branches:
# TODO change to name of intervention
Expand Down
4 changes: 2 additions & 2 deletions src/vivarium_gates_mncnh/model_specifications/model_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins:
components:
vivarium_public_health:
population:
- BasePopulation()
- ScaledPopulation("population.scaling_factor")

vivarium_gates_mncnh:
components:
Expand All @@ -20,7 +20,7 @@ components:
configuration:
input_data:
input_draw_number: 0
artifact_path: "/mnt/team/simulation_science/pub/models/vivarium_gates_mncnh/artifacts/anc/ethiopia.hdf"
artifact_path: "/mnt/team/simulation_science/pub/models/vivarium_gates_mncnh/artifacts/anc/pakistan.hdf"
interpolation:
order: 0
extrapolate: True
Expand Down

0 comments on commit 7ed9b25

Please sign in to comment.