#!/bin/csh -f

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

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


set latoverlon = 1.216
set xmin  =  5.0
set xmax  = 35.0
set ymin  =  5.0
set ymax  = 30.0
set dTmin =  2.0
set dTmax =  8.0


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


$FC minmax.f
./a.out > minmax.csv

gnuplot <<EOF
set term png
set out "dT.png"
unset key
set datafile separator ","
plot 'minmax.csv' u 0:(\$2-\$1)
EOF

gnuplot <<EOF
set term png
set out "Tminmax.png"
unset key
set datafile separator ","
plot 'minmax.csv' u 0:1, 'minmax.csv' u 0:2
EOF

gnuplot <<EOF
set term png
set out "WSminmax.png"
unset key
set datafile separator ","
plot 'minmax.csv' u 0:3, 'minmax.csv' u 0:4
EOF

#gnuplot <<EOF
#set term png
#set out "WDminmax.png"
#unset key
#set datafile separator ","
#plot 'minmax.csv' u 0:5, 'minmax.csv' u 0:6
#EOF

#rm a.out datafile
rm a.out


$FC dTloc.f
./a.out < minmax.csv > dT-location.dat

gnuplot <<EOF
set term png
set out "dTmap.png"
unset key
set title 'dT (MAX-MIN)'
set size ratio ${latoverlon}
set xrange [${xmin}:${xmax}]
set yrange [${ymin}:${ymax}]
set cbrange [${dTmin}:${dTmax}]
unset ztics
set palette rgbformulae 33,13,10
plot "dT-location.dat" u 1:2:3 lc palette pt 7 ps 2.0
EOF
