NAME
Geo::METARTAF - Decode METAR, SPECI, and TAF strings
SYNOPSIS
use strict;
use Geo::METARTAF;
my $t = new Geo::METARTAF;
$t->metar("CYVR 280200Z 09011KT 6SM -RA BR FEW006 OVC011 06/06 A2964 RMK ST2SC6 SLP039=");
or
$t->speci("CYVR 280240Z 08010KT 6SM BR FEW006 OVC010 06/06 A2962 RMK SF2SC6 SLP034=");
or
$t->taf("CYVR 280103Z 2801/2906 10012KT 6SM -RA BR SCT005 OVC025
TEMPO 2801/2808 2SM SHRA BR BKN005 OVC025
BECMG 2806/2808 12015G25KT
FM280800 12015G25KT P6SM -RA SCT008 OVC030
TEMPO 2808/2818 3SM -RA BR BKN008 OVC030
FM281800 16018G28KT P6SM SCT030 OVC050
TEMPO 2818/2906 6SM -SHRA BR OVC030
BECMG 2900/2902 16012KT
RMK NXT FCST BY 280300Z=");
or
$t->decode("METAR CYHZ 280200Z 34007KT 15SM SKC M03/M04 A3027 RMK SLP261=");
or
$t->decode("TAF CYYT 272340Z 2800/2824 02012G22KT 1/2SM -DZ -RA FG VV002
FM281200 01012KT 1/2SM FG VV002
PROB30 2812/2815 2SM -FZDZ BR
FM281500 35012KT 2SM BR OVC004
PROB30 2815/2821 1 1/2SM -FZDZ BR OVC003
FM282300 30010KT 2SM BR OVC004
PROB30 2823/2824 BKN003
RMK NXT FCST BY 280600Z=");
print $t->as_string;
print $t->minimal;
ABSTRACT
Geo::METARTAF decodes aviation METAR, SPECI, and TAF weather code strings into English or, if you sub-class, some other language.
DESCRIPTION
METAR (Meteorological Aerodrome Report), SPECI (Special METAR), and TAF (Terminal Aerodrome Forecast) are ASCII strings containing codes describing the weather at airports and weather bureaus around the world.
This module attempts to decode these reports into a form of English that is (hopefully) more understandable than the reports themselves.
The decoded data is based on the Transport Canada AIM.
It is possible to sub-class the translation routines to enable translation to other langauages.
METHODS
- new(%args)
-
Constructor for the class. Each weather announcement will need a new constructor.
If you sub-class the built-in English translation routines then you can pick this up by calling the constructor using:
my $t = Geo::METARTAF->new(decode_language => 'Geo::METARTAF::FR');
or whatever you decide to use.
- decode(weather_string)
-
The main routine that decodes a weather string. It expects a string that begins with either the word
METAR
,SPECI
, orTAF
. It creates a decoded form of the weather string in the object.If this method is unable to process the weather string, you can use the error method to get the reason.
- metar(weather_string)
-
This simply adds
METAR
to the front of the string and calls decode(). - speci(weather_string)
-
This simply adds
SPECI
to the front of the string and calls decode(). - taf(weather_string)
-
This simply adds
TAF
to the front of the string and calls decode().It makes very little difference to the decoding process which of these routines you use. It does, however, affect the output in that it will mark it as the appropriate type of report.
- as_string
-
Returns the decoded weather report as a human readable string.
This is probably the simplest, and most likely, of the output options that you might want to use.
- as_html
-
Returns the decoded weather report as an HTML table.
Classes are assigned to all of the table data elements allowing you to format the results using CSS styles.
- minimal
-
Returns the (cleaned up) weather report. It is cleaned up in the sense that all whitespace is reduced to exactly one space character.
- error
-
If decode() is unable to process the string, this method returns the reason.
ACCESSORS
- icao()
-
Returns the ICAO code contained in the weather report
- day()
-
Returns the day of the month of this report
- time()
-
Returns the issue time of this report
- valid_from()
-
Returns the time from which this report is valid for (if there is one).
- valid_to()
-
Returns the time to which this report is valid for (if there is one).
- visibility_dist()
-
Returns the minimum visibility, if present.
- visibility_units()
-
Returns the units of the visibility information.
- wind_dir()
-
Returns the wind direction in degrees, if present.
- wind_speed()
-
Returns the wind speed.
- wind_units()
-
Returns the units of wind speed.
- wind_gusting()
-
Returns any wind gust speed. It is possible to have wind_speed() without gust information.
- pressure()
-
Returns the altimeter setting, if present.
- pressure_units()
-
Returns the units in which pressure() is measured.
- temp()
-
Returns any outside air temperature present.
- dewpoint()
-
Returns any dew point temperature present.
SEE ALSO
Geo::METAR and Geo::TAF
This module is a modified version of the Geo::TAF module created by Dirk Koopman
For an example of a weather forecast for a Canadian airport (CYHZ) see https://metar-taf.com/cyhz
AUTHOR
Peter Carter, pecarter@yahoo.ca
COPYRIGHT AND LICENSE
Copyright (c) 2025 by Peter Carter
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.