Skip to content

Commit ef88218

Browse files
authored
Merge pull request #204 from cmu-delphi/kmm/rename_signals
Kmm/rename signals
2 parents 2e580d1 + eb19aa4 commit ef88218

File tree

5 files changed

+42
-28
lines changed

5 files changed

+42
-28
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
HOME_DWELL = 'median_home_dwell_time'
4+
COMPLETELY_HOME = 'completely_home_prop'
5+
FULL_TIME_WORK = 'full_time_work_prop'
6+
PART_TIME_WORK = 'part_time_work_prop'
7+
8+
SIGNALS = [
9+
HOME_DWELL,
10+
COMPLETELY_HOME,
11+
FULL_TIME_WORK,
12+
PART_TIME_WORK
13+
]
14+
15+
GEO_RESOLUTIONS = [
16+
'county',
17+
'state',
18+
]

safegraph/delphi_safegraph/process.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
from delphi_epidata import Epidata
2-
1+
import covidcast
32
import numpy as np
43
import pandas as pd
54

5+
from .constants import HOME_DWELL, COMPLETELY_HOME, FULL_TIME_WORK, PART_TIME_WORK
66
from .geo import FIPS_TO_STATE
77

88
# Magic number for modular arithmetic; CBG -> FIPS
99
MOD = 10000000
1010

11-
1211
def add_prefix(signal_names, wip_signal, prefix: str):
1312
"""Adds prefix to signal if there is a WIP signal
1413
Parameters
@@ -47,7 +46,7 @@ def add_prefix(signal_names, wip_signal, prefix: str):
4746

4847
# Check if the signal name is public
4948
def public_signal(signal_):
50-
"""Checks if the signal name is already public using Epidata
49+
"""Checks if the signal name is already public using COVIDcast
5150
Parameters
5251
----------
5352
signal_ : str
@@ -58,10 +57,10 @@ def public_signal(signal_):
5857
True if the signal is not present
5958
False if the signal is present
6059
"""
61-
epidata_df = Epidata.covidcast_meta()
62-
for index in range(len(epidata_df['epidata'])):
63-
if 'signal' in epidata_df['epidata'][index]:
64-
if epidata_df['epidata'][index]['signal'] == signal_:
60+
epidata_df = covidcast.meta()
61+
for index in range(len(epidata_df)):
62+
if 'signal' in epidata_df[index]:
63+
if epidata_df[index]['signal'] == signal_:
6564
return False
6665
return True
6766

@@ -91,10 +90,6 @@ def construct_signals(cbg_df, signal_names):
9190
Dataframe with columns: timestamp, county_fips, and
9291
{each signal described above}.
9392
"""
94-
prefix = 'wip_'
95-
COMPLETELY_HOME = 'completely_home_prop'
96-
FULL_TIME_WORK = 'full_time_work_prop'
97-
PART_TIME_WORK = 'part_time_work_prop'
9893

9994
# Preparation
10095
cbg_df['timestamp'] = cbg_df['date_range_start'].apply(
@@ -104,13 +99,13 @@ def construct_signals(cbg_df, signal_names):
10499

105100
# Transformation: create signal not available in raw data
106101
for signal in signal_names:
107-
if signal in (FULL_TIME_WORK, prefix + FULL_TIME_WORK):
102+
if signal.endswith(FULL_TIME_WORK):
108103
cbg_df[signal] = (cbg_df['full_time_work_behavior_devices']
109104
/ cbg_df['device_count'])
110-
elif signal in (COMPLETELY_HOME, prefix + COMPLETELY_HOME):
105+
elif signal.endswith(COMPLETELY_HOME):
111106
cbg_df[signal] = (cbg_df['completely_home_device_count']
112107
/ cbg_df['device_count'])
113-
elif signal in (PART_TIME_WORK, prefix + PART_TIME_WORK):
108+
elif signal.endswith(PART_TIME_WORK):
114109
cbg_df[signal] = (cbg_df['part_time_work_behavior_devices']
115110
/ cbg_df['device_count'])
116111

safegraph/delphi_safegraph/run.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,9 @@
99

1010
from delphi_utils import read_params
1111

12+
from .constants import SIGNALS, GEO_RESOLUTIONS
1213
from .process import process, add_prefix
1314

14-
SIGNALS = [
15-
'median_home_dwell_time',
16-
'completely_home_prop',
17-
'full_time_work_prop',
18-
'part_time_work_prop'
19-
]
20-
21-
GEO_RESOLUTIONS = [
22-
'county',
23-
'state',
24-
]
25-
26-
2715
def run_module():
2816

2917
params = read_params()

safegraph/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from setuptools import find_packages
33

44
required = [
5+
"covidcast"
56
"numpy",
67
"pandas",
78
"pytest",

safegraph/tests/params.json.template

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"static_file_dir": "./static",
3+
"raw_data_dir": "/mnt/data/safegraph/",
4+
"export_dir": "./receiving",
5+
"cache_dir": "./cache",
6+
"n_core": "12",
7+
"aws_access_key_id": "",
8+
"aws_secret_access_key": "",
9+
"aws_default_region": "",
10+
"aws_endpoint": "",
11+
"wip_signal" : ""
12+
}

0 commit comments

Comments
 (0)