added temperature correction
[zc] / www / cgi-bin / by_day.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/$pn.env
25
26 cat $dir/by_day.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/$pn.sql \
31 | psql --username=dpavlin -A -F "," -t zc > /dev/shm/$pn.txt-by-day
32
33 cat $dir/template.gnuplot | sed \
34         -e "s,axes.txt,/dev/shm/$pn.txt-by-day," \
35         -e "s,^set terminal.*$,set terminal svg," \
36         -e "s,^set output.*$,set output," \
37 > /dev/shm/$pn.gnuplot
38
39 gnuplot /dev/shm/$pn.gnuplot
40
41 #rm /dev/shm/axes.txt.$$ /dev/shm/axes.gnuplot.$$