-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimu_processing.py
53 lines (45 loc) · 1.28 KB
/
imu_processing.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
import pandas as pd
import numpy as np
from scipy import fftpack
from scipy.signal import butter, lfilter
def load_data(filepath):
with open(filepath, 'r') as file:
lines = file.readlines()
data = {
'A_X': [],
'A_Y': [],
'A_Z': [],
}
temp_data = {
'A_X': None,
'A_Y': None,
'A_Z': None,
}
# Iterate through lines and add values to the data dictionary
for line in lines:
try:
key, value = line.strip().split(" = ")
if key in temp_data:
temp_data[key] = float(value)
# If we have a full set of values, append them to the data dictionary
if all(temp_data.values()):
for k in data:
data[k].append(temp_data[k])
# Reset temp_data for next set of values
temp_data = {
'A_X': None,
'A_Y': None,
'A_Z': None,
}
except:
pass
# Convert data dictionary to pandas DataFrame
df = pd.DataFrame(data)
return df
def compute_means(df):
means = [
df['A_X'].mean(),
df['A_Y'].mean(),
df['A_Z'].mean(),
]
return means