#!/bin/csh -f

set datadir = '../../csv'

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


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

$FC tminmax.f
./a.out
rm a.out datafile

gnuplot <<EOF
set term png
set out "Tmin-Lon.png"
unset key
unset colorbox
set datafile separator ","
set xdata time
set timefmt "%H:%M:%S"
set title "Time of minimum temperature"
set xrange ["09:30:00":"11:30:00"]
set format x "%H:%M"
set xlabel "Time"
set ylabel "Longitude (arcsec)"
plot 'minfile.csv' u 3:1 w p pt 5 ps 0.4 lc rgb "blue"
EOF

gnuplot <<EOF
set term png
set out "Tmin-Lat.png"
unset key
unset colorbox
set datafile separator ","
set xdata time
set timefmt "%H:%M:%S"
set title "Time of minimum temperature"
set xrange ["09:30:00":"11:30:00"]
set format x "%H:%M"
set xlabel "Time"
set ylabel "Latitude (arcsec)"
plot 'minfile.csv' u 3:2 w p pt 5 ps 0.4 lc rgb "blue"
EOF

gnuplot <<EOF
set term png
set out "Tmax-Lon.png"
unset key
unset colorbox
set datafile separator ","
set xdata time
set timefmt "%H:%M:%S"
set title "Time of maximum temperature"
set xrange ["09:30:00":"11:30:00"]
set format x "%H:%M"
set xlabel "Time"
set ylabel "Longitude (arcsec)"
plot 'maxfile.csv' u 3:1 w p pt 5 ps 0.4 lc rgb "red"
EOF

gnuplot <<EOF
set term png
set out "Tmax-Lat.png"
unset key
unset colorbox
set datafile separator ","
set xdata time
set timefmt "%H:%M:%S"
set title "Time of maximum temperature"
set xrange ["09:30:00":"11:30:00"]
set format x "%H:%M"
set xlabel "Time"
set ylabel "Latitude (arcsec)"
plot 'maxfile.csv' u 3:2 w p pt 5 ps 0.4 lc rgb "red"
EOF
