def smoothing(y, box_pts):
box = np.ones(box_pts) / box_pts
y_smooth = np.convolve(y, box, mode='same')
def generate_features(draw_graphs, raw_data, axes, sampling_freq, scale_axes, smooth):
# features is a 1D array, reshape so we have a matrix with one raw per axis
raw_data = raw_data.reshape(int(len(raw_data) / len(axes)), len(axes))
# split out the data from all axes
for ax in range(0, len(axes)):
for ix in range(0, raw_data.shape[0]):
X.append(raw_data[ix][ax])
# X now contains only the current axis
# if smoothing is enabled, do that
# we save bandwidth by only drawing graphs when needed
smoothed_graph[axes[ax]] = list(fx)
# we need to return a 1D array again, so flatten here again
# draw the graph with time in the window on the Y axis, and the values on the X axes
# note that the 'suggestedYMin/suggestedYMax' names are incorrect, they describe
# the min/max of the X axis
'y': np.linspace(0.0, raw_data.shape[0] * (1 / sampling_freq) * 1000, raw_data.shape[0] + 1).tolist(),
return { 'features': features, 'graphs': graphs }