-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdsp.py
More file actions
39 lines (32 loc) · 1.21 KB
/
Copy pathdsp.py
File metadata and controls
39 lines (32 loc) · 1.21 KB
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
import numpy as np
def generate_features(implementation_version, draw_graphs, raw_data, axes, sampling_freq, scale_axes):
# features is a 1D array, reshape so we have a matrix
raw_data = raw_data.reshape(int(len(raw_data) / len(axes)), len(axes))
features = []
graphs = []
# split out the data from all axes
for ax in range(0, len(axes)):
X = []
for ix in range(0, raw_data.shape[0]):
X.append(float(raw_data[ix][ax]))
# X now contains only the current axis
fx = np.array(X)
# process the signal here
fx = fx * scale_axes
# we need to return a 1D array again, so flatten here again
for f in fx:
features.append(f)
return {
'features': features,
'graphs': graphs,
# if you use FFTs then set the used FFTs here (this helps with memory optimization on MCUs)
'fft_used': [],
'output_config': {
# type can be 'flat', 'image' or 'spectrogram'
'type': 'flat',
'shape': {
# shape should be { width, height, channels } for image, { width, height } for spectrogram
'width': len(features)
}
}
}