-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaximum_plotly.py
46 lines (38 loc) · 1.38 KB
/
maximum_plotly.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
import numpy as np
import matplotlib.pyplot as plt
import plotly.plotly as py
import plotly.graph_objs as go
# -------------- Import data ----------#
data = np.genfromtxt("D:/Humain_gait/data/New Analysis/MAL/200 Steps/IMU Data/new_F1T1.csv", delimiter=',',
skip_header=1, dtype=np.float)
# data [row,column], zero indexed # extract entire column [:, x] #extract entire row [x,:]
# -------------------------------------#
# ------------- data setup ------------#
gyro_z = data[:, 6]
time = data[:, 0]
rows = data.shape[0] # no. of rows in array
# -------------------------------------#
# ------- initialize numpy arrays -----#
dif = np.zeros((rows, 1))
max_number = np.zeros((rows, 1))
maximum = np.empty((rows, 1))
# -------------------------------------#
for i in range(rows - 2):
# --------- Differentiation -------#
# v_dif = gyro_z[i+1]- gyro_z[i]
# t_dif = time[i+1] - time[i]
# dif[i] = v_dif/t_dif
# ---------------------------------#
# --------- Maximum ---------------#
if gyro_z[i] < gyro_z[i + 1] and gyro_z[i + 1] > gyro_z[i + 2]:
max_number[i] = 1 # iterable for total maximums
maximum[i + 1] = gyro_z[i + 1]
# ---------------------------------#
print('total number of maximums =', sum(max_number))
trace = go.Scatter(
x=time,
y=maximum,
mode='lines'
)
data = [trace]
py.plot(data, filename='file_name.html')