-
Notifications
You must be signed in to change notification settings - Fork 2
/
stepper.py
44 lines (39 loc) · 987 Bytes
/
stepper.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
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 6 20:52:52 2019
@author: pruth
"""
import pandas
import numpy as np
import matplotlib.pyplot as plt
import csv
import scipy.signal
filename = ('stepcounter.csv')
names = ['xacc', 'yacc', 'zacc']
data = pandas.read_csv(filename, names=names)
##print(data.shape)
##plt.plot(data)
readdata = csv.reader(open('stepcounter.csv', 'r'))
data = []
for row in readdata:
data.append(row)
q1 = []
for i in range(len(data)):
q1.append(float(data[i][0]))
for row in readdata:
data.append(row)
q2 = []
for i in range(len(data)):
q2.append(float(data[i][1]))
for row in readdata:
data.append(row)
q3 = []
for i in range(len(data)):
q3.append(float(data[i][2]))
tik= scipy.signal.argrelextrema(
np.array(q2),
comparator=np.greater,order = 1
)
#print('Peaks are:',(tik[0]))
print('{} steps'.format(len(tik[0])*2))
print('Total calories in kcal is {}'.format(len(tik[0])*0.00412))