#!/usr/local/bin/perl # PERL program to generate PostScript and GIF Hurricane maps. Runs IDL to # generate the maps and puts them in $RootPath directory (if it exists). # Copyright (C) 1996 Thomas R. Metcalf # # This software is provided "as is" and is subject to change without # notice. No warranty of any kind is made with regard to this software, # including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose. The author shall # not be liable for any errors or for direct, indirect, special, # incidental or consequential damages in connection with the furnishing, # performance, or use of this software: use it at your own risk. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # #setpriority(0,0,getpriority(0,0)+4); # nice the process $RootPath = "/data1/WWW/Tropical"; $DPath = "$RootPath/Data"; $TFile = "$RootPath/Data/tropical"; $FFile = "$RootPath/Data/forecasts"; $TMaps = "$RootPath/Bin/TMaps"; $ForecastOut = "$DPath/forecast.txt"; $rcp = "/usr/ucb/rcp"; if (! -d "$RootPath") {die "$RootPath does not exist";} # directory exists? # Get old file names. They will be deleted at the end. opendir(PSDIR,"$RootPath/PS"); @psfiles = grep(/(\d\d\d\d\.ps|\d\d\d\d\.ps\.Z)$/,readdir(PSDIR)); grep($_ = "$RootPath/PS/".$_,@psfiles); closedir(PSDIR); opendir(GIFDIR,"$RootPath/Gif"); @giffiles = grep(/(\d\d\d\d\.gif|\d\d\d\d\.gif\.Z)$/,readdir(GIFDIR)); grep($_ = "$RootPath/Gif/".$_,@giffiles); closedir(GIFDIR); # Get names of data files to use for storm archives opendir(DATADIR,"$DPath"); #@stormfiles = grep(/^\w+\-\d\d$/,readdir(DATADIR)); @stormfiles = grep(/\w+\-\d\d$/,readdir(DATADIR)); closedir(DATADIR); grep($_ = "$DPath/".$_,@stormfiles); # add root to file names @stormfiles = grep(-M $_ < 1.0,@stormfiles); # only do newish files ($sec,$min,$hour,$mday,$mon,$year) = gmtime; $mon++; if ($min < 10) {$min="0$min"}; if ($hour < 10) {$hour="0$hour";} if ($mday < 10) {$mday="0$mday";} if ($mon < 10) {$mon="0$mon";} $extension = "$year$mon$mday.$hour$min"; # Date is used in the filenames #if ($year < 1995) {$lyear = $year + 1900;} #if ($year < 95) {$lyear = $lyear + 100;} if ($year < 1900) {$lyear = $year + 1900;} $year = substr($lyear,2,2); #system("/bin/cp $TFile $RootPath/Data/tropical$year 1>/dev/null 2>&1"); $ENV{'IDL_DEVICE'}='PS'; $ENV{'IDL_DIR'}='/usr/local/lib/idl'; $idlprogram = <<"IDLEND"; !path = ":/data1/WWW/Tropical/Bin/IDL:" + !path + ":/usr/local/lib/idl/lib:/usr/local/lib/idl/astron/pro:/solar/idl:" !quiet=0 set_plot,"z" retall ;loadct,13 ctrainbow tvlct,r,g,b,/get r(0)=0 & r(!d.table_size-1)=255 g(0)=0 & g(!d.table_size-1)=255 b(0)=0 & b(!d.table_size-1)=255 tvlct,r,g,b tropical,database=database,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/nep.latest.gif",a,r,g,b tropical,database=database,/atlantic,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/atl.latest.gif",a,r,g,b tropical,database=database,/nwpacific,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/nwp.latest.gif",a,r,g,b tropical,database=database,/swpacific,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/swp.latest.gif",a,r,g,b tropical,database=database,/sepacific,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/sep.latest.gif",a,r,g,b tropical,database=database,/nindian,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/nin.latest.gif",a,r,g,b tropical,database=database,/sindian,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/sin.latest.gif",a,r,g,b tropical,/nogrid,/nodates,/world,database=database,year=$year,file="$TFile",mapdir="$TMaps",xsize=885,ysize=350,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/wld.latest.gif",a,r,g,b tropical,/nodates,/nonames,/nogrid,/noscale,/nousa,/nocountries,/notitle,/nolabel,/world,database=database,year=$year,file="$TFile",mapdir="$TMaps",xsize=360,ysize=116,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/wld.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/nep.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,/nwpacific,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/nwp.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,/swpacific,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/swp.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,/sepacific,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/sep.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,/atlantic,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/atl.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,/nindian,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/nin.thumbnail.gif",a,r,g,b tropical,database=database,expand=0.333,/nodates,/noscale,/nonames,/nolabel,/sindian,file="$TFile",mapdir="$TMaps",/notitle,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/Gif/sin.thumbnail.gif",a,r,g,b tropical,/nodates,/nep,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/nep${lyear}.gif",a,r,g,b tropical,/nodates,/nwp,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/nwp${lyear}.gif",a,r,g,b tropical,/nodates,/atl,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/atl${lyear}.gif",a,r,g,b tropical,/nodates,/swp,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/swp${lyear}.gif",a,r,g,b tropical,/nodates,/sep,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/sep${lyear}.gif",a,r,g,b tropical,/nodates,/sin,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/sin${lyear}.gif",a,r,g,b tropical,/nodates,/nin,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",noedge=0 retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/nin${lyear}.gif",a,r,g,b tropical,/nodates,/nonames,/nogrid,/world,/all,data=alldata,year=$year,file="$TFile",mapdir="$TMaps",xsize=885,ysize=350,/noedge retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/wld${lyear}.gif",a,r,g,b retall set_plot,"ps" loadct,0 device,/landscape,file="$RootPath/PS/nep.latest.ps" tropical,database=database,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/atl.latest.ps" tropical,database=database,/atlantic,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/nwp.latest.ps" tropical,database=database,/nwpacific,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/swp.latest.ps" tropical,database=database,/swpacific,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/sep.latest.ps" tropical,database=database,/sepacific,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/nin.latest.ps" tropical,database=database,/nindian,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/sin.latest.ps" tropical,database=database,/sindian,file="$TFile",/noedge device,/close retall device,/landscape,file="$RootPath/PS/wld.latest.ps" tropical,database=database,/world,/nogrid,/nodates,file="$TFile",/noedge device,/close retall set_plot,"z" device,set_resolution=[640,512],z_buffering=1 .run tcforecast journal,"$ForecastOut" tcforecast,file="$FFile$year",gifdir="$RootPath/GifArchive",out_file_append=\'$lyear\' journal retall exit IDLEND system("/usr/bin/echo '$idlprogram' | /usr/local/lib/idl/bin/idl"); #system("/usr/bin/echo '$idlprogram' | /usr/local/lib/idl/bin/idl 1>/dev/null 2>&1"); sleep(30); unlink @psfiles; # delete old files unlink @giffiles; # delete old files system("/usr/local/bin/ps2pdf $RootPath/PS/atl.latest.ps $RootPath/PS/atl.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/nep.latest.ps $RootPath/PS/nep.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/nwp.latest.ps $RootPath/PS/nwp.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/sep.latest.ps $RootPath/PS/sep.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/swp.latest.ps $RootPath/PS/swp.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/nin.latest.ps $RootPath/PS/nin.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/sin.latest.ps $RootPath/PS/sin.latest.pdf"); system("/usr/local/bin/ps2pdf $RootPath/PS/wld.latest.ps $RootPath/PS/wld.latest.pdf"); foreach $storm (@stormfiles) { @stormpath = split(m|/|,$storm); $name = $stormpath[$#stormpath]; # get storm name print "$storm ... $name\n"; $idlarchiveprogram = <<"IDLARCHIVEEND"; !path = ":/data1/WWW/Tropical/Bin/IDL:" + !path + ":/usr/local/lib/idl/lib:/usr/local/lib/idl/astron/pro:/solar/idl:" !quiet=0 set_plot,"z" retall ;loadct,13 ctrainbow tvlct,r,g,b,/get r(0)=0 & r(!d.n_colors-1)=255 g(0)=0 & g(!d.n_colors-1)=255 b(0)=0 & b(!d.n_colors-1)=255 tvlct,r,g,b tropical,file="$storm",/plot_current_storms,xsize=640,ysize=580,/all retall a = tvrd() tvlct,r,g,b,/get write_gif,"$RootPath/GifArchive/$name.gif",a,r,g,b IDLARCHIVEEND system("/usr/bin/echo '$idlarchiveprogram' | /usr/local/lib/idl/bin/idl"); #system("/usr/bin/echo '$idlarchiveprogram' | /usr/local/lib/idl/bin/idl 1>/dev/null 2>&1"); }