sshmax2png.sh 1.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#!/bin/bash

EWPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../utils" && pwd )"
SSHFILE=eWave.2D.sshmax
FONT=$EWPATH/FreeMonoBold.ttf

# Check command line parameters
VMIN=0.1
VMAX=10.

while test $# -gt 0; do
  case "$1" in
    -h|--help)
	echo ""
  	echo "Usage: sshmax2png.sh [scaleMin scaleMax]"
  	echo "   where optional scale is given in meters, default scale- from 0.1 to 10 m"
  	echo "   avoid using 0 as ScaleMin because of logarithmic scale!"
        exit 0
        ;;
    -grd)
        shift
        if test $# -gt 0; then
       	  f=$1  
        else
          echo "Error: no grid specified."
          exit 1
        fi
        shift
        ;;
    -ssh)
	shift
	if test $# -gt 0; then
          SSHFILE=$1
        else
          echo "Error: no ssh file specified."
          exit 1
        fi
  esac
done

# Check number of grd-files in current directory
# We assume presence of a single grd -- bathymetry
ngrids=0
if test "$f" = ""; then
  for f in *.grd
  do
    ngrids=$((ngrids+1))
  done
  if [ $ngrids -gt 1 ]; then
    echo "More than one grid. Do not know which one to use!"
    exit 2
  fi
fi

# Execute converter
$EWPATH/ew2png -grdB $f -palB $EWPATH/topo4sshmaxBW.cpt -transparency 0.001 -grdW $SSHFILE -palW $EWPATH/sshmax.rel.cpt -log -minmax $VMIN $VMAX -legend scale+range -font $FONT