Code:
import pandas as pd
from collections import defaultdict
import matplotlib.pyplot as plt
def main():
with open(r'C:\Users\sarad\ss3.dat.log','r') as line:
table = defaultdict(dict)
for line in line:
if line:
entry = line.strip()
if ':' in entry:
t = entry
else:
if line.startswith("Sensor"):
_, sample,data = entry.split()
table[t].update({sample:float(data)})
print(type(data),data)
print(table)
df=pd.DataFrame(table).T
print(df)
df.plot()
plt.xticks(
ticks=range(len(df)),
labels=df.index,
rotation=45
)
plt.locator_params(axis='x',nbins=10)
plt.xlabel('Time')
plt.ylabel('Temperature')
plt.title('Temperature vs Time ')
plt.show()
main()
ss3.dat.log file is like
00:00:08
Sensor A 76.202574
Sensor B 76.199620
Sensor C 76.092497
Sensor D 76.120303
Sensor E 76.041031
Sensor F 77.463662
Sensor G 85.509276
Sensor H 112.226697
00:00:39
Sensor A 76.201118
Sensor B 76.199382
Sensor C 76.089885
Sensor D 76.118796
Sensor E 76.041040
Sensor F 77.464466
Sensor G 85.509370
Sensor H 112.226071
00:01:10
Sensor A 76.201070
Sensor B 76.193708
Sensor C 76.087995
Sensor D 76.119122
Sensor E 76.041150
Sensor F 77.464949
Sensor G 85.508649
Sensor H 112.225700
00:01:41
Sensor A 76.201223
Sensor B 76.199162
Sensor C 76.089856
Sensor D 76.118216
Sensor E 76.041759
Sensor F 77.465946
Sensor G 85.509358
Sensor H 112.225497
00:02:13
Sensor A 76.199548
Sensor B 76.198596
Sensor C 76.092475
Sensor D 76.121014
Sensor E 76.041773
Sensor F 77.466750
Sensor G 85.509600
Sensor H 112.225685
00:02:44
and so on.
Now I need to do a plot of the temperature gradient. Those float values are the temperatures. And 00:00:08
these values are the clock time. I need to find out the graph of (variation of temparature/ variation of time) with the temprature.(dT/dt vs time)