33=== Purpose ===
44===============
55
6- Fetches FluSurv-NET data (flu hospitaliation rates) from CDC. Unlike the other
6+ Fetches FluSurv-NET data (flu hospitalization rates) from CDC. Unlike the other
77CDC-hosted datasets (e.g. FluView), FluSurv is not available as a direct
88download. This program emulates web browser requests for the web app and
99extracts data of interest from the JSON response.
4949
5050# all currently available FluSurv locations and their associated codes
5151# the number pair represents NetworkID and CatchmentID
52- location_codes = {
52+ location_to_code = {
5353 "CA" : (2 , 1 ),
5454 "CO" : (2 , 2 ),
5555 "CT" : (2 , 3 ),
@@ -155,7 +155,7 @@ def mmwrid_to_epiweek(mmwrid):
155155
156156def extract_from_object (data_in ):
157157 """
158- Given a FluSurv data object, return hospitaliation rates.
158+ Given a FluSurv data object, return hospitalization rates.
159159
160160 The returned object is indexed first by epiweek, then by zero-indexed age
161161 group.
@@ -171,11 +171,16 @@ def extract_from_object(data_in):
171171 # capture as-of-yet undefined age groups 10, 11, and 12
172172 continue
173173 age_index = obj ["age" ] - 1
174- # iterage over weeks
174+ # iterate over weeks
175175 for mmwrid , _ , _ , rate in obj ["data" ]:
176176 epiweek = mmwrid_to_epiweek (mmwrid )
177177 if epiweek not in data_out :
178178 # weekly rate of each age group
179+ # TODO what is this magic constant? Maybe total # of age
180+ # groups?? Appears to be assuming that age groups are
181+ # numbered sequentially. Better to store data_out in a
182+ # dictionary of dictionaries, given new age group ids
183+ # (e.g. 99, 21, etc)
179184 data_out [epiweek ] = [None ] * 9
180185 prev_rate = data_out [epiweek ][age_index ]
181186 if prev_rate is None :
@@ -201,7 +206,7 @@ def get_data(location_code):
201206
202207 This method performs the following operations:
203208 - fetches FluSurv data from CDC
204- - extracts and returns hospitaliation rates
209+ - extracts and returns hospitalization rates
205210 """
206211
207212 # fetch
0 commit comments