Read the csv file with acceloremeter information. Convert the data in file to numpy array and then plot it.
In [63]:
import csv
import numpy as np
import matplotlib.pyplot as plt
Open the CSV file and transform to an array. Also get number of samples
In [71]:
with open('../dataset/PhysicsToolboxSuite/walk_normal_hand_001.csv', 'rb') as csvfile:
data_reader = csv.reader(csvfile, delimiter = ',')
data = np.asarray(list(data_reader))
Convert data into separate variables (arrays)
In [72]:
timevec_str = data[1:-1,0]
timevec = timevec_str.astype(np.float)
gFx_str = data[1:-1,1]
gFx = gFx_str.astype(np.float)
gFy_str = data[1:-1,2]
gFy = gFy_str.astype(np.float)
gFz_str = data[1:-1,3]
gFz = gFz_str.astype(np.float)
TgF_str = data[1:-1,4]
TgF = TgF_str.astype(np.float)
NumSamples = len(timevec);
TimeDuration = timevec[NumSamples-1] - timevec[0];
In [73]:
msg = 'Number of samples = ' + repr(NumSamples)
print msg
msg = 'Duration of sample = ' + repr(TimeDuration) + ' seconds'
print msg
print ' '
print timevec
print gFx
print gFy
print gFz
print TgF
Plotting graphs of variables
In [74]:
fig = plt.figure()
plt.figure(figsize=(16,8))
plt.plot(timevec,TgF,label="TgF")
plt.grid(linestyle='-', linewidth=1)
plt.legend(loc='upper right')
plt.show()
fig = plt.figure()
plt.figure(figsize=(16,8))
plt.plot(timevec,gFx,label="gFx",color="blue")
plt.plot(timevec,gFy,label="gFy",color="red")
plt.plot(timevec,gFz,label="gFz",color="green")
plt.grid(linestyle='-', linewidth=1)
plt.legend(loc='upper right')
plt.show()
In [75]:
# Parameters to setup
# idx_ini = 0
# idx_end = NumSamples
idx_ini = 0
idx_end = 120
# Extract range
timevec_zoom = timevec[idx_ini:idx_end]
gFx_zoom = gFx[idx_ini:idx_end]
gFy_zoom = gFy[idx_ini:idx_end]
gFz_zoom = gFz[idx_ini:idx_end]
TgF_zoom = TgF[idx_ini:idx_end]
NumSamples_zoom = len(timevec_zoom);
TimeDuration_zoom = timevec[idx_end-1] - timevec[idx_ini];
In [76]:
msg = 'Number of samples of zoom = ' + repr(NumSamples_zoom)
print msg
msg = 'Duration of sample of zoom = ' + repr(TimeDuration_zoom) + ' seconds'
print msg
In [77]:
fig = plt.figure()
plt.figure(figsize=(16,8))
plt.plot(timevec_zoom,TgF_zoom,'b-o',label="TgF")
plt.grid(linestyle='-', linewidth=1)
plt.legend(loc='upper right')
plt.show()
fig = plt.figure()
plt.figure(figsize=(16,8))
plt.plot(timevec_zoom,gFx_zoom,'b-o',label="gFx",color="blue")
plt.plot(timevec_zoom,gFy_zoom,'r-o',label="gFy",color="red")
plt.plot(timevec_zoom,gFz_zoom,'g-o',label="gFz",color="green")
plt.grid(linestyle='-', linewidth=1)
plt.legend(loc='upper right')
plt.show()
In [ ]: