#!/usr/local/bin/perl # A filter for the tropical storms data which converts it into a clipped HTML table. # 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. # # These refer to the column in the tropical storm data base. $DATE = 21; $ACTDATE = 23; $OBSTYPE = 20; $LATITUDE = 5; $LONGITUDE = 7; $NS = 6; $EW = 8; $TNAME = 9; $TYEAR = 0; $TMONTH = 1; $TDAY = 2; $TTIME = 3; $TWIND = 16; $TGUST = 17; $COURSE = 10; $SPEED = 12; $PRESSURE = 14; $TYPE = 19; $WMO = 22; $html_header = <<"HEADER_END"; Data History HEADER_END $html_legend = <<"LEGEND_END"; LEGEND_END $html_table_header = <<"TABLE_HEADER_END"; TABLE_HEADER_END $html_table_footer = <<"TABLE_FOOTER_END";
Date Time Lat Lon Wind
m-d UT Deg Deg Kts
TABLE_FOOTER_END $html_footer = <<"FOOTER_END"; FOOTER_END print "$html_header\n"; print "$html_legend\n"; $i=0; while (<>) { chop; s/ / /g; @line = split(" "); $name = substr($line[$TNAME],0,length($line[$TNAME])-3); $year = $line[$TYEAR]; $syear = substr($year,2,2); $month = $line[$TMONTH]; $day = $line[$TDAY]; if (length($month) == 1) {$month = "0".$month;} if (length($day) == 1) {$day = "0".$day;} $date = $month."-".$day; $line[$TTIME] =~ /(\d+)\.(\d*)/i; $hour = $1; if (length($hour) == 1) {$hour = "0".$hour;} $minute = $2; if (length($minute) == 1) {$minute = "0".$minute;} $time = $hour.":".$minute; $lat = $line[$LATITUDE].$line[$NS]; $lon = $line[$LONGITUDE].$line[$EW]; $course = $line[$COURSE]; $speed = $line[$SPEED]; $pressure = $line[$PRESSURE]; if (&ISNUMBER($line[$TWIND])) {$wind = int($line[$TWIND]);} else {$wind = $line[$TWIND];} while (length($wind) < 3) {$wind = "0".$wind;} if (&ISNUMBER($line[$TGUST])) {$gust = int($line[$TGUST]);} else {$gust = $line[$TGUST];} while (length($gust) < 3) {$gust = "0".$gust;} $type = $line[$TYPE]; $observation = $line[$OBSTYPE]; $wmo = $line[$WMO]; if ($i == 0) { print "

$name History

\n"; print "

Forecasts in bold

\n"; print "$html_table_header\n"; } print "\n"; if ($observation =~ /FOR/i) { $font=""; $closefont = ""; } else { $font=""; $closefont = ""; } print " $font$date$closefont\n"; print " $font$time$closefont\n"; print " $font$lat$closefont\n"; print " $font$lon$closefont\n"; print " $font$wind$closefont\n"; if ($type =~ /FOR/i) {print " \n";} print "\n"; ++$i; } print "$html_table_footer\n"; print "


\n"; print "

\n"; print "Home | \n"; print "Summary | \n"; print "Strike Probs

"; print "Warning: These data may not be accurate.\n"; print "$html_footer\n"; exit; sub ISNUMBER { # Is the argument a number, e.g. 1.0, .1, 1, 1e4, 1.0e4, etc.? # Returns true or false. $_[0] =~ /^\s*(\+|-|)(\d+|\d+\.\d*|\d*\.\d+)(e\d+|)\s*$/i; }