Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Monday January 06, 2003
07:28 PM

NOAA has the 8th fastest computer in the world

[ #9803 ]

The National Oceanic and Atmospheric Adminitration has the 8th fastest computer in the world, according to Top500 (results available in XML). I do not see the NSA listed as number 1 (although several rankings are simply labelled "US Government"), so take the results however you will (and ask Ziggy's about secretive US Government organizations if you really need to know the real story :).

I do not need all that computer power, I just want the weather in cities that affect me. The Geo::WeatherNOAA module does most of the work for me in my first attempt at a personal weather script. I read lines from DATA (until I make a proper configuration file) and use that to fetch and present the data.

To do this, I need to know what NOAA calls the local weather station. The area I care about right now (Chicago near Lake Michigan) shows up as "Meigs", a small airport on the shore, rather than "Chicago", which stretches almost to the western and northern borders of the state, I think. I also care about Dallas (and Salt Lake City, and Atlanta, and Cincinnati---weather there affects my life several times a month). To see the weather for Dallas, I had to fetch the hourly report for Texas and find the name of something close to Dallas---I chose "DFW AIRPORT". I can do that for any state with the right state abbreviation in this URL: <URL:http://iwin.nws.noaa.gov/iwin/STATE_ABBR_HERE/hourly.html>.

#!/usr/bin/perl
 
use Geo::WeatherNOAA;
 
while( <DATA> )
    {
    next unless m/\|/;
    chomp;
 
    my( $city, $state, $name ) = split /\|/;
 
    $name ||= $city;
 
    my $response = uc( $name ) . "\n";
 
    $response .= print_current( $city, $state, '', 'get');
    $response =~ s/&deg;/-/g;
    $response .= "\n" unless substr( $response, -1, 1 ) eq "\n";
 
    print $response, "-" x 73, "\n";
    }
 
__DATA__
meigs|il|Chicago
providence|ri
new york city|ny
monterey|ca
CINC-COVINGTON|oh|Cincinnati
atlanta|ga
salt lake city|ut
dfw airport|tx

The output fits on one of my (long) terminal screens and I see everything at once rather than visiting a lot of web pages.

CHICAGO
At 5:00 PM, Meigs, IL conditions were partly cloudy skies at  34-F,
    wind was northwest at 15 mph.  The relative humidity was  51%, and
    barometric pressure was rising from 30.39 in.
-------------------------------------------------------------------------
    PROVIDENCE
At 6:00 PM, Providence, RI conditions were cloudy skies at  29-F, wind
    was north at 9 mph.  The relative humidity was  85%, and barometric
    pressure was rising from 29.87 in.
-------------------------------------------------------------------------
    NEW YORK CITY
At 6:00 PM, New York City, NY conditions were cloudy skies at  32-F,
    wind was northwest at 7 mph.  The relative humidity was  85%, and
    barometric pressure was rising from 29.87 in.
-------------------------------------------------------------------------
    MONTEREY
At 3:00 PM, Monterey, CA conditions were sunny skies at  68-F, wind was
    northwest at 7 mph.  The relative humidity was  42%, and barometric
    pressure was rising from 30.04 in.
-------------------------------------------------------------------------
    CINCINNATI
At 6:00 PM, Cinc-covington, OH conditions were mostly cloudy skies at
    31-F, wind was northwest at 20 mph, gusts up to 28 mph.  The
    relative humidity was  63%, and barometric pressure was rising from
    30.30 in.
-------------------------------------------------------------------------
    ATLANTA
At 6:00 PM, Atlanta, GA conditions were partly cloudy skies at  40-F,
    wind was north at 16 mph.  The relative humidity was  55%, and
    barometric pressure was rising from 30.24 in.
-------------------------------------------------------------------------
    SALT LAKE CITY
At 4:00 PM, Salt Lake City, UT conditions were mostly sunny skies at
    43-F, wind was west at 12 mph.      The relative humidity was  65%, and
    barometric pressure was rising from 30.50 in.
-------------------------------------------------------------------------
    DFW AIRPORT
At 5:00 PM, Dfw Airport, TX conditions were mostly cloudy skies at
    50-F, wind was north at 13 mph.  The relative humidity was  48%,
    and barometric pressure was rising from 30.48 in.
-------------------------------------------------------------------------