Skip to content

Commit b416c32

Browse files
authored
Merge pull request #1795 from cmu-delphi/release/indicators_v0.3.33_utils_v0.3.10
Release covidcast-indicators 0.3.33
2 parents 6dedfdf + 11ab6ed commit b416c32

File tree

18 files changed

+60
-44
lines changed

18 files changed

+60
-44
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.32
2+
current_version = 0.3.33
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

ansible/templates/claims_hosp-params-prod.json.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"common": {
33
"export_dir": "/common/covidcast/receiving/hospital-admissions/",
4-
"log_exceptions": false
4+
"log_filename": "/var/log/indicators/hospital-admissions.log"
55
},
66
"indicator": {
77
"input_dir": "./retrieve_files",

changehc/delphi_changehc/load_data.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Author: Aaron Rumack
55
Created: 2020-10-14
66
"""
7+
from datetime import datetime
78
# third party
89
import pandas as pd
910

@@ -58,7 +59,7 @@ def load_chng_data(filepath, dropdate, base_geo,
5859
# restrict to start and end date
5960
data = data[
6061
(data[Config.DATE_COL] >= Config.FIRST_DATA_DATE) &
61-
(data[Config.DATE_COL] < dropdate)
62+
(data[Config.DATE_COL] <= dropdate)
6263
]
6364

6465
# counts between 1 and 3 are coded as "3 or less", we convert to 1
@@ -76,25 +77,30 @@ def load_chng_data(filepath, dropdate, base_geo,
7677
return data
7778

7879

79-
def load_combined_data(denom_filepath, covid_filepath, dropdate, base_geo,
80+
def load_combined_data(denom_filepath, covid_filepath, base_geo,
8081
backfill_dir, geo, weekday, numtype, backfill_merge_day):
8182
"""Load in denominator and covid data, and combine them.
8283
8384
Args:
8485
denom_filepath: path to the aggregated denominator data
8586
covid_filepath: path to the aggregated covid data
86-
dropdate: data drop date (datetime object)
8787
base_geo: base geographic unit before aggregation ('fips')
8888
8989
Returns:
9090
combined multiindexed dataframe, index 0 is geo_base, index 1 is date
9191
"""
9292
assert base_geo == "fips", "base unit must be 'fips'"
9393

94+
# Get issue_date from the filename
95+
issue_date = datetime.strptime(covid_filepath.split("/")[-1][:8], "%Y%m%d")
96+
assert (
97+
issue_date == datetime.strptime(denom_filepath.split("/")[-1][:8], "%Y%m%d")
98+
), "The aggregated files used for Covid Claims and Total Claims should have the same drop date."
99+
94100
# load each data stream
95-
denom_data = load_chng_data(denom_filepath, dropdate, base_geo,
101+
denom_data = load_chng_data(denom_filepath, issue_date, base_geo,
96102
Config.DENOM_COLS, Config.DENOM_DTYPES, Config.DENOM_COL)
97-
covid_data = load_chng_data(covid_filepath, dropdate, base_geo,
103+
covid_data = load_chng_data(covid_filepath, issue_date, base_geo,
98104
Config.COVID_COLS, Config.COVID_DTYPES, Config.COVID_COL)
99105

100106
# merge data
@@ -109,13 +115,13 @@ def load_combined_data(denom_filepath, covid_filepath, dropdate, base_geo,
109115

110116
# Store for backfill
111117
merge_backfill_file(backfill_dir, numtype, geo, weekday, backfill_merge_day,
112-
dropdate, test_mode=False, check_nd=25)
113-
store_backfill_file(data, dropdate, backfill_dir, numtype, geo, weekday)
118+
issue_date, test_mode=False, check_nd=25)
119+
store_backfill_file(data, issue_date, backfill_dir, numtype, geo, weekday)
114120
return data
115121

116122

117123
def load_cli_data(denom_filepath, flu_filepath, mixed_filepath, flu_like_filepath,
118-
covid_like_filepath, dropdate, base_geo,
124+
covid_like_filepath, base_geo,
119125
backfill_dir, geo, weekday, numtype, backfill_merge_day):
120126
"""Load in denominator and covid-like data, and combine them.
121127
@@ -125,24 +131,29 @@ def load_cli_data(denom_filepath, flu_filepath, mixed_filepath, flu_like_filepat
125131
mixed_filepath: path to the aggregated mixed data
126132
flu_like_filepath: path to the aggregated flu-like data
127133
covid_like_filepath: path to the aggregated covid-like data
128-
dropdate: data drop date (datetime object)
129134
base_geo: base geographic unit before aggregation ('fips')
130135
131136
Returns:
132137
combined multiindexed dataframe, index 0 is geo_base, index 1 is date
133138
"""
134139
assert base_geo == "fips", "base unit must be 'fips'"
135140

141+
# Get issue_date from the filename
142+
issue_date = datetime.strptime(flu_filepath.split("/")[-1][:8], "%Y%m%d")
143+
assert (
144+
issue_date == datetime.strptime(denom_filepath.split("/")[-1][:8], "%Y%m%d")
145+
), "The aggregated files used for CLI Claims and Total Claims should have the same drop date."
146+
136147
# load each data stream
137-
denom_data = load_chng_data(denom_filepath, dropdate, base_geo,
148+
denom_data = load_chng_data(denom_filepath, issue_date, base_geo,
138149
Config.DENOM_COLS, Config.DENOM_DTYPES, Config.DENOM_COL)
139-
flu_data = load_chng_data(flu_filepath, dropdate, base_geo,
150+
flu_data = load_chng_data(flu_filepath, issue_date, base_geo,
140151
Config.FLU_COLS, Config.FLU_DTYPES, Config.FLU_COL)
141-
mixed_data = load_chng_data(mixed_filepath, dropdate, base_geo,
152+
mixed_data = load_chng_data(mixed_filepath, issue_date, base_geo,
142153
Config.MIXED_COLS, Config.MIXED_DTYPES, Config.MIXED_COL)
143-
flu_like_data = load_chng_data(flu_like_filepath, dropdate, base_geo,
154+
flu_like_data = load_chng_data(flu_like_filepath, issue_date, base_geo,
144155
Config.FLU_LIKE_COLS, Config.FLU_LIKE_DTYPES, Config.FLU_LIKE_COL)
145-
covid_like_data = load_chng_data(covid_like_filepath, dropdate, base_geo,
156+
covid_like_data = load_chng_data(covid_like_filepath, issue_date, base_geo,
146157
Config.COVID_LIKE_COLS, Config.COVID_LIKE_DTYPES, Config.COVID_LIKE_COL)
147158

148159
# merge data
@@ -162,30 +173,35 @@ def load_cli_data(denom_filepath, flu_filepath, mixed_filepath, flu_like_filepat
162173

163174
# Store for backfill
164175
merge_backfill_file(backfill_dir, numtype, geo, weekday, backfill_merge_day,
165-
dropdate, test_mode=False, check_nd=25)
166-
store_backfill_file(data, dropdate, backfill_dir, numtype, geo, weekday)
176+
issue_date, test_mode=False, check_nd=25)
177+
store_backfill_file(data, issue_date, backfill_dir, numtype, geo, weekday)
167178
return data
168179

169180

170-
def load_flu_data(denom_filepath, flu_filepath, dropdate, base_geo,
181+
def load_flu_data(denom_filepath, flu_filepath, base_geo,
171182
backfill_dir, geo, weekday, numtype, backfill_merge_day):
172183
"""Load in denominator and flu data, and combine them.
173184
174185
Args:
175186
denom_filepath: path to the aggregated denominator data
176187
flu_filepath: path to the aggregated flu data
177-
dropdate: data drop date (datetime object)
178188
base_geo: base geographic unit before aggregation ('fips')
179189
180190
Returns:
181191
combined multiindexed dataframe, index 0 is geo_base, index 1 is date
182192
"""
183193
assert base_geo == "fips", "base unit must be 'fips'"
184194

195+
# Get issue_date from the filename
196+
issue_date = datetime.strptime(flu_filepath.split("/")[-1][:8], "%Y%m%d")
197+
assert (
198+
issue_date == datetime.strptime(denom_filepath.split("/")[-1][:8], "%Y%m%d")
199+
), "The aggregated files used for Flu Claims and Total Claims should have the same drop date."
200+
185201
# load each data stream
186-
denom_data = load_chng_data(denom_filepath, dropdate, base_geo,
202+
denom_data = load_chng_data(denom_filepath, issue_date, base_geo,
187203
Config.DENOM_COLS, Config.DENOM_DTYPES, Config.DENOM_COL)
188-
flu_data = load_chng_data(flu_filepath, dropdate, base_geo,
204+
flu_data = load_chng_data(flu_filepath, issue_date, base_geo,
189205
Config.FLU_COLS, Config.FLU_DTYPES, Config.FLU_COL)
190206

191207
# merge data
@@ -200,6 +216,6 @@ def load_flu_data(denom_filepath, flu_filepath, dropdate, base_geo,
200216

201217
# Store for backfill
202218
merge_backfill_file(backfill_dir, numtype, geo, weekday, backfill_merge_day,
203-
dropdate, test_mode=False, check_nd=25)
204-
store_backfill_file(data, dropdate, backfill_dir, numtype, geo, weekday)
219+
issue_date, test_mode=False, check_nd=25)
220+
store_backfill_file(data, issue_date, backfill_dir, numtype, geo, weekday)
205221
return data

changehc/delphi_changehc/run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,16 @@ def run_module(params: Dict[str, Dict[str, Any]]):
183183
)
184184
if numtype == "covid":
185185
data = load_combined_data(file_dict["denom"],
186-
file_dict["covid"],dropdate_dt,"fips",
186+
file_dict["covid"], "fips",
187187
backfill_dir, geo, weekday, numtype,
188188
backfill_merge_day)
189189
elif numtype == "cli":
190190
data = load_cli_data(file_dict["denom"],file_dict["flu"],file_dict["mixed"],
191-
file_dict["flu_like"],file_dict["covid_like"],dropdate_dt,"fips",
191+
file_dict["flu_like"],file_dict["covid_like"], "fips",
192192
backfill_dir, geo, weekday, numtype, backfill_merge_day)
193193
elif numtype == "flu":
194194
data = load_flu_data(file_dict["denom"],file_dict["flu"],
195-
dropdate_dt,"fips",backfill_dir, geo, weekday,
195+
"fips",backfill_dir, geo, weekday,
196196
numtype, backfill_merge_day)
197197
more_stats = su_inst.update_sensor(
198198
data,

changehc/tests/test_backfill.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
weekday = True
3434
backfill_merge_day = 0
3535

36-
combined_data = load_combined_data(DENOM_FILEPATH, COVID_FILEPATH, DROP_DATE,
36+
combined_data = load_combined_data(DENOM_FILEPATH, COVID_FILEPATH,
3737
"fips", backfill_dir, geo, weekday, "covid",
3838
backfill_merge_day)
3939

changehc/tests/test_load_data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class TestLoadData:
3737
Config.DENOM_COLS, Config.DENOM_DTYPES, Config.DENOM_COL)
3838
covid_data = load_chng_data(COVID_FILEPATH, DROP_DATE, "fips",
3939
Config.COVID_COLS, Config.COVID_DTYPES, Config.COVID_COL)
40-
combined_data = load_combined_data(DENOM_FILEPATH, COVID_FILEPATH, DROP_DATE,
40+
combined_data = load_combined_data(DENOM_FILEPATH, COVID_FILEPATH,
4141
"fips", backfill_dir, geo, weekday, "covid",
4242
backfill_merge_day)
43-
flu_data = load_flu_data(DENOM_FILEPATH, FLU_FILEPATH, DROP_DATE,"fips",
43+
flu_data = load_flu_data(DENOM_FILEPATH, FLU_FILEPATH, "fips",
4444
backfill_dir, geo, weekday, "flu", backfill_merge_day)
4545
gmpr = GeoMapper()
4646

@@ -54,11 +54,11 @@ def test_base_unit(self):
5454
Config.DENOM_COLS, Config.DENOM_DTYPES, Config.COVID_COL)
5555

5656
with pytest.raises(AssertionError):
57-
load_combined_data(DENOM_FILEPATH, COVID_FILEPATH, DROP_DATE, "foo",
57+
load_combined_data(DENOM_FILEPATH, COVID_FILEPATH, "foo",
5858
backfill_dir, geo, weekday, "covid", backfill_merge_day)
5959

6060
with pytest.raises(AssertionError):
61-
load_flu_data(DENOM_FILEPATH, FLU_FILEPATH, DROP_DATE, "foo",
61+
load_flu_data(DENOM_FILEPATH, FLU_FILEPATH, "foo",
6262
backfill_dir, geo, weekday, "covid", backfill_merge_day)
6363

6464
def test_denom_columns(self):

changehc/tests/test_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
backfill_merge_day = 0
3131

3232
class TestLoadData:
33-
combined_data = load_combined_data(DENOM_FILEPATH, COVID_FILEPATH, DROP_DATE,
33+
combined_data = load_combined_data(DENOM_FILEPATH, COVID_FILEPATH,
3434
"fips", backfill_dir, geo, weekday, "covid",
3535
backfill_merge_day)
3636

changehc/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

claims_hosp/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

doctor_visits/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

dsew_community_profile/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

google_symptoms/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

hhs_hosp/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

jhu/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

nchs_mortality/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

nowcast/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

quidel_covidtest/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

sir_complainsalot/version.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
current_version = 0.3.32
1+
current_version = 0.3.33

0 commit comments

Comments
 (0)