Modification of getSampleRate method for all CF scripts.

sociality-task
Primoz 2022-03-30 15:00:11 +00:00
parent ab0b9227d7
commit 470993eeb0
3 changed files with 12 additions and 11 deletions

View File

@ -8,10 +8,11 @@ import sys
def getSampleRate(data):
try:
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
timestamps_diff = data['timestamp'].diff().dropna().mean()
except:
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
raise Exception("Error occured while trying to get the mean sample rate from the data.")
print(1000/timestamps_diff)
return 1000/timestamps_diff
def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment, filter_data_by_segment):
@ -41,7 +42,7 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
eda_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
acc_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
requested_intraday_features = provider["FEATURES"]
# name of the features this function can compute
@ -50,8 +51,8 @@ def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
# extract features from intraday data
eda_intraday_features = extractAccFeaturesFromIntradayData(eda_intraday_data,
acc_intraday_features = extractAccFeaturesFromIntradayData(acc_intraday_data,
intraday_features_to_compute, time_segment,
filter_data_by_segment)
return eda_intraday_features
return acc_intraday_features

View File

@ -7,9 +7,9 @@ from CalculatingFeatures.calculate_features import calculateFeatures
def getSampleRate(data):
try:
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
timestamps_diff = data['timestamp'].diff().dropna().mean()
except:
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
raise Exception("Error occured while trying to get the mean sample rate from the data.")
return 1000/timestamps_diff

View File

@ -7,9 +7,9 @@ from CalculatingFeatures.calculate_features import calculateFeatures
def getSampleRate(data):
try:
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
timestamps_diff = data['timestamp'].diff().dropna().mean()
except:
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
raise Exception("Error occured while trying to get the mean sample rate from the data.")
return 1000/timestamps_diff