Skip to content

NCHS data available at HHS, nation level #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nchs_mortality/delphi_nchs_mortality/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
"prop"
]
INCIDENCE_BASE = 100000
GEO_RES = "state"
GEO_RES = [
"nation",
"hhs",
"state"
]

# this is necessary as a delimiter in the f-string expressions we use to
# construct detailed error reports
Expand Down
7 changes: 4 additions & 3 deletions nchs_mortality/delphi_nchs_mortality/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
from datetime import datetime, date, timedelta
from typing import Dict, Any
from itertools import product

import numpy as np
from delphi_utils import S3ArchiveDiffer, get_structured_logger
Expand Down Expand Up @@ -60,7 +61,7 @@ def run_module(params: Dict[str, Any]):

stats = []
df_pull = pull_nchs_mortality_data(token, test_file)
for metric in METRICS:
for metric,geo in product(METRICS,GEO_RES):
if metric == 'percent_of_expected_deaths':
print(metric)
df = df_pull.copy()
Expand All @@ -71,7 +72,7 @@ def run_module(params: Dict[str, Any]):
sensor_name = "_".join([SENSOR_NAME_MAP[metric]])
dates = export_csv(
df,
geo_name=GEO_RES,
geo_name=geo,
export_dir=daily_export_dir,
start_date=datetime.strptime(export_start_date, "%Y-%m-%d"),
sensor=sensor_name,
Expand All @@ -92,7 +93,7 @@ def run_module(params: Dict[str, Any]):
sensor_name = "_".join([SENSOR_NAME_MAP[metric], sensor])
dates = export_csv(
df,
geo_name=GEO_RES,
geo_name=geo,
export_dir=daily_export_dir,
start_date=datetime.strptime(export_start_date, "%Y-%m-%d"),
sensor=sensor_name,
Expand Down
20 changes: 16 additions & 4 deletions nchs_mortality/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,29 @@ def test_output_files_exist(self, run_as_module, date):
'deaths_pneumonia_or_flu_or_covid_incidence']
sensors = ["num", "prop"]

expected_files = []
expected_files_nation = []
expected_files_state=[]
expected_files_hhs=[]
for d in dates:
for metric in metrics:
if metric == "deaths_percent_of_expected":
expected_files += ["weekly_" + d + "_state_" \
expected_files_nation += ["weekly_" + d + "_nation_" \
+ metric + ".csv"]
expected_files_state += ["weekly_" + d + "_state_" \
+ metric + ".csv"]
expected_files_hhs += ["weekly_" + d + "_hhs_" \
+ metric + ".csv"]
else:
for sensor in sensors:
expected_files += ["weekly_" + d + "_state_" \
expected_files_nation += ["weekly_" + d + "_nation_" \
+ metric + "_" + sensor + ".csv"]
expected_files_state += ["weekly_" + d + "_state_" \
+ metric + "_" + sensor + ".csv"]
expected_files_hhs += ["weekly_" + d + "_hhs_" \
+ metric + "_" + sensor + ".csv"]
assert set(expected_files).issubset(set(csv_files))
assert set(expected_files_nation).issubset(set(csv_files))
assert set(expected_files_state).issubset(set(csv_files))
assert set(expected_files_hhs).issubset(set(csv_files))

@pytest.mark.parametrize("date", ["2020-09-14", "2020-09-18"])
def test_output_file_format(self, run_as_module, date):
Expand Down