added temperature correction
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 29 Oct 2020 10:46:04 +0000 (11:46 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 29 Oct 2020 10:46:04 +0000 (11:46 +0100)
gnuplot/by_day.sql
subvision-numbers.txt
www/cgi-bin/by_day.cgi

index f138f63..2ee08bd 100644 (file)
@@ -1,7 +1,7 @@
 select 
 to_char(min(time), 'YYYY-MM-DD HH24') as time,
 avg(x_axis_angle) ,
-avg(y_axis_angle) - ( ( 20 - avg(sensor_temperature) ) * 0.0001 ),
+avg(y_axis_angle) - ( ( (select avg(sensor_temperature) from zc where pn = 2008050087) - avg(sensor_temperature) ) * 0.0001 ),
 avg(sensor_temperature) 
 from zc
 where pn = 2008050087 -- and time > now() - interval '24 hours'
index 2cc13cc..a821b8e 100644 (file)
@@ -1,10 +1,10 @@
 dalibor 2008050077 864823042077032 
-2OI-000117 2008050078 864823042077040 rijeka
+2OI-000117 2008050078 864823042077040 rijeka 0.0001
 2OI-000120 2008050079 864823042076968 rijeka
-2OI-000116 2008050080 864823042076976 rijeka
-2OI-000115 2008050082 864823042076901 rijeka
-2OI-000118 2008050083 864823042076745 rijeka
-2OI-000119 2008050084 864823042076679 rijeka
+2OI-000116 2008050080 864823042076976 rijeka 0.006
+2OI-000115 2008050082 864823042076901 rijeka 0.005
+2OI-000118 2008050083 864823042076745 rijeka 0.001
+2OI-000119 2008050084 864823042076679 rijeka 0.002
 2OI-000214 2008050081 864823042077008 rijeka
 balkon 2008050086 864823042077016 
 dobrica 2008050087 864823042076992 
index c69f055..ccbd89c 100755 (executable)
@@ -9,16 +9,25 @@ echo
 
 #pn=$( basename $0 | sed 's/.cgi//' )
 test -z "$QUERY_STRING" && QUERY_STRING='.'
-pn=$( grep "$QUERY_STRING" $dir/../subvision-numbers.txt | head -1 | cut -d' ' -f2 )
+numbers=$( grep "$QUERY_STRING" $dir/../subvision-numbers.txt | head -1 )
+pn=$( echo $numbers | cut -d' ' -f2 )
+temp_corr=$( echo $numbers | cut -d' ' -f5 )
+test -z "$temp_corr" && temp_corr=0.00001
+
 offset=$( grep "^$pn" $dir/offset.txt )
 offset_x=$( echo $offset | cut -d' ' -f2 )
-offset_y=$( echo $offset | cut -d' ' -f3 )
 test -z "$offset_x" && offset_x=0
+offset_y=$( echo $offset | cut -d' ' -f3 )
 test -z "$offset_y" && offset_y=0
 
+
+set > /dev/shm/$pn.env
+
 cat $dir/by_day.sql | sed \
        -e "s/2008050087/$pn/" \
        -e "s/x_axis_angle/x_axis_angle + $offset_x/" -e "s/y_axis_angle/y_axis_angle + $offset_y/" \
+       -e "s/0.0001/$temp_corr/" \
+| tee /dev/shm/$pn.sql \
 | psql --username=dpavlin -A -F "," -t zc > /dev/shm/$pn.txt-by-day
 
 cat $dir/template.gnuplot | sed \