Weather::NHC::TropicalCyclone::ForecastAdvisory - provides handy extraction and conversion functionality for use with the NHC forecast advisory text
Below is a full example of fetching a JSON file from NHC and iterating over each storm using Weather::NHC::TropicalCyclone. The NHC forecast is fetched, then it is this text that is converted in to the ATCF data format using this module's save_as_atcf method.
Weather::NHC::TropicalCyclone
save_as_atcf
use strict; use warnings; use Weather::NHC::TropicalCyclone (); use Weather::NHC::TropicalCyclone::Forecast (); my $nhc = Weather::NHC::TropicalCyclone->new; $nhc->fetch; my $storms_ref = $nhc->active_storms; foreach my $storm (@$storms_ref) { my $advNum = $storm->publicAdvisory->{advNum}; my $imgs_ref = $storm->fetch_forecastGraphics_urls; if ( not $stormsAdvCache->{ $storm->id }->{$advNum} ) { my $new_advisory_file = sprintf( "%s.%s.fst.html", $advNum, $storm->id ); rename $local_file, $new_advisory_file; my $new_advisory_atcf_file = sprintf( "%s.%s.fst", $advNum, $storm->id ); my $fst_util = Weather::NHC::TropicalCyclone::Forecast->new( input_file => $new_advisory_file, output_file => $new_advisory_atcf_file); $fst_util->save_as_atcf; } }
Parses text advisories from the National Hurricane Center and converts them to ATCF forecast format for use within ADCIRC. It currently provides basic functionality for converting the text advisories to a data file that is generally useful. It doesn't provide a true object interface for advisories, but if this is an approach that is useful it would be done in this module.
For more information on this format and others provided by the Automated Tropical Cyclone Forecast System (ATCF), please visit https://www.nrlmry.navy.mil/atcf_web/docs/database/new/database.html.
new
Constructor, accepts two named parameters: input_file or input_text and output_file. These define the initial file containing the NHC forecast text and the file to which the ATCF format should be written.
input_file
input_text
output_file
Note: input_file and input_file are mutually exclusive. An exception will be thrown from the new constructor if both are provided.
as_atcf
Internal field accessor, only useful after extract_atcf has been called on the instance.
extract_atcf
extract_and_save_atcf
Combines extract_atcf and save_atcf into a single, convenient method since this will usually be what is wanted.
save_atcf
As long as input_file has been defined and it is in the expected NCH forecast advisory format, relevant data values will be extracted and return with each record contained in an array refernce. Each element in this array reference corresponds to a distict ATCF record.
Accessor for the input file containing the NHC forecast advisory text if used in the constructor..
Accessor for the input text of the NHC forecast advisory if used in the constructor.
Accessor for the output file that is written with the contents of as_atcf when save_atcf or extract_and_save_atcf is called.
Saves contents returned by as_atcf to the file specific by output.
output
_parseIotachs
Internal method that assists extract_atcf in its parsing.
The core parsing code in this module was created by Jason Fleming for use in the ADCIRC Surge Guidance System (ASGS). It is contained in the file, nhc_advisory_bot.pl, which is available in their github repository. This module is presented simply as a wrapper around this functionality.
nhc_advisory_bot.pl
https://github.com/jasonfleming/asgs/blob/master/nhc_advisory_bot.pl
Copyright(C) 2009-2015: Jason Fleming
This file is part of the ADCIRC Surge Guidance System (ASGS).
The ASGS 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 3 of the License, or (at your option) any later version.
ASGS 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 the ASGS. If not, see <http://www.gnu.org/licenses/>.
To install Weather::NHC::TropicalCyclone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Weather::NHC::TropicalCyclone
CPAN shell
perl -MCPAN -e shell install Weather::NHC::TropicalCyclone
For more information on module installation, please visit the detailed CPAN module installation guide.