-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreprocess.py
56 lines (41 loc) · 1.67 KB
/
preprocess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
from helper import convert_to_map
from clean import clean_file
import file_process
debug = True
def preprocess(input_string, configs=None):
"""
Performs the operations for the preprocess command, i.e, cleans the files in the specified directory and executes the preprocess functionality.
Paremeters:
-----------
input_string (str array): options for preprocess command which are directory and frequency.
"""
if input_string == "syntax":
msg = """preprocess [-d directory] [-f frequency=200] [-c clean=False]
-d : The data path.
-f : The interpolation rate. Default is 200 Hz.
-c : True then call 'clean()' function first. Default is 'False'.
"""
print(msg)
else:
input_map = convert_to_map(input_string)
frequency = float(input_map.get('-f', 200))
data_path = input_map.get('-d', None)
rolling_window_size = input_map.get('-w', 50)
if not data_path and configs:
data_path = configs['data_path']
if not data_path:
print("ERROR: preprocess(): data path is not set")
return
clean_flag = input_map.get('-c', "false")
if debug:
print("interpolation rate %f Hz" % frequency)
print("data path: %s" % data_path)
print("clean: %s" % clean_flag)
# TODO: accept more flags for clean
if clean_flag.lower() == 'true':
clean_options = ["-d", data_path]
clean_file(clean_options)
file_process.process_data_main(data_path, frequency, rolling_window_size)
if __name__ == "__main__":
preprocess(['-d', 'vehsense-backend-data', '-c', 'true'])