:
# script to generate 2 plots (gifs) from current MRF forecast
#   24-48 hr precip, 24 hr 500 mb Hgt/Abs Vorticity
#
# this script is an example how to use wwwgrab and the web plotter
#
# requires GNU date command, wwwgrab and xv (optional)
#
set -x
set -e

# get initial time .. MRF finishes in about 9Z
date=`date --utc +%Y%m%d --date "9 hours ago"`
day=`date --utc +%d --date "9 hours ago"`
month=`date --utc +%b --date "9 hours ago"`
year=`date --utc +%Y`

# get day 1

day1=`date --utc +%d --date '15 hours'`
month1=`date --utc +%b --date '15 hours'`
year1=`date --utc +%Y --date '15 hours'`

# get day 2

day2=`date --utc +%d --date '1 day 15 hours'`
month2=`date --utc +%b --date '1 day 15 hours'`
year2=`date --utc +%Y --date '1 day 15 hours'`

tmpfile=/tmp/junk.mrf.$$
tmpfile=/tmp/junk.output
precip=/tmp/precip.png
hgtvort=/tmp/hgtvort.png

# pick up 24-48 hour precip

wwwgrab "http://sgi62.wwb.noaa.gov:8080/cgi-bin/pdisp_mrf.sh?\
ctlfile=mrf$date.ctl&ptype=map&var=smth+precip+24-48hr&\
level=1000&nlevels=16&op1=none&op2=none&hour=00Z&day=$day&\
month=$month&year=$year&proj=n_amer&lon0=280&dlon=50&lat0=-60&dlat=60&\
type=shaded&cint=def&white=def&plotsize=800x600&\
title=Precip+00Z$day1$month1$year1-00Z$day2$month2" $tmpfile

pngname=`egrep "meta.*png" $tmpfile |sed -e 's/^.*src="//' -e 's/png.*$/png/'`

if [ "$pngname" = "" -o `grep -c "ERROR" $tmpfile` -gt 0 ] ; then
   echo "forecast not available .. don't know why"
   echo "look at $tmpfile"
   exit 8
fi

rm $tmpfile

wwwgrab "http://sgi62.wwb.noaa.gov:8080$pngname" $precip
xv $precip &

# display 24 hour forecast of HGT and abs vorticity at 500 mb

wwwgrab "http://sgi62.wwb.noaa.gov:8080/cgi-bin/pdisp_mrf.sh?\
ctlfile=mrf$date.ctl&ptype=map&var=HGT%26AbsVort&level=500&nlevels=16&\
op1=none&op2=none&hour=00Z&day=$day1&month=$month1&year=$year1&\
proj=n_amer&lon0=280&dlon=50&lat0=-60&dlat=60&type=shaded&\
cint=def&white=def&plotsize=800x600&\
title=500mb+Hgt/AVort+24hr+fcst+valid+00Z$day1$month1$year1" $tmpfile

pngname=`egrep "meta.*png" $tmpfile |sed -e 's/^.*src="//' -e 's/png.*$/png/'`
# rm $tmpfile

wwwgrab "http://sgi62.wwb.noaa.gov:8080$pngname" $hgtvort
xv $hgtvort &

exit 0
