#!/bin/sh
set -x

# Verzamel de rooster definities.

. ./LONLAT.def

# Haal het land/zee masker op.

./getfield `ls -1t /data/hirlam/hl_home/OPR/mf2*f | head -1` landseamask > landseamask.txt.orig

# Maak de rgb image land / zee kaart aan:

awk '{print $1, $2, $3, 0, $3 * 127, (1 - $3) * 127, 255}' landseamask.txt.orig | \
    sed -e 's/^   0 0 127 255$//' > landseamask.txt

gnuplot << EOF
   set terminal png truecolor size $XMAP,$YMAP
   set output 'landzeekaart.png'
   set view map
   unset colorbox
   $XRANGE
   $YRANGE
   set title 'Land / Zee kaart'
   splot 'landseamask.txt' notitle with rgbimage
EOF

gnuplot << EOF
   set terminal postscript landscape color
   set output 'landzeekaart.ps'
   set view map
   unset colorbox
   $XRANGE
   $YRANGE
   set title 'Land / Zee kaart'
   splot 'landseamask.txt' notitle with rgbimage
EOF

# Genereer de "kust" lijn kaart voor later gebruik:

awk '$3 > 0.2 && $3 < 0.8 {print $1, $2, $3}' landseamask.txt.orig > coastline.txt

exit 0
