-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotTemp_PT1000_multiArduino.py
More file actions
96 lines (67 loc) · 2.45 KB
/
plotTemp_PT1000_multiArduino.py
File metadata and controls
96 lines (67 loc) · 2.45 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
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
from collections import defaultdict
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from time import sleep, strftime, time
from datetime import datetime
import sys
from optparse import OptionParser
sys.path.append("/home/cmsdaq/Lab5015Utils/")
from Lab5015_utils import read_arduino_temp
parser = OptionParser()
parser.add_option("--inFile","--inFile")
(options,args)=parser.parse_args()
plt.ion()
mytime = []
mytemps = defaultdict(list)
labels = []
labels.append("LYSO")
labels.append("dissipator side")
labels.append("Cold Plate")
labels.append("hot TEC side")
labels.append("SiPMS")
labels.append("Humidity")
labels.append("Air Temperature")
def graph():
plt.clf()
plt.grid(b=True,which='major')
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))
plt.gca().xaxis.set_major_locator(mdates.MinuteLocator(interval=30))
axes = plt.gca()
axes.set_ylim([0.,40.])
for sensor,data in mytemps.items():
plt.plot(mytime,data,label=labels[int(sensor)])
plt.legend()
plt.gcf().autofmt_xdate()
plt.gcf().autofmt_xdate()
plt.show()
if options.inFile == "live":
while True:
temps = read_arduino_temp()
out = ""
for position in range(len(temps)):
mytemps[position].append(float(temps[position]))
out += str(temps[position])+" "
time = datetime.now()
mytime.append(time)
print(time.strftime("%Y-%m-%d %H:%M:%S")+" "+out )
graph()
plt.pause(1)
else:
with open(str(options.inFile), 'r') as fin:
for line in fin.readlines() [-20000:]:
readings = line.strip().split()
nreadings = len(readings)
mytime.append(datetime.strptime(readings[0]+" "+readings[1], "%Y-%m-%d %H:%M:%S"))
for position in range(4,nreadings):
#if isinstance(position, float):
mytemps[position-4].append(float(readings[position]))
while True:
with open(str(options.inFile), 'r') as fin:
for line in fin.readlines() [-1:]:
readings = line.strip().split()
nreadings = len(readings)
mytime.append(datetime.strptime(readings[0]+" "+readings[1], "%Y-%m-%d %H:%M:%S"))
for position in range(4,nreadings):
mytemps[position-4].append(float(readings[position]))
graph()
plt.pause(1)