#! /bin/ksh
# This is: autog11 for cimss (aka maple) in /home2/www/goes/realtime.
# 01jul2000 more use of just naming with g11.
# 30jun2000 vers for GOES-11 test.
# 06apr2000 del ctop.wisc.text.html from final (con)cat for grtmain.html (gsw).
# 04jan2000 add gscb05 (cntfiles only!) - GSW, JPN
# 17nov1999 add usct (for US CTP) incl java capability.
# 31aug1999 add java for ozone.
# 27aug1999 add ls -1...tail -4 for short 4-frame loops as well.
#
# Produce realtime GOES mpegs and maintain
# the realtime.html document. This script is
# activated by rsh from a remote host. The
# gifs used here are rcp'ed here from the
# remote hosts.
# *************************************************
# determine number of gif files falling within a
# 24-hour period
# $1 -> product type
cntfiles()
{
ls ${1}.*.[0-9]*.gif 2>/dev/null | wc -l | read ntot
if [ $ntot -ne 0 ]
then
ls -1 ${1}.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n | sed -n "1,1 p" | \
read file rest
echo $file | cut -d"." -f2 | read fday
echo $file | cut -d"." -f3 | read ftim
let day1=$fday*10000+$ftim
let num=0
for file in `ls -1 ${1}.*.[0-9]*.gif | sort -t. +1 -n +2 -n`
do
echo $file | cut -d"." -f2 | read fday
echo $file | cut -d"." -f3 | read ftim
let day2=$fday*10000+$ftim
let diff=$day1-$day2
if [ $diff -le 10000 ]
then
let num+=1
else
rm $file
fi
done
if [ $num -ne 0 ]
then
ls -1 ${1}.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n | sed -n "1,1 p" | \
read file rest
cp -p $file latest${1}.gif
rm -f /home/ftp/pub/goes/${1}.*.gif 2> /dev/null
cp -p $file /home/ftp/pub/goes/
cp -p latest${1}.gif /home/ftp/pub/goes/
fi
else
echo "no files of type ${1}.*.gif present"
exit 1
fi
}
# *************************************************
# make time in format hh:mm
# $1 -> time as hhmm
maketime()
{
let hour=${1}/100
let min=${1}%100
if [ $min -lt 10 ]
then
ntim=$hour:0$min
else
ntim=$hour:$min
fi
}
# *************************************************
# echo to html document, indent one level
# $1 -> product type
echohtml()
{
echo "
" > $1.data.html
if [ $num -gt 1 ]
then
wc -c $1.mpg | read n rest
wc -c $1.fli | read nn rest
echo "" \
>> $1.data.html
echo "24-hour" >> $1.data.html
echo " MPEG" >> $1.data.html
echo "($n bytes) | " >> $1.data.html
echo " FLI" >> $1.data.html
echo "($nn bytes) Animation " >> $1.data.html
echo "(FLI Player Information)" \
>> $1.data.html
echo "
" >> $1.data.html
fi
let gifnum=0
let pday=0
for file in `ls -1 $1.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n`
do
echo $file | cut -d"." -f2 | read fday
echo $file | cut -d"." -f3 | read ftim
let day2=$fday*10000+$ftim
let diff=$day1-$day2
if [ $diff -le 10000 ]
then
maketime $ftim
today $fday | read day mon year
let gifnum+=1
if [ $pday -eq 0 ] || [ $pday -ne $day ]
then
if [ $pday -ne 0 ]
then
echo "
" >> $1.data.html
fi
let pday=$day
echo "" \
>> $1.data.html
echo "GIF Images for $day $mon $year" >> $1.data.html
echo "" >> $1.data.html
echo " $ntim UTC" >> $1.data.html
else
echo ", $ntim UTC" >> $1.data.html
fi
fi
done
if [ $gifnum -ne 0 ]
then
echo "
" >> $1.data.html
fi
echo "" >> $1.data.html
}
# *************************************************
# echo to html document, indent two levels
# $1 -> product type
echohtml2()
{
echo "" > $1.data.html
echo "" >> $1.data.html
if [ $num -gt 1 ]
then
wc -c $1.mpg | read n rest
wc -c $1.fli | read nn rest
echo "" \
>> $1.data.html
echo "24-hour" >> $1.data.html
echo " MPEG" >> $1.data.html
echo "($n bytes) | " >> $1.data.html
echo " FLI" >> $1.data.html
echo "($nn bytes) Animation " >> $1.data.html
echo "(FLI Player Information)" \
>> $1.data.html
echo "
" >> $1.data.html
fi
let gifnum=0
let pday=0
for file in `ls -1 $1.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n`
do
echo $file | cut -d"." -f2 | read fday
echo $file | cut -d"." -f3 | read ftim
let day2=$fday*10000+$ftim
let diff=$day1-$day2
if [ $diff -le 10000 ]
then
maketime $ftim
today $fday | read day mon year
let gifnum+=1
if [ $pday -eq 0 ] || [ $pday -ne $day ]
then
if [ $pday -ne 0 ]
then
echo "
" >> $1.data.html
fi
let pday=$day
echo "" \
>> $1.data.html
echo "GIF Images for $day $mon $year" >> $1.data.html
echo "" >> $1.data.html
echo " $ntim UTC" >> $1.data.html
else
echo ", $ntim UTC" >> $1.data.html
fi
fi
done
if [ $gifnum -ne 0 ]
then
echo "
" >> $1.data.html
fi
echo "
" >> $1.data.html
echo "" >> $1.data.html
}
# *************************************************
# echo to html document, indent two levels
# $1 -> product type
echohtml3()
{
echo "" > $1.data.html
echo "" >> $1.data.html
if [ $num -gt 1 ]
then
# wc -c $1.mpg | read n rest
# wc -c $1.fli | read nn rest
#
# echo "" \
>> $1.data.html
# echo "24-hour" >> $1.data.html
# echo " MPEG" >> $1.data.html
# echo "($n bytes) | " >> $1.data.html
# echo " FLI" >> $1.data.html
# echo "($nn bytes) Animation " >> $1.data.html
# echo "(FLI Player Information)" \
>> $1.data.html
echo "
" >> $1.data.html
fi
let gifnum=0
let pday=0
for file in `ls -1 $1.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n`
do
echo $file | cut -d"." -f2 | read fday
echo $file | cut -d"." -f3 | read ftim
let day2=$fday*10000+$ftim
let diff=$day1-$day2
if [ $diff -le 10000 ]
then
maketime $ftim
today $fday | read day mon year
let gifnum+=1
if [ $pday -eq 0 ] || [ $pday -ne $day ]
then
if [ $pday -ne 0 ]
then
echo "
" >> $1.data.html
fi
let pday=$day
echo "" \
>> $1.data.html
echo "GIF Images for $day $mon $year" >> $1.data.html
echo "" >> $1.data.html
echo " $ntim UTC" >> $1.data.html
else
echo ", $ntim UTC" >> $1.data.html
fi
fi
done
if [ $gifnum -ne 0 ]
then
echo "
" >> $1.data.html
fi
echo "
" >> $1.data.html
echo "" >> $1.data.html
}
# *************************************************
# archive the realtime products
# $1 -> product type
archiveit()
{
arch=./archive/
ls -1 ${1}.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n | sed -n "1,1 p" | read file
echo $file | cut -f2 -d. | read day
tarfile=${arch}${1}.${day}.tar
if [ ! -a $tarfile ]
then
tar cf $tarfile $file
else
tar rf $tarfile $file
fi
old=6
find $arch -name "${1}.*.tar" -mtime +$old -exec rm {} \;
}
# *************************************************
# maintain softlink to latest synoptic time (00 or 12 UTC) gif. delete
# gifs older than one week.
# $1 -> time period (00 or 12)
# $2 -> product name (uspwr, uslir)
time_link()
{
ls $2.*.${1}00.gif 2>/dev/null | wc -l | read n
if [ $n -ne 0 ]
then
ls -1 $2.*.${1}00.gif | sort -r -t. +1 -n +2 -n | sed -n "1,1 p" | \
read wrfile
if [ -L latest.$2.${1}00.gif ]
then
rm latest.$2.${1}00.gif 2>/dev/null
fi
ln -s $wrfile latest.$2.${1}00.gif
find . -name "$2.*.${1}00.gif" -mtime +6 -exec rm {} \;
fi
}
# *************************************************
# maintain softlink to latest daily gif. delete gifs older than
# one week.
# $1 -> product name (gesstc)
day_link()
{
ls $1.*.gif 2>/dev/null | wc -l | read n
if [ $n -ne 0 ]
then
ls -1 $1.*.gif | sort -r -t. +1 -n +2 -n | sed -n "1,1 p" | \
read wrfile
if [ -L latest.$1.gif ]
then
rm latest.$1.gif 2>/dev/null
fi
ln -s $wrfile latest.$1.gif
find . -name "$1.*.gif" -mtime +6 -exec rm {} \;
fi
}
# *************************************************************
# *************************************************************
#
# Begin autogoes execution here.
# For cimss (aka maple) appropriate directory is home2.
# *** NOTE - appropriate directory for GOES-11 test period ***
umask 002
export PATH=$PATH:$HOME/bin:.
cd /home2/www/goes/realtime/g11
# branch according to product type passed in $1
case $1 in
# *************************************************
# these are the tony schreiner products
tonys)
cntfiles ctop
# update tony schreiner section of the html document
echohtml2 ctop
# build list of last 24 and 4 hrs worth of ctop gifs for
# java animation (anictop.html).
ls -1 ctop.*.gif > listctop.txt
ls -1 ctop.*.gif | tail -4 > listctop4.txt
# archive the product
archiveit ctop
;;
# *************************************************
# this is the wisconsin cloud top product. no animation needed,
# only archive.
wisprd)
# determine number of gifs.
cntfiles ctop_wisprd
if [ $num -ne 0 ]
then
ls -1 ctop_wisprd.*.[0-9]*.gif | sort -r -t. +1 -n +2 -n | \
sed -n "1,1 p" | read file
cp -p $file ctop_wisprd.latest.gif
fi
# archive the product and exit without rebuilding the page
archiveit ctop_wisprd
exit 0
;;
# *************************************************
# place sounder ch=11 gif on top of real-time page
wv11)
# reduce lastest sounder ch=11 sounder image to logo size
/usr/sww/bin/convert -geometry 528x176 latest.wvsnd11.gif \
latest.wvsnd11.little.gif
cp -p latest.wvsnd11.gif /home/ftp/pub/goes/
exit 0
;;
# *************************************************
# this is sounder precipitable water. the mpeg is generated
# on rets.
snpw)
cntfiles snpw
# update precipitable water section of the html document
echohtml2 snpw
# build list of last 24 and 4 hrs worth of snpw gifs for
# java animation (anisnpw.html).
ls -1 snpw.*.gif > listsnpw.txt
ls -1 snpw.*.gif | tail -4 > listsnpw4.txt
# archive the product
archiveit snpw
;;
# *************************************************
# this is central US sounder precipitable water. the mpeg
# is generated on rets.
cupw)
cntfiles cupw
# update central US precipitable water section of the
# html document
echohtml2 cupw
# archive the product
archiveit cupw
# update 00 and 12 link to cupwr (cupw with radiosondes)
time_link 00 cupwr
time_link 12 cupwr
;;
# *************************************************
# this is sounder lifted index. the mpeg is generated
# on rets.
culi)
cntfiles culi
# update lifted index section of the html document
echohtml culi
# archive the product
archiveit culi
# update 00 link to culir (culi with radiosondes)
time_link 00 culir
;;
# *************************************************
# this is (entire) US sounder precipitable water. the fli
# is generated on suomi.
uspw)
cntfiles uspw
# update (entire) US precipitable water section of the
# html document
echohtml2 uspw
# build list of last 24 and 4 hrs worth of uspw gifs for
# java animation (aniuspw.html).
ls -1 uspw.*.gif > listuspw.txt
ls -1 uspw.*.gif | tail -4 > listuspw4.txt
# archive the product
archiveit uspw
# update 00 and 12 link to uspwr (uspw with radiosondes)
time_link 00 uspwr
time_link 12 uspwr
;;
# *************************************************
# this is (entire) US sounder lifted index. the fli is
# generated on suomi.
usli)
cntfiles usli
# update (entire) US lifted index section of the html document
echohtml usli
# build list of last 24 and 4 hrs worth of usli gifs for
# java animation (aniusli.html).
ls -1 usli.*.gif > listusli.txt
ls -1 usli.*.gif | tail -4 > listusli4.txt
# archive the product
archiveit usli
# update 00 link to uslir (usli with radiosondes)
time_link 00 uslir
;;
# *************************************************
# this is (entire) US sounder CAPE. Associate -ce-
# with convctv energy for abbreviation of CAPE.
# NO mpeg has been made. Only fli loop is generated.
usce)
cntfiles usce
# update CAPE (-ce-) section of the html document
echohtml usce
# build list of last 24 and 4 hrs worth of usce gifs for
# java animation (aniusce.html).
ls -1 usce.*.gif > listusce.txt
ls -1 usce.*.gif | tail -4 > listusce4.txt
# archive the product
archiveit usce
;;
# *************************************************
# this is (entire) US sounder Cloud Top Pressure.
# NO mpeg has been made. (Nor any fli either).
usct)
cntfiles usct
# update (entire) US CTP section of the html document
echohtml usct
# build list of last 24 and 4 hrs worth of usct gifs for
# java animation (aniusct.html).
ls -1 usct.*.gif > listusct.txt
ls -1 usct.*.gif | tail -4 > listusct4.txt
# archive the product
archiveit usct
;;
# *************************************************
# This is cen US/GlfMex sounder Cloud Top Pressure
# from GOES-11(L).
# NO mpeg has been made. (Nor any fli either).
g11ct)
cntfiles g11ct
# update cen US/GlfMex - GOES-11 CTP section of html document
echohtml g11ct
# build list of last 24 and 4 hrs worth of g11ct gifs for
# java animation (anig11ct.html).
ls -1 g11ct.*.gif > listg11ct.txt
ls -1 g11ct.*.gif | tail -4 > listg11ct4.txt
;;
# *************************************************
# This is cen US/GlfMex sounder precipitable water
# from GOES-11(L).
# NO mpeg has been made. (Nor any fli either).
g11pw)
cntfiles g11pw
# update cen US/GlfMex - GOES-11 PW section of html document
echohtml g11pw
# build list of last 24 and 4 hrs worth of g11pw gifs for
# java animation (anig11pw.html).
ls -1 g11pw.*.gif > listg11pw.txt
ls -1 g11pw.*.gif | tail -4 > listg11pw4.txt
;;
# *************************************************
# This is cen US/GlfMex sounder lifted index
# from GOES-11(L).
# NO mpeg has been made. (Nor any fli either).
g11li)
cntfiles g11li
# update cen US/GlfMex - GOES-11 PW section of html document
echohtml g11li
# build list of last 24 and 4 hrs worth of g11li gifs for
# java animation (anig11li.html).
ls -1 g11li.*.gif > listg11li.txt
ls -1 g11li.*.gif | tail -4 > listg11li4.txt
;;
# *************************************************
# This is the 20-panel format display for all
# channels from the GOES Sounder. Files were
# transferred from rets (gsall.scr).
gsall)
cntfiles gsall
# update the GOES all Sounder channels section of the html document
echohtml gsall
# build list of last 24 and 4 hrs worth of gsall gifs for
# java animation (anigsall.html).
ls -1 gsall.*.gif > listgsall.txt
ls -1 gsall.*.gif | tail -4 > listgsall4.txt
### N.B. Let this conversion run back on oldthunder.
### reduce latest 20-panel gif to smaller size so it
### definitely would fit in its entirety across top of page
### /usr/sww/bin/convert -geometry 640x448 latestgsall.gif \
### latestgsall.little.gif
;;
# *************************************************
# This is the ozone product.
ozone)
cntfiles ozone
# update the GOES ozone product section of the html document
echohtml3 ozone
# build list of last 24 and 4 hrs worth of ozone gifs for
# java animation (aniozone.html).
ls -1 ozone.*.gif > listozone.txt
ls -1 ozone.*.gif | tail -4 > listozone4.txt
;;
# *************************************************
# *************************************************
# This is for the GOES Sounder composite images of
# individual bands. These apply for specific bands
# (3,8,10-12,15,17) each hour. Gifs are transferred
# from suomi (makgscb.scr).
gscb03)
cntfiles gscb03
# update GOES SNDR composite image (band 03) section of the html document
echohtml2 gscb03
;;
# *************************
gscb05)
cntfiles gscb05
# update GOES SNDR composite image (band 05) section of the html document
###echohtml2 gscb05
;;
# *************************
gscb08)
cntfiles gscb08
# update GOES SNDR composite image (band 08) section of the html document
echohtml2 gscb08
;;
# *************************
gscb10)
cntfiles gscb10
# update GOES SNDR composite image (band 10) section of the html document
echohtml2 gscb10
;;
# *************************
gscb11)
cntfiles gscb11
# update GOES SNDR composite image (band 11) section of the html document
echohtml2 gscb11
;;
# *************************
gscb12)
cntfiles gscb12
# update GOES SNDR composite image (band 12) section of the html document
echohtml2 gscb12
;;
# *************************
gscb15)
cntfiles gscb15
# update GOES SNDR composite image (band 15) section of the html document
echohtml2 gscb15
;;
# *************************
gscb17)
cntfiles gscb17
# update GOES SNDR composite image (band 17) section of the html document
echohtml2 gscb17
;;
# *************************************************
# This is GOES Imager SST (by regression). The mpeg
# is no longer generated.
gesst)
cntfiles gesst
# update imager sst section of the html document
echohtml2 gesst
# build list of last 24 and 4 hrs worth of gesst gifs for
# java animation (anigesst.html).
ls -1 gesst.*.gif > listgesst.txt
ls -1 gesst.*.gif | tail -4 > listgesst4.txt
# update link to gesstc (composite gesst)
day_link gesstc
;;
# *************************************************
*)
echo "Invalid Selection"
exit 1
;;
esac
# concatenate to produce a new html document
# This is the approved document for the realtime GOES-11 section
# of the CIMSS Homepage.
cat headg11.html \
g11pw.text.html g11pw.data.html \
g11li.text.html g11li.data.html \
g11ct.text.html g11ct.data.html \
tailg11.html > /tmp/autog11.$$
mv /tmp/autog11.$$ g11main.html
##### gsa11.text.html gsa11.data.html \
### N.B. The following repetitive permission changing is not needed.
### chgrp staff *.gif *.mpg *.html 2>/dev/null
### chmod g+w *.gif *.mpg *.html 2>/dev/null
exit 0