forked from Prattbuw/Treadmill_Paper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmooth_diff.py
More file actions
40 lines (30 loc) · 896 Bytes
/
smooth_diff.py
File metadata and controls
40 lines (30 loc) · 896 Bytes
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
import h5py
import os
import math
#matplotlib inline
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import pandas as pd
import seaborn as sea
import scipy.signal
import read_data as rd
import organize_data as od
import fill_nans as fill
import velocity as vel
import swing_stance as s_s
from scipy import signal
from scipy.signal import savgol_filter
from scipy.signal import savgol_filter
def smooth_diff(node_loc, win=25, poly=3):
"""
node_loc is a [frames, 2] array
win defines the window to smooth over
poly defines the order of the polynomial
to fit with
"""
node_loc_vel = np.zeros_like(node_loc)
for c in range(node_loc.shape[-1]):
node_loc_vel[:, c] = savgol_filter(node_loc[:, c], win, poly, deriv=1)
node_vel = np.linalg.norm(node_loc_vel,axis=1)
return node_vel