NAME
Weather::NHC::TropicalCyclone::Storm - Provides a convenient interface to NHC's Tropical Cyclone JSON format.
SYNOPSIS
use strict;
use warnings;
use Weather::NHC::TropicalCyclone ();
my $nhc = Weather::NHC::TropicalCyclone->new;
$nhc->fetch;
my $storms_ref = $nhc->active_storms;
my $count = @$storms_ref;
print qq{$count storms found\n};
foreach my $storm (@$storms_ref) {
print $storm->name . qq{\n};
my ($text, $advNum, $local_file) = $storm->fetch_publicAdvisory($storm->id.q{.fst});
print qq{$local_file saved for Advisory $advNum\n};
rename $local_file, qq{$advNum.$local_file};
}
DESCRIPTION
Given JSON returned by the NHC via https://www.nhc.noaa.gov/CurrentStorms.json, this module creates a covenient object for encapsulating each storm and fetching the data associated with them.
METHODS
Each storm instances provides an accessor for each field. In addition to this, each field that represents data (text extractible via .shtml or a downloadable file) also provides a fetch_* method.
Text Extracted from .shtml
Optional parameter naming a file to save the extracted text to.
Returns a list of 3 values: extracted text, advisory number, and local file (if optional parameter is provided to the called method.
Provided methods include:
fetch_publicAdvisoryfetch_forecastAdvisoryfetch_forecastDiscussionfetch_windspeedProbabilities_get_text-
Internal method used by all of the fetch methods that extract text from the linked
.shtmlfiles.
Directly Downloadable Files
Optional parameter naming a file to save the extracted text to.
Returns a list of 2 values: name of saved local file and advisory (if provided).
Provided methods include:
fetch_forecastTrackfetch_windWatchesWarningsfetch_trackConefetch_initialWindExtentfetch_forecastWindRadiiGISfetch_earliestArrivalTimeTSWindsGISfetch_mostLikelyTimeTSWindsGISfetch_windSpeedProbabilitiesGISfetch_stormSurgeWatchWarningGISfetch_potentialStormSurgeFloodingGISfetch_bestTrackGIS-
Note: This resource doesn't provide an advisory.
N/Ais returned in its place. _get_file-
Internal method used by all of the fetch methods that downloads files.
Links Extracted from .shtml
fetch_forecastGraphics-
Uses the URL provided by the
forecastGraphicsfields to determine the location of the base graphics directory. The default index page returned by the web server is scraped to get a fully resolved list of all graphics available for the storm.Returns list of graphics URLs as an array reference. A method to download all of the graphics is not provided at this time. But give the list of URLs, it's trivial to write a loop to download any number of these images using
HTTP::Tiny'smirrormethod. Seeperldoc HTTP::Tinyfor more information.
Auxillary Fetch Methods
fetch_best_track-
Accepts an optional parameter that defines the local file to save this file as.
Attempts to fetch the best track
.datfile that. This URL is not provided directly by the JSON file, but can be easily derived by using using$DEFAULT_BTK_ROOTand composing the filename using theidaccessor. This method combines this with a fetch over HTTPS (usingHTTP::Tiny'smirrormethod).This method returns just the local file name.
ENVIRONMENT
Default ackage variables:
$DEFAULT_GRAPHICS_ROOT-
defines the base URL used to determine the list of graphics available for the storm
$DEFAULT_BTK_ROOT-
defines the base URL used to fetch the best track
.datfile
COPYRIGHT and LICENSE
This module is distributed under the same terms as Perl itself.