Update testing module for Fitbit

pull/131/head
Meng Li 2021-04-16 18:32:20 -04:00
parent 5d732a45ec
commit 305cc9d4ad
7 changed files with 26 additions and 19 deletions

View File

@ -8,6 +8,9 @@ DayOfWeek2Date = {"Fri": ["2020-03-06", "2020-10-30"],
"Mon": ["2020-03-09", "2020-11-02"]}
def assign_test_timestamps(file_path):
columns_to_delete = ["test_time", "day_of_week", "time"]
data = pd.read_csv(file_path)
data[["day_of_week", "time"]] = data["test_time"].str.split(pat=" ", n=1, expand=True)
@ -15,14 +18,18 @@ def assign_test_timestamps(file_path):
# 0 is for March and 1 is for Nov
for i in [0, 1]:
data["datetime"] = pd.to_datetime(data.apply(lambda row: DayOfWeek2Date[row["day_of_week"]][i] + " " + row["time"], axis=1))
data["local_date_time"] = pd.to_datetime(data.apply(lambda row: DayOfWeek2Date[row["day_of_week"]][i] + " " + row["time"], axis=1))
data_with_timestamps = pd.concat([data_with_timestamps, data], axis=0)
# Convert datetime with timezone to timestamp
data_with_timestamps.insert(0, "timestamp", data_with_timestamps["datetime"].dt.tz_localize(tz="America/New_York").astype(np.int64) // 10**6)
if "fitbit" in file_path:
data_with_timestamps.insert(0, "timestamp", 0)
else:
# Convert local_date_time with timezone to timestamp
data_with_timestamps.insert(0, "timestamp", data_with_timestamps["local_date_time"].dt.tz_localize(tz="America/New_York").astype(np.int64) // 10**6)
columns_to_delete.add("local_date_time")
# Discard useless columns
for col in ["test_time", "day_of_week", "time", "datetime"]:
for col in columns_to_delete:
del data_with_timestamps[col]
return data_with_timestamps

View File

@ -319,7 +319,7 @@ PHONE_WIFI_VISIBLE:
# See https://www.rapids.science/latest/setup/configuration/#data-stream-configuration
FITBIT_DATA_STREAMS:
USE: fitbitjson_mysql
USE: fitbitparsed_csv
# AVAILABLE:
fitbitjson_mysql:
@ -335,7 +335,7 @@ FITBIT_DATA_STREAMS:
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
fitbitparsed_csv:
FOLDER: data/external/fitbit_csv
FOLDER: tests/data/external/aware_csv
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
# Sensors ------

View File

@ -319,7 +319,7 @@ PHONE_WIFI_VISIBLE:
# See https://www.rapids.science/latest/setup/configuration/#data-stream-configuration
FITBIT_DATA_STREAMS:
USE: fitbitjson_mysql
USE: fitbitparsed_csv
# AVAILABLE:
fitbitjson_mysql:
@ -335,7 +335,7 @@ FITBIT_DATA_STREAMS:
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
fitbitparsed_csv:
FOLDER: data/external/fitbit_csv
FOLDER: tests/data/external/aware_csv
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
# Sensors ------

View File

@ -319,7 +319,7 @@ PHONE_WIFI_VISIBLE:
# See https://www.rapids.science/latest/setup/configuration/#data-stream-configuration
FITBIT_DATA_STREAMS:
USE: fitbitjson_mysql
USE: fitbitparsed_csv
# AVAILABLE:
fitbitjson_mysql:
@ -335,7 +335,7 @@ FITBIT_DATA_STREAMS:
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
fitbitparsed_csv:
FOLDER: data/external/fitbit_csv
FOLDER: tests/data/external/aware_csv
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
# Sensors ------

View File

@ -319,7 +319,7 @@ PHONE_WIFI_VISIBLE:
# See https://www.rapids.science/latest/setup/configuration/#data-stream-configuration
FITBIT_DATA_STREAMS:
USE: fitbitjson_mysql
USE: fitbitparsed_csv
# AVAILABLE:
fitbitjson_mysql:
@ -335,7 +335,7 @@ FITBIT_DATA_STREAMS:
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
fitbitparsed_csv:
FOLDER: data/external/fitbit_csv
FOLDER: tests/data/external/aware_csv
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
# Sensors ------

View File

@ -319,7 +319,7 @@ PHONE_WIFI_VISIBLE:
# See https://www.rapids.science/latest/setup/configuration/#data-stream-configuration
FITBIT_DATA_STREAMS:
USE: fitbitjson_mysql
USE: fitbitparsed_csv
# AVAILABLE:
fitbitjson_mysql:
@ -335,7 +335,7 @@ FITBIT_DATA_STREAMS:
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
fitbitparsed_csv:
FOLDER: data/external/fitbit_csv
FOLDER: tests/data/external/aware_csv
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
# Sensors ------

View File

@ -319,7 +319,7 @@ PHONE_WIFI_VISIBLE:
# See https://www.rapids.science/latest/setup/configuration/#data-stream-configuration
FITBIT_DATA_STREAMS:
USE: fitbitjson_mysql
USE: fitbitparsed_csv
# AVAILABLE:
fitbitjson_mysql:
@ -335,7 +335,7 @@ FITBIT_DATA_STREAMS:
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
fitbitparsed_csv:
FOLDER: data/external/fitbit_csv
FOLDER: tests/data/external/aware_csv
SLEEP_SUMMARY_EPISODE_DAY_ANCHOR: end # summary sleep episodes are considered as events based on either the start timestamp or end timestamp.
# Sensors ------