This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTempParser.py
executable file
·53 lines (42 loc) · 1.78 KB
/
TempParser.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
#!/usr/bin/env python3
import argparse
import os
import codecs
import datetime
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.dates import date2num, num2date
cpu = {'time': [], 'temp': []}
gpu = {'time': [], 'temp': []}
def parse_raw(file_path):
with codecs.open(file_path, 'r', 'iso-8859-1') as temp_file:
for line in temp_file:
data = line.split()
if (len(data) < 9):
continue
date = data[2].split('/')
time = data[3].split(':')
time[2] = time[2].split('.')
timestamp = datetime.datetime(int(date[2]), int(date[0]), int(date[1]),
int(time[0]), int(time[1]), int(time[2][0]), int(time[2][1]))
cpu["time"].append(timestamp)
cpu["temp"].append(float(data[6]))
gpu["time"].append(timestamp)
gpu["temp"].append(float(data[8]))
matplotlib.rcParams.update({'font.size': 100})
plt.figure(figsize=(max(len(cpu['time'])/2, 200), 110))
plt.title('Temperature', fontsize=200)
plt.xlabel('Time', fontsize=150)
plt.ylabel('Temperature (°C)', fontsize=150)
plt.plot(cpu['time'], cpu['temp'], 'g-', linewidth=10.0)
plt.plot(gpu['time'], gpu['temp'], 'b-', linewidth=10.0)
plt.ylim((0, 110))
plt.savefig('temperature.svg')
print("Min / Max GPU temp: %f°C / %f°C" % (min(gpu['temp']), max(gpu['temp'])))
print("Min / Max CPU temp: %f°C / %f°C" % (min(cpu['temp']), max(cpu['temp'])))
parser = argparse.ArgumentParser(description='Process OpenStratos temperature data')
parser.add_argument('file', metavar='FILE', type=str, nargs=1,
help='the file containing temperature data')
args = parser.parse_args()
path = os.path.join(os.path.dirname(__file__), args.file[0])
parse_raw(path)