-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplotTemp_PT1000.py
More file actions
executable file
·155 lines (129 loc) · 4.76 KB
/
plotTemp_PT1000.py
File metadata and controls
executable file
·155 lines (129 loc) · 4.76 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
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
144
145
146
147
148
149
150
151
152
153
154
155
#! /usr/bin/python3
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from time import sleep, strftime, time
from datetime import datetime
import sys
import argparse
import os
# define dm
file=sys.argv[1]
nPointsOffset = 5
plt.ion()
mytime = []
mysecs = []
TCopperR= []
TCopperL= []
TTopL= []
TTopR= []
TBottomL= []
TBottomR= []
DeltaTTopL= []
DeltaTTopR= []
DeltaTBottomL= []
DeltaTBottomR= []
# draw function ---
def graph():
plt.clf()
axes = plt.gca()
plt.subplot(211)
plt.plot(mysecs,TCopperL,color='black',linestyle='dotted',label='copper left')
plt.plot(mysecs,TCopperR,color='black',linestyle='dashed',label='copper right')
plt.plot(mysecs,TTopL,color='red',label='top left')
plt.plot(mysecs,TTopR,color='orange',label='top right')
plt.plot(mysecs,TBottomL,color='blue',label='bottom left')
plt.plot(mysecs,TBottomR,color='green',label='bottom right')
plt.xlabel("time elapsed [min.]")
plt.ylabel("temperature [C]")
plt.grid()
plt.ylim([15.,50.])
plt.legend()
plt.subplot(212)
plt.plot(mysecs,DeltaTTopL,color='red',label='top left')
plt.plot(mysecs,DeltaTTopR,color='orange',label='top right')
plt.plot(mysecs,DeltaTBottomL,color='blue',label='bottom left')
plt.plot(mysecs,DeltaTBottomR,color='green',label='bottom right')
plt.xlabel("time elapsed [min.]")
plt.ylabel("Delta T [C]")
plt.grid()
plt.ylim([-30.,3.])
plt.legend()
plt.text(0.15,-10,'max. $\Delta$T = %.2f C'%DeltaTTopLMin, color='red')
plt.text(0.15,-11,'max. $\Delta$T = %.2f C'%DeltaTTopRMin, color='orange')
plt.text(0.15,-12,'max. $\Delta$T = %.2f C'%DeltaTBottomLMin, color='blue')
plt.text(0.15,-13,'max. $\Delta$T = %.2f C'%DeltaTBottomRMin, color='green')
plt.show()
TCopperROffset = 0.
TCopperLOffset = 0.
TTopLOffset = 0.
TTopROffset = 0.
TBottomLOffset = 0.
TBottomROffset = 0.
DeltaTTopLMin = 999.
DeltaTTopRMin = 999.
DeltaTBottomLMin = 999.
DeltaTBottomRMin = 999.
# reading log file
it = 0
with open(str(file), 'r') as fin:
#for line in fin.readlines() [-200]:
for line in fin.readlines():
readings = line.strip().split()
if len(readings) != 8:
continue;
mytime.append(datetime.strptime(readings[0]+" "+readings[1], "%Y-%m-%d %H:%M:%S"))
if len(mysecs) == 0:
mysecs.append(0)
else:
mysecs.append((mytime[-1]-mytime[0]).total_seconds()/60.)
TCopperR.append(float(readings[2]))
TCopperL.append(float(readings[3]))
TTopL.append(float(readings[4]))
TTopR.append(float(readings[5]))
TBottomL.append(float(readings[6]))
TBottomR.append(float(readings[7]))
# calibration points
if it < nPointsOffset:
TCopperROffset += TCopperR[-1]
TCopperLOffset += TCopperL[-1]
TTopLOffset += TTopL[-1]
TTopROffset += TTopR[-1]
TBottomLOffset += TBottomL[-1]
TBottomROffset += TBottomR[-1]
elif it == nPointsOffset:
TCopperROffset /= nPointsOffset
TCopperLOffset /= nPointsOffset
TTopLOffset /= nPointsOffset
TTopROffset /= nPointsOffset
TBottomLOffset /= nPointsOffset
TBottomROffset /= nPointsOffset
offset = 0.
# correcting temperatures for T offset
if it >= nPointsOffset:
offset = TTopLOffset - TCopperLOffset
#offset = 0.
DeltaTTopL.append( TTopL[-1]-TCopperL[-1]-offset )
if (TTopL[-1]-TCopperL[-1]-offset) < DeltaTTopLMin:
DeltaTTopLMin = (TTopL[-1]-TCopperL[-1]-offset)
if it >= nPointsOffset:
offset = TTopROffset - TCopperROffset
#offset = 0.
DeltaTTopR.append( TTopR[-1]-TCopperR[-1]-offset )
if (TTopR[-1]-TCopperR[-1]-offset) < DeltaTTopRMin:
DeltaTTopRMin = (TTopR[-1]-TCopperR[-1]-offset)
if it >= nPointsOffset:
offset = TBottomLOffset - TCopperLOffset
#offset = 0.
DeltaTBottomL.append( TBottomL[-1]-TCopperL[-1]-offset )
if (TBottomL[-1]-TCopperL[-1]-offset) < DeltaTBottomLMin:
DeltaTBottomLMin = (TBottomL[-1]-TCopperL[-1]-offset)
if it >= nPointsOffset:
offset = TBottomROffset - TCopperROffset
#offset = 0.
DeltaTBottomR.append( TBottomR[-1]-TCopperR[-1]-offset )
if (TBottomR[-1]-TCopperR[-1]-offset) < DeltaTBottomRMin:
DeltaTBottomRMin = (TBottomR[-1]-TCopperR[-1]-offset)
print(str(readings[1])+" "+str(readings[2])+" "+str(readings[3])+" "+str(readings[4])+" "+str(readings[5])+" "+str(readings[6])+" "+str(readings[7]))
it += 1
graph()
input('ok?')