summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplot.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/plot.py b/plot.py
index 535398e..647a083 100755
--- a/plot.py
+++ b/plot.py
@@ -13,6 +13,7 @@
import sys
import subprocess
import os
+import math
from string import Template
if len(sys.argv) != 3:
@@ -28,7 +29,7 @@ argmax = 50000
# If you change this you also need to change the create and graph lists below.
# Also note that samples have to be in the same order every time (the key is currently ignored).
-samples_per_line=3
+samples_per_line=2
template_values = {
# 0 = everything from the input
@@ -45,7 +46,8 @@ create = [
'DS:temp1:GAUGE:50:U:U',
'DS:temp2:GAUGE:50:U:U',
- 'DS:hum1:GAUGE:50:U:U',
+ #'DS:hum1:GAUGE:50:U:U',
+ 'DS:abshum1:GAUGE:50:U:U',
'RRA:AVERAGE:0.5:1:$total_samples',
'RRA:MIN:0.5:1:$total_samples',
@@ -61,10 +63,10 @@ graph = [
'--color=BACK#FFFFFF',
#'--title','Temperature',
'--vertical-label', 'Temperature °C',
- '--right-axis-label', 'Humidity %',
- '--right-axis', '2:0',
- '--alt-autoscale',
- #'-l','25','-u','30',
+ '--right-axis-label', 'Humidity g/m³',
+ '--right-axis', '0.5:0',
+ #'--alt-autoscale',
+ '-l','10','-u','35', '--rigid',
'--left-axis-format', '%4.2lf',
'--right-axis-format', '%4.2lf',
@@ -72,9 +74,12 @@ graph = [
'LINE1:temp1#339966:temp 1\l',
'DEF:temp2='+rrd_file+':temp2:AVERAGE',
'LINE1:temp2#663399:temp 2\l',
- 'DEF:hum1='+rrd_file+':hum1:AVERAGE',
- 'CDEF:hum11=hum1,2,/',
- 'LINE1:hum11#996633:hum 1\l',
+ #'DEF:hum1='+rrd_file+':hum1:AVERAGE',
+ #'CDEF:hum11=hum1,2,/',
+ #'LINE1:hum11#996633:hum 1\l',
+ 'DEF:abshum1='+rrd_file+':abshum1:AVERAGE',
+ 'CDEF:abshum11=abshum1,2,*',
+ 'LINE1:abshum11#996633:abshum 1\l',
]
#### end of config
@@ -100,6 +105,14 @@ with open(log_file,"r") as f:
# values
for i in range(1, samples_per_line + 1):
values.append(float(elem[i].split("=")[1]))
+
+ # absolute humidity
+ hum=float(elem[3].split("=")[1])
+ temp=values[2]
+ # Source: https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/
+ abshum=(6.112 * math.e**(17.67 * temp / (temp + 243.5)) * hum * 2.1674) / (273.15+temp)
+ values.append(abshum)
+
samples.append(values)
# create rrd