2020-10-08 00:11:06 +02:00
|
|
|
import pandas as pd
|
2021-11-19 16:34:36 +01:00
|
|
|
from utils.utils import fetch_provider_features, run_provider_cleaning_script
|
2020-10-08 00:11:06 +02:00
|
|
|
|
2022-05-20 15:18:45 +02:00
|
|
|
import sys
|
|
|
|
|
2020-10-08 00:11:06 +02:00
|
|
|
sensor_data_files = dict(snakemake.input)
|
|
|
|
|
|
|
|
provider = snakemake.params["provider"]
|
|
|
|
provider_key = snakemake.params["provider_key"]
|
|
|
|
sensor_key = snakemake.params["sensor_key"]
|
|
|
|
|
2022-04-13 15:18:23 +02:00
|
|
|
calc_windows = False
|
|
|
|
try:
|
|
|
|
calc_windows = provider["WINDOWS"]["COMPUTE"]
|
|
|
|
except KeyError:
|
2022-05-11 10:50:15 +02:00
|
|
|
print("WINDOWS COMPUTE key not found in config.yaml!")
|
2022-04-13 15:18:23 +02:00
|
|
|
|
|
|
|
|
2021-11-19 16:34:36 +01:00
|
|
|
if sensor_key == "all_cleaning_individual" or sensor_key == "all_cleaning_overall":
|
|
|
|
# Data cleaning
|
|
|
|
sensor_features = run_provider_cleaning_script(provider, provider_key, sensor_key, sensor_data_files)
|
|
|
|
else:
|
|
|
|
# Extract sensor features
|
|
|
|
del sensor_data_files["time_segments_labels"]
|
|
|
|
time_segments_file = snakemake.input["time_segments_labels"]
|
2020-10-08 00:11:06 +02:00
|
|
|
|
2022-04-13 15:18:23 +02:00
|
|
|
if calc_windows:
|
2022-05-11 10:50:15 +02:00
|
|
|
window_features, second_order_features = fetch_provider_features(provider, provider_key, sensor_key, sensor_data_files, time_segments_file, calc_windows=True)
|
|
|
|
second_order_features.to_csv(snakemake.output[0], index=False)
|
|
|
|
window_features.to_csv(snakemake.output[1], index=False)
|
2022-04-14 13:51:53 +02:00
|
|
|
elif "empatica" in sensor_key:
|
2022-04-13 15:18:23 +02:00
|
|
|
pd.DataFrame().to_csv(snakemake.output[1], index=False)
|
2022-04-25 15:07:03 +02:00
|
|
|
|
2022-05-11 10:50:15 +02:00
|
|
|
sensor_features = fetch_provider_features(provider, provider_key, sensor_key, sensor_data_files, time_segments_file, calc_windows=False)
|
2022-04-13 15:18:23 +02:00
|
|
|
|
2022-05-11 10:50:15 +02:00
|
|
|
if not calc_windows:
|
|
|
|
sensor_features.to_csv(snakemake.output[0], index=False)
|