|
@@ -0,0 +1,64 @@
|
|
1
|
+#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+from influxdb import InfluxDBClient
|
|
4
|
+import matplotlib.pyplot as plt
|
|
5
|
+import matplotlib
|
|
6
|
+from datetime import datetime
|
|
7
|
+
|
|
8
|
+# config
|
|
9
|
+host = '10.23.42.14'
|
|
10
|
+port = 8086
|
|
11
|
+user = 'root'
|
|
12
|
+password = 'root'
|
|
13
|
+dbname = 'giessomat'
|
|
14
|
+
|
|
15
|
+# data
|
|
16
|
+client = InfluxDBClient(host, port, user, password, dbname)
|
|
17
|
+print("Querying DB " + dbname + " on " + host)
|
|
18
|
+result = client.query('SELECT "duration" FROM "calibrated_filling";')
|
|
19
|
+#print("Result: {0}".format(result))
|
|
20
|
+
|
|
21
|
+data = list(result.get_points())
|
|
22
|
+print("Got " + str(len(data)) + " datapoints")
|
|
23
|
+#print(data)
|
|
24
|
+
|
|
25
|
+times = ([datetime.strptime(d['time'], '%Y-%m-%dT%H:%M:%S.%fZ') for d in data])
|
|
26
|
+durations = ([d['duration'] for d in data])
|
|
27
|
+
|
|
28
|
+max_t = max(durations)
|
|
29
|
+min_t = min(durations)
|
|
30
|
+
|
|
31
|
+simple_average = min_t + ((max_t - min_t) / 2)
|
|
32
|
+average = 0
|
|
33
|
+for d in durations:
|
|
34
|
+ average += d
|
|
35
|
+average /= len(durations)
|
|
36
|
+
|
|
37
|
+sorted_durations = sorted(durations)
|
|
38
|
+median = sorted_durations[int(len(sorted_durations) / 2)]
|
|
39
|
+
|
|
40
|
+print("Min. Filling Time: " + str(min_t))
|
|
41
|
+print("Max. Filling Time: " + str(max_t))
|
|
42
|
+print("Average Filling Time:")
|
|
43
|
+print(" Simple = " + str(simple_average))
|
|
44
|
+print(" Average = " + str(average))
|
|
45
|
+print(" Median = " + str(median))
|
|
46
|
+
|
|
47
|
+# plot results
|
|
48
|
+plt.ioff()
|
|
49
|
+
|
|
50
|
+# ---------------------------
|
|
51
|
+
|
|
52
|
+fig, ax = plt.subplots()
|
|
53
|
+
|
|
54
|
+dates = matplotlib.dates.date2num(times)
|
|
55
|
+ax.plot_date(dates, durations, '-', label='filling')
|
|
56
|
+
|
|
57
|
+ax.set_xlabel('Time')
|
|
58
|
+ax.set_ylabel('Duration')
|
|
59
|
+ax.set_title('Filling Durations')
|
|
60
|
+ax.legend()
|
|
61
|
+
|
|
62
|
+# ---------------------------
|
|
63
|
+
|
|
64
|
+plt.show()
|