-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotInitial.py
More file actions
59 lines (49 loc) · 2.08 KB
/
plotInitial.py
File metadata and controls
59 lines (49 loc) · 2.08 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
import numpy as np
import matplotlib.pyplot as plt
import os
from datetime import datetime
from string import digits
def plot_initial(plot_type, title):
dataLocation = "./Recordings/SoftwareProject/"
os.listdir(dataLocation)
singleBlinkLoc = dataLocation + plot_type
# print(os.listdir(singleBlinkLoc)[0])
singleBlinkLoc = singleBlinkLoc + os.listdir(singleBlinkLoc)[0]
dataStartLine = 6
singleBlinkRaw = []
count = 0
for line in open(singleBlinkLoc, 'r').readlines():
if count >= dataStartLine:
singleBlinkRaw.append(line.strip().split(','))
else:
count += 1
singleBlinkRaw = np.char.strip(np.array(singleBlinkRaw))
granularity = 10
# getting just the data channels recorded
singleBlinkChannels = singleBlinkRaw[:, 1:5]
singleBlinkTime = singleBlinkRaw[:, 8:9]
timeThing = "15:30:25.402"
datetime_object = datetime.strptime(timeThing, '%H:%M:%S.%f')
data = singleBlinkChannels[:,0][::granularity]
channel0 = singleBlinkChannels[:,0][:500:granularity]
channel1 = singleBlinkChannels[:,1][:500:granularity]
channel2 = singleBlinkChannels[:,2][:500:granularity]
channel3 = singleBlinkChannels[:,3][:500:granularity]
plt.plot(np.arange(len(channel0)), channel0.astype(float), label = 'Channel 0')
plt.plot(np.arange(len(channel1)), channel1.astype(float), label = 'Channel 1')
plt.plot(np.arange(len(channel2)), channel2.astype(float), label = 'Channel 2')
plt.plot(np.arange(len(channel3)), channel3.astype(float), label = 'Channel 3')
plt.xlabel('Granularity 10')
plt.ylabel('Hz')
plt.title(title)
plt.legend(loc = 'center right')
plt.savefig("./Plots/RAW/" + title + '.png')
plt.clf()
def plotRawData():
dataLocation = "./Recordings/SoftwareProject/"
inputs = os.listdir(dataLocation)
for input_ in inputs:
# getting the name from the file name and removing numbers and extension from the name
title = input_.split("-")[-1].split(".")[0].translate({ord(k): None for k in digits})
plot_initial(input_ + '/', title)
plotRawData()