|
3 | 3 | === Purpose === |
4 | 4 | =============== |
5 | 5 |
|
6 | | -A Python utility class to download and parse Quidel date, which is called |
| 6 | +A Python utility class to download and parse Quidel data, which is called |
7 | 7 | by quidel_update.py |
8 | 8 |
|
9 | 9 |
|
|
17 | 17 | * original version |
18 | 18 | ''' |
19 | 19 |
|
20 | | -# standard |
| 20 | +# standard library |
| 21 | +from collections import defaultdict |
| 22 | +import datetime |
| 23 | +import email |
| 24 | +import getpass |
| 25 | +import imaplib |
| 26 | +import os |
21 | 27 | from os import listdir |
22 | 28 | from os.path import isfile, join |
23 | | - |
24 | | -import email, getpass, imaplib, os |
25 | | -import datetime |
26 | 29 | import math |
27 | | -from collections import defaultdict |
28 | 30 | import re |
29 | 31 |
|
30 | 32 | # third party |
31 | | -import pandas as pd |
32 | 33 | import numpy as np |
| 34 | +import pandas as pd |
33 | 35 |
|
34 | | -# delphi |
| 36 | +# first party |
| 37 | +import delphi.operations.secrets as secrets |
35 | 38 | import delphi.utils.epidate as ED |
36 | 39 | import delphi.utils.epiweek as EW |
37 | | -from delphi.utils.state_info import * |
38 | | -import delphi.operations.secrets as secrets |
| 40 | +from delphi.utils.geo.locations import Locations |
39 | 41 |
|
40 | 42 | def word_map(row,terms): |
41 | 43 | for (k,v) in terms.items(): |
@@ -206,16 +208,23 @@ def load_csv(self, dims=None): |
206 | 208 | # output: [#unique_device,fluA,fluB,fluAll,total] |
207 | 209 | def prepare_measurements(self,data_dict,use_hhs=True,start_weekday=6): |
208 | 210 | buffer_dict = {} |
209 | | - SI = StateInfo() |
210 | 211 | if use_hhs: |
211 | | - region_list = SI.hhs |
| 212 | + region_list = Locations.hhs_list |
212 | 213 | else: |
213 | | - region_list = SI.sta |
| 214 | + region_list = Locations.atom_list |
| 215 | + |
| 216 | + def get_hhs_region(atom): |
| 217 | + for region in Locations.hhs_list: |
| 218 | + if atom.lower() in Locations.hhs_map[region]: |
| 219 | + return region |
| 220 | + if atom.lower() == 'ny': |
| 221 | + return 'hhs2' |
| 222 | + return atom |
214 | 223 |
|
215 | 224 | day_shift = 6 - start_weekday |
216 | 225 | time_map = lambda x:date_to_epiweek(x,'-',shift=day_shift) |
217 | | - region_map = lambda x:SI.state_regions[x]['hhs'] \ |
218 | | - if use_hhs and x in SI.state_regions else x # a bit hacky |
| 226 | + region_map = lambda x:get_hhs_region(x) \ |
| 227 | + if use_hhs and x not in Locations.hhs_list else x # a bit hacky |
219 | 228 |
|
220 | 229 | end_date = sorted(data_dict.keys())[-1] |
221 | 230 | # count the latest week in only if Thurs data is included |
|
0 commit comments