-
Notifications
You must be signed in to change notification settings - Fork 0
/
EagleData.py
146 lines (126 loc) · 5.64 KB
/
EagleData.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import csv
import json
import re
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
from matplotlib.widgets import Button
import pandas as pd
path = "C:\\Users\\Mahdyyar\\Desktop\\2581_data.csv"
path = "C:\\Users\\Mahdyyar\\Desktop\\2581_10.csv"
with open(path) as csvfile:
data = {}
data['lat'] = []
data['lng'] = []
spamreader = csv.reader(csvfile, delimiter=',', quotechar='\"')
for row in spamreader:
x = re.findall("\((.*?)\)", row[2])
for a in x:
y = re.findall("\'(.*?)\'", a)
if y[0] == "lng":
data['lng'].append(float(a.split(",")[1]))
elif y[0] == "lat":
data['lat'].append(float(a.split(",")[1]))
df = pd.DataFrame(data=data)
df.to_csv("lat_lng_data.csv")
datatype = "ignition"#"ignition"signalstrength
time = []
data = []
timesignalstrength = []
signalstrength = []
fig, ax = plt.subplots()
ax.set_autoscale_on(True)
ax.autoscale_view(True,True,True)
plt.subplots_adjust(bottom=0.2)
with open(path) as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='\"')
for row in spamreader:
x = re.findall("\((.*?)\)", row[2])
if ("-07") in row[1]:
for a in x:
y = re.findall("\'(.*?)\'", a)
if y[0] == datatype and len(time) < 2000000:
# print(row[1])
datetime_object = datetime.strptime(row[1], '%Y-%m-%d %H:%M:%S')
time.append(datetime_object)
data.append(int(a.split(",")[1]))
# print(a)
elif y[0] == "signalstrength":
datetime_object = datetime.strptime(row[1], '%Y-%m-%d %H:%M:%S')
timesignalstrength.append(datetime_object)
signalstrength.append(int(a.split(",")[1]))
elif len(time) > 2000:
print("ecceeded")
l, = plt.plot(time, data, 'o-')
class Index:
ind = 26
def next(self, event):
self.ind += 1
print("{0:0=2d}".format(self.ind))
if self.ind > 31:
self.ind = 1
with open(path) as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='\"')
time.clear()
data.clear()
for row in spamreader:
x = re.findall("\((.*?)\)", row[2])
if ("-"+"{0:0=2d}".format(self.ind)) in row[1]:
for a in x:
y = re.findall("\'(.*?)\'", a)
if y[0] == datatype and len(time) < 2000000:
# print(row[1])
datetime_object = datetime.strptime(row[1], '%Y-%m-%d %H:%M:%S')
time.append(datetime_object)
data.append(int(a.split(",")[1]))
# print(a)
elif y[0] == "signalstrength":
datetime_object = datetime.strptime(row[1], '%Y-%m-%d %H:%M:%S')
timesignalstrength.append(datetime_object)
signalstrength.append(int(a.split(",")[1]))
elif len(time) > 2000:
print("ecceeded")
# plt.scatter(time, data)
ax.axis([min(time), max(time), min(data), max(data)])
l.set_ydata(data)
l.set_xdata(time)
# plt.scatter(timesignalstrength, signalstrength)
# plt.xticks(rotation = 90) # Rotates X-Axis Ticks by 45-degrees
plt.draw()
def prev(self, event):
self.ind -= 1
print("{0:0=2d}".format(self.ind))
time.clear()
data.clear()
with open(path) as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='\"')
for row in spamreader:
x = re.findall("\((.*?)\)", row[2])
if ("-"+"{0:0=2d}".format(self.ind)) in row[1]:
for a in x:
y = re.findall("\'(.*?)\'", a)
if y[0] == "ignition" and len(time) < 2000000:
# print(row[1])
datetime_object = datetime.strptime(row[1], '%Y-%m-%d %H:%M:%S')
time.append(datetime_object)
data.append(int(a.split(",")[1]))
# print(a)
elif y[0] == "signalstrength":
datetime_object = datetime.strptime(row[1], '%Y-%m-%d %H:%M:%S')
timesignalstrength.append(datetime_object)
signalstrength.append(int(a.split(",")[1]))
elif len(time) > 2000:
print("ecceeded")
l.set_ydata(data)
l.set_xdata(time)
ax.axis([min(time), max(time), min(data), max(data)])
plt.draw()
callback = Index()
axprev = plt.axes([0.7, 0.05, 0.1, 0.075])
axnext = plt.axes([0.81, 0.05, 0.1, 0.075])
bnext = Button(axnext, 'Next')
bnext.on_clicked(callback.next)
bprev = Button(axprev, 'Previous')
bprev.on_clicked(callback.prev)
plt.xticks(rotation = 90) # Rotates X-Axis Ticks by 45-degrees
plt.show()