#!/bin/csh -f

set datadir = '../out'
set amedas  = 'amedas.dat'

set dT = 0.0
#set dT = -0.3

set Tmax = 23.5
set Tmin = 20.5

set NKF = '/usr/bin/nkf'
set FC  = '/usr/bin/gfortran'


cat ${datadir}/P*.dat > datafile
$NKF -Lu --overwrite datafile

$FC calcmean.f
./a.out > tmean.csv

gnuplot <<EOF
set term png
set out "TAmean.png"
unset key
unset colorbox
set datafile separator ","
set xdata time
set timefmt "%H:%M:%S"
set title "Temperature"
set xrange ["09:30:00":"11:30:00"]
set format x "%H:%M"
set xlabel "Time"
set ylabel "Temperature (degree C)"
set yrange [${Tmin}:${Tmax}]
plot 'tmean.csv' u 1:(\$2+${dT}):3 with errorbars pt 5 ps 0.4 lc rgb "red", 'amedas.csv' u 1:5 w p pt 5 ps 2 lc rgb "blue"
EOF

rm a.out datafile
