Skip to content

Commit 6d543a2

Browse files
committed
replace state_info with geo/locations
Replaced usage of the deprecated StateInfo class with the newer Locations class. Also organized imports.
1 parent dd2c5f3 commit 6d543a2

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

src/acquisition/quidel/quidel.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=== Purpose ===
44
===============
55
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
77
by quidel_update.py
88
99
@@ -17,25 +17,27 @@
1717
* original version
1818
'''
1919

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
2127
from os import listdir
2228
from os.path import isfile, join
23-
24-
import email, getpass, imaplib, os
25-
import datetime
2629
import math
27-
from collections import defaultdict
2830
import re
2931

3032
# third party
31-
import pandas as pd
3233
import numpy as np
34+
import pandas as pd
3335

34-
# delphi
36+
# first party
37+
import delphi.operations.secrets as secrets
3538
import delphi.utils.epidate as ED
3639
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
3941

4042
def word_map(row,terms):
4143
for (k,v) in terms.items():
@@ -206,16 +208,23 @@ def load_csv(self, dims=None):
206208
# output: [#unique_device,fluA,fluB,fluAll,total]
207209
def prepare_measurements(self,data_dict,use_hhs=True,start_weekday=6):
208210
buffer_dict = {}
209-
SI = StateInfo()
210211
if use_hhs:
211-
region_list = SI.hhs
212+
region_list = Locations.hhs_list
212213
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
214223

215224
day_shift = 6 - start_weekday
216225
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
219228

220229
end_date = sorted(data_dict.keys())[-1]
221230
# count the latest week in only if Thurs data is included

src/acquisition/quidel/quidel_update.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=== Purpose ===
44
===============
55
6-
Stores data provided by Quidel Corp., which contains flu lab test result.
6+
Stores data provided by Quidel Corp., which contains flu lab test results.
77
See: quidel.py
88
99
@@ -42,12 +42,13 @@
4242
import mysql.connector
4343

4444
# first party
45-
from . import quidel
45+
from delphi.epidata.acquisition.quidel import quidel
4646
import delphi.operations.secrets as secrets
4747
from delphi.utils.epidate import EpiDate
4848
import delphi.utils.epiweek as flu
49+
from delphi.utils.geo.locations import Locations
4950

50-
LOCATIONS = ['hhs%d'%i for i in range(1,11)]
51+
LOCATIONS = Locations.hhs_list
5152
DATAPATH = '/home/automation/quidel_data'
5253

5354
def update(locations, first=None, last=None, force_update=False, load_email=True):

0 commit comments

Comments
 (0)