Yikes

Here is a script (uses sh instead of csh) that I stole from Bob Smalley. It comes with no warranties, expressed or implied, and don't ask me or Bob to help you with it. If you can make it work, then you are entering nerddom and probably haven't shaved for several days. If you can figure out how it works and how to change it, you are already in nerddom and probably haven't showered for several days.


#!/bin/sh

#set defaults
WHITE=255
LTGRAY=192
VLTGRAY=225
EXTGRAY=250
GRAY=128
BLACK=0

RED=250/0/0
DKRED=196/50/50
BLUE=0/0/255
GREEN=0/255/0
YELLOW=255/255/50
ORANGE=255/192/50
PURPLE=255/50/255
CYAN=50/255/255
LTBLUE=192/192/250
VLTBLUE=225/250/250
LTRED=250/225/225
PINK=255/225/255
BROWN=160/64/32

COASTCOLOR=$BLACK
COASTWIDTH=0.1
BWPLOTCOAST=1
PLOTBORDER=0
BORDERS=
BORDERCOLOR=$LTGRAY
PLATEBOUNDS=0

ROOT=/midtown/mid4/smalley

#illum direction determines how it "looks"
BATHILLUM=270
TOPOILLUM=315

PTECT=$ROOT/ptect

LINETHICK=1

SEAFLOOR=1
SEAFILL=-S$LTGRAY
LANDFILL=-G$WHITE
LAKEFILL=-C$WHITE

ORIENT=
RESOL=-Df
CONTINUE="-K -O"
GRID=-Ba2/a2$MAPLABEL
SQUARE=

AREA=
LAKEFILL=

ERROR=0

if [ $# -eq 0 -or $# -ge 2 ]
then
# echo error
 ERROR=1
else
# echo num input parameters = $#
 REGPARM=$1
 TOPO=$2
 echo $1 $2
fi

if [ $ERROR = 0 ]
then

 CLEAN=yes
 echo $REGPARM
 if [ $REGPARM = india ]
 then

  GRID=-Ba2/a2$MAPLABEL

  LONMIN=63.
  LATMAX=29.
  LONMAX=72.
  LATMIN=21.
  PROJ=Jm
  SCALE=0.7
  ORIENT=-P
  PLATEBOUNDS=1
  PLOTBORDER=1
  YOFFSET=1.5

 elif [ $REGPARM = india1 ]
 then

  GRID=-Ba2/a2$MAPLABEL

  LONMIN=64.
  LATMAX=30.
  LONMAX=73.
  LATMIN=20.
  PROJ=Jm
  SCALE=0.7
  ORIENT=-P
  PLATEBOUNDS=1
  YOFFSET=1.5

 elif [ $REGPARM = india2 ]
 then

  GRID=-Ba2/a2$MAPLABEL

  LONMIN=63.
  LATMAX=40.
  LONMAX=83.
  LATMIN=20.
  PROJ=Jm
  SCALE=0.35
  ORIENT=-P
  PLATEBOUNDS=1
  YOFFSET=1.5

 else
  ERROR=1
  echo region sel bad
  echo region must be one of
  nawk 'BEGIN {FS="\="} /REGPARM \=/ {print $2}' $0 | nawk '{print $1}' | sort -u
 fi
fi
 
 if [ $ERROR = 0 ]
 then

  echo region sel ok
 
  if [ $TOPO = color -o $TOPO = bw -o $TOPO = notopo ]
  then
   echo color sel ok
  else
   ERROR=1
   echo color sel bad
  echo color must be one of
  nawk 'BEGIN {FS="\="} /TOPO \=/ {print $2}' $0 | nawk '{print $1}' | sort -u
  fi

  if [ $TOPO = notopo ]
  then
   BW=1
  else
   BW=0
  fi
 
fi
echo end regional map setup 
ROOTNAME=$0
echo rootname ${ROOTNAME}, proj $PROJ, scale $SCALE

if [ $ERROR = 1 ]
then
 echo
 echo "cap [ REGION ] [ TOPOGRAPHY ]"
 echo
 echo color or bw for color or bw topo, notopo for no topo
 exit
fi

if [ $PLOTBORDER = 1 ]
then
 BORDERS=-N1/8/$BORDERCOLOR
fi

REGION=$LONMIN/$LONMAX/$LATMIN/$LATMAX$SQUARE
echo region selected $REGION

LABEL=:."${ROOTNAME}":
GRID=$GRID$LABEL
echo $GRID

echo set scaling
echo proj and scale $PROJ $SCALE

if [ $TOPO != notopo ]
then
 echo prep topo gridfiles

 echo initial region for grdraster $REGION
  echo use same region for grdraster selection
  GRDRASTERREGION=$REGION
 echo grd raster region $GRDRASTERREGION

 if [ $SEAFLOOR = 1 ]
 then
  echo do seafloor
  DATASET=10
  DATAGRID=-I2m/2m
  grdraster $DATASET -G${ROOTNAME}_2mtopo.grd $DATAGRID -R$GRDRASTERREGION -V
  echo done with 2m topo grdraster
  grdedit -A ${ROOTNAME}_2mtopo.grd
  echo done fixing grd file
 fi

 echo do topo
 DATASET=9
 DATAGRID=-I30c/30c
 grdraster $DATASET -G${ROOTNAME}_topo.grd $DATAGRID -R$GRDRASTERREGION -V
 echo done with gtopo grdraster
 grdedit -A ${ROOTNAME}_topo.grd
 echo done fixing grd file
fi
echo done grdraster calls

echo $GRID
 OUTPUTFILE=${ROOTNAME}.ps
 echo $OUTPUTFILE

\rm $OUTPUTFILE

echo resolution $RESOL
if [ $TOPO != notopo ]
then
 echo here for topo/bath
 NORM=-Nt
 grdgradient ${ROOTNAME}_topo.grd -A$TOPOILLUM -G${ROOTNAME}_topo.intns $NORM -V
 INTNSFILE=${ROOTNAME}_topo
 echo done with illumination for topo

 if [ $SEAFLOOR = 1 ]
 then
 echo prep and merge bathy
 DATAGRID=-I30c/30c
 grdsample ${ROOTNAME}_2mtopo.grd -G${ROOTNAME}_30stopo.grd $DATAGRID -F -R$GRDRASTERREGION -V
 grdgradient ${ROOTNAME}_30stopo.grd -A$BATHILLUM -G${ROOTNAME}_30stopo.intns $NORM -V
 grdmath -F -V ${ROOTNAME}_topo.grd ${ROOTNAME}_30stopo.grd AND = ${ROOTNAME}_topobath.grd
 grdmath -F -V ${ROOTNAME}_topo.intns ${ROOTNAME}_30stopo.intns AND = ${ROOTNAME}_topobath.intns
 INTNSFILE=${ROOTNAME}_topobath
 echo done w/ test merge
 fi

 if [ $TOPO = bw ]
 then

  echo grey scale topo
  echo '-10000 128 10000 128' > ${ROOTNAME}.cpt
  grdimage $INTNSFILE.intns -I$INTNSFILE.intns -C${ROOTNAME}.cpt -R$REGION -$PROJ$SCALE $GRID -K -X$XOFFSET -Y$YOFFSET -V $ORIENT > $OUTPUTFILE

 else

  echo color topo
   CPTFILE=/midtown/mid1/gmt/GMT3.3.4/share/GMT_globe.cpt
  grdimage $INTNSFILE.grd -I$INTNSFILE.intns -C$CPTFILE -R$REGION -$PROJ$SCALE $GRID -K -X$XOFFSET -Y$YOFFSET -V $ORIENT > $OUTPUTFILE

 fi

 COASTCOLOR=$WHITE
 BORDERCOLOR=$WHITE
  if [ $BWPLOTCOAST = 1 ]
  then
   COAST=-W$COASTWIDTH/$COASTCOLOR
  else
   COAST =
  fi
  pscoast -R$REGION -$PROJ$SCALE $RESOL $AREA -N1/8/$BORDERCOLOR $COAST $RIVERS $CONTINUE >> $OUTPUTFILE

else

#here for no topo
 echo region $REGION
 echo proj and scale $PROJ$SCALE
 echo resol $RESOL
 echo rivers $RIVERS
 echo grid $GRID
 pscoast -R$REGION -$PROJ$SCALE $RESOL $AREA $SEAFILL $LAKEFILL $LANDFILL $RIVERS $COAST -K $GRID -X$XOFFSET -Y$YOFFSET -V $ORIENT > $OUTPUTFILE

fi

echo done with topo part, plot map data

if [ $PLATEBOUNDS = 1 ]
then
 echo plot plateboundaries
 psxy -R -$PROJ$SCALE -M$ -W$LINETHICK/$RED -O -K $PTECT/ridges >> $OUTPUTFILE
 psxy -R -$PROJ$SCALE -M$ -W$LINETHICK/$GREEN -O -K $PTECT/xforms >> $OUTPUTFILE
 psxy -R -$PROJ$SCALE -M$ -W$LINETHICK/$BLUE -O -K $PTECT/trenches >> $OUTPUTFILE
fi

psmeca -R -$PROJ$SCALE -Sd0.2/0/0 -G$RED $CONTINUE -L -W0.5/$BLACK << END >> $OUTPUTFILE 
`nawk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10}' india.quick.cmt`
END

if [ $REGPARM = india2 ]
then
psmeca -R -$PROJ$SCALE -Sd0.2/0/0 -G$RED $CONTINUE -L -W0.5/$BLACK << END >> $OUTPUTFILE
`nawk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10}' india.cmt`
END
fi

echo done with figure - clean up
if [ $CLEAN = yes ]
then
if [ $TOPO != notopo ]
then

 \rm ${ROOTNAME}.cpt
 \rm ${ROOTNAME}.grd
 \rm ${ROOTNAME}.intns

 \rm ${ROOTNAME}_topo.grd
 \rm ${ROOTNAME}_topo.intns
 \rm ${ROOTNAME}_2mtopo.grd
 \rm ${ROOTNAME}_2mtopo.intns
 \rm ${ROOTNAME}_30stopo.grd
 \rm ${ROOTNAME}_30stopo.intns
 \rm ${ROOTNAME}_topobath.grd
 \rm ${ROOTNAME}_topobath.intns
fi
fi

echo done with $0, output file $OUTPUTFILE