draw graphs by_temp buckets daily
[zc] / www / cgi-bin / by_temp.cgi
1 #!/bin/sh
2
3 dir=/home/dpavlin/zc/gnuplot/
4
5 set > /dev/shm/cgi.env
6
7 echo "Content-type: image/svg+xml"
8 echo
9
10 #pn=$( basename $0 | sed 's/.cgi//' )
11 test -z "$QUERY_STRING" && QUERY_STRING='.'
12 numbers=$( grep "$QUERY_STRING" $dir/../subvision-numbers.txt | head -1 )
13 pn=$( echo $numbers | cut -d' ' -f2 )
14 temp_corr=$( echo $numbers | cut -d' ' -f5 )
15 test -z "$temp_corr" && temp_corr=0.00001
16
17 offset=$( grep "^$pn" $dir/offset.txt )
18 offset_x=$( echo $offset | cut -d' ' -f2 )
19 test -z "$offset_x" && offset_x=0
20 offset_y=$( echo $offset | cut -d' ' -f3 )
21 test -z "$offset_y" && offset_y=0
22
23
24 set > /dev/shm/by_temp.$pn.env
25
26 cat $dir/by_temp.sql | sed \
27         -e "s/2008050087/$pn/" \
28         -e "s/x_axis_angle/x_axis_angle + $offset_x/" -e "s/y_axis_angle/y_axis_angle + $offset_y/" \
29         -e "s/0.0001/$temp_corr/" \
30 | tee /dev/shm/by_temp.$pn.sql \
31 | psql --username=dpavlin -A -F "," -t zc \
32 | tee /dev/shm/by_temp.$pn.txt \
33 | awk -v pn=$pn -F, '{ print $1","$2","$3","$4 > "/dev/shm/by_temp."pn"."$5".txt" }'
34
35 cat $dir/by_temp.gnuplot | sed \
36         -e "s,\.pn\.,.$pn.," \
37         -e "s,^set terminal.*$,set terminal svg," \
38         -e "s,^set output.*$,set output," \
39 > /dev/shm/by_temp.$pn.gnuplot
40
41 gnuplot /dev/shm/by_temp.$pn.gnuplot
42
43 #rm /dev/shm/axes.txt.$$ /dev/shm/axes.gnuplot.$$