#!/bin/sh
set -x

dtg=$1
todir=$HOME/public_html/$dtg
[ -s $todir/landuse.png ] && exit # Already done.

year=`$HOME/bin/mandtg -year $dtg`
month=`$HOME/bin/mandtg -month $dtg`
day=`$HOME/bin/mandtg -day $dtg`
hour=`$HOME/bin/mandtg -hour $dtg`
maand=`echo $month | sed s/^0//`
dag=`echo $day | sed s/^0//`

maanden=(maandnul januari februari maart april mei juni juli augustus september oktober november december)

$HOME/PlotsOfTheDay/landuse /data/hirlam/hl_arc/OPR/$year/$month/$day/$hour/fc${year}${month}${day}_18+000 > landuse.txt

. $HOME/PlotsOfTheDay/LONLAT.def

gnuplot << EOF
   set terminal png truecolor size $XMAP,$YMAP
   set output 'landuse.png'
   set view map
   set palette model RGB defined (1 'blue', 2 'white', 3 'yellow', 4 'green', 5 'dark-green')
   unset colorbox
   $XRANGE
   $YRANGE
   set zrange [1:5]
   set cbrange [1:5]
   set title 'Landgebruik $dag ${maanden[$maand]} (blauw: water; wit: ijs; geel: kale grond; groen: lage vegetatie; donkergroen: bos)'
   splot 'landuse.txt' notitle with points palette pointtype 5
EOF

gnuplot << EOF
   set terminal postscript landscape color
   set output 'landuse.ps'
   set view map
   set palette model RGB defined (1 'blue', 2 'white', 3 'yellow', 4 'green', 5 'dark-green')
   unset colorbox
   $XRANGE
   $YRANGE
   set zrange [1:5]
   set cbrange [1:5]
   set title 'Landgebruik $dag ${maanden[$maand]} (blauw: water; wit: ijs; geel: kale grond; groen: lage vegetatie; donkergroen: bos)'
   splot 'landuse.txt' notitle with points palette pointtype 5
EOF

mv landuse.png landuse.ps $todir
rm landuse.txt

exit 0
