#!/bin/sh PATH=/bin:/usr/bin:/usr/local/bin:/opt/grads-2.0.a9/bin cd `dirname $0` r=X case "${1}-${2}-${3}-${4}" in 20[0-9][0-9]-[01][0-9]-[0123][0-9]-[012][0-9]) : ;; *) echo "usage: sh $0 YYYY mm dd HH" ; exit 1 ;; esac yygg=$3$4 yy=$1 mm=$2 hh=$4 dhm=${3}${4}00 case "$hh" in 00|06|12|18) : okay ;; *) echo skip hh=$hh exit 0 ;; esac : find basetime vt=`ruby -e 'puts Time.gm(*ARGV.map{|s| s.to_i}).to_i' $1 $2 $3 $4` let "h6 = 3600 * 6" let "ofs = 3600 * 4" let "bt = ( vt - ofs ) / h6 * h6" set -- `ruby -e 'puts Time.at(ARGV.first.to_i).strftime("%Y %m %d %H")' $bt` by=$1 bm=$2 bd=$3 bh=$4 grib="Z__C_RJTD_${by}${bm}${bd}${bh}0000_GSM_GPV_Rgl_FD0006_grib2.bin" url="http://database.rish.kyoto-u.ac.jp/arch/jmadata/data/gpv/original/$by/$bm/$bd" ogrib=".zG${by}${bm}${bd}T${bh}F06.grib" for file in .zG????????T${bh}F06.grib do case "$file" in ${ogrib}) : skip ;; *) rm -f $file ;; esac done if [ ! -f ${ogrib} ]; then http_proxy=http://localhost/ wget -q -O"$ogrib" "${url}/${grib}" fi if [ ! -f ${ogrib} ]; then echo grib2 download fails. >&2 exit 1 fi g2ctl ${ogrib} > zgrib2.ctl gribmap -i zgrib2.ctl ruby gradswx.rb -f"synop-ph.tsv" -m:0..25,100..140 \ -y${dhm} -ym${yy}-${mm} zsynop.txt zsynop2.txt grads -b -p -c 'run gradswx-ph.gs' convert zgradsph.png -crop 1400x1915+80+80 zplotph${hh}.png