SYNOPSIS

  use Geo::METAR;
  use strict;

  my $m = new Geo::METAR;
  $m->metar("KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014");
  print $m->dump;

  exit;

DESCRIPTION

\s-1METAR\s0 reports are available on-line, thanks to the National Weather Service. Since reading the \s-1METAR\s0 format isn't easy for non-pilots, these reports are relatively useles to the common man who just wants a quick glace at the weather. This module tries to parse the \s-1METAR\s0 reports so the data can be used to create readable weather reports and/or process the data in applications.

USAGE

\$1

Here is how you might use the Geo::METAR module.

One use that I have had for this module is to query the \s-1NWS\s0 \s-1METAR\s0 page (using the \s-1LWP\s0 modules) at:

http://weather.noaa.gov/cgi-bin/mgetmetar.pl?cccc=EHSB

to get an up-to-date \s-1METAR\s0. Then, I scan thru the output, looking for what looks like a \s-1METAR\s0 string (that's not hard in Perl). Oh, \s-1EHSB\s0 can be any site location code where there is a reporting station.

I then pass the \s-1METAR\s0 into this module and get the info I want. I can then update my webcam page with the current temperature, sky conditions, or whatnot. See for yourself at http://webcam.idefix.net/

See the \s-1BUGS\s0 section for a remark about multiple passes with the same Geo::METAR object. The following functions are defined in the \s-1METAR\s0 module. Most of them are public, meaning that you're supposed to use them. Some are private, meaning that you're not supposed to use them \*(-- but I won't stop you. Assume that functions are public unless otherwise documented.

metar()

metar() is the function to whwich you should pass a \s-1METAR\s0 string. It will take care of decomposing it into its component parts converting the units and so on. Example: \*(C`$m->metar("KFDY 251450Z 21012G21KT 8SM OVC065 04/M01 A3010 RMK 57014");\*(C'

debug()

debug() toggles debugging messages. By default, debugging is turned off. Turn it on if you are developing \s-1METAR\s0 or having trouble with it. debug() understands all of the folloing: Enable Disable ------ ------- 1 0 'yes' 'no' 'on' 'off' If you contact me for help, I'll likely ask you for some debugging output. Example: \*(C`$m->debug(1);\*(C'

dump()

dump() will dump the internal data structure for the \s-1METAR\s0 in a semi-human readable format. Example: \*(C`$m->dump;\*(C'

version()

version() will print out the current version. Example: \*(C`print $m->version;\*(C'

_tokenize()

\s-1PRIVATE\s0 Called internally to break the \s-1METAR\s0 into its component tokens.

_process()

\s-1PRIVATE\s0 Used to make sense of the tokens found in _tokenize(). After you've called metar(), you'd probably like to get at the individual values for things like temperature, dew point, and so on. You do that by accessing individual variables via the \s-1METAR\s0 object.

This section lists those variables and what they represent.

If you call dump(), you'll find that it spits all of these out.

\s-1VERSION\s0

The version of \s-1METAR\s0.pm that you're using.

\s-1METAR\s0

The actual, raw \s-1METAR\s0.

\s-1TYPE\s0

Report type in English (\*(L"Routine Weather Report\*(R" or \*(L"Special Weather Report\*(R")

\s-1SITE\s0

4-letter site code.

\s-1DATE\s0

The date (just the day of the month) on which the report was issued.

\s-1TIME\s0

The time at which the report was issued.

\s-1MOD\s0

Modifier (\s-1AUTO/COR\s0) if any.

\s-1WIND_DIR_ENG\s0

The current wind direction in English (Southwest, East, North, etc.)

\s-1WIND_DIR_ABB\s0

The current wind direction in abbreviated English (S, E, N, etc.)

\s-1WIND_DIR_DEG\s0

The current wind direction in degrees.

\s-1WIND_KTS\s0

The current wind speed in Knots.

\s-1WIND_MPH\s0

The current wind speed in Miles Per Hour.

\s-1WIND_MS\s0

The current wind speed in Metres Per Second.

\s-1WIND_GUST_KTS\s0

The current wind gusting speed in Knots.

\s-1WIND_GUST_MPH\s0

The current wind gusting speed in Miles Per Hour.

\s-1WIND_GUST_MS\s0

The current wind gusting speed in Metres Per Second.

\s-1WIND_VAR\s0

The wind variation in English

\s-1WIND_VAR_1\s0

The first wind variation direction

\s-1WIND_VAR_ENG_1\s0

The first wind variation direction in English

\s-1WIND_VAR_2\s0

The second wind variation direction

\s-1WIND_VAR_ENG_2\s0

The second wind variation direction in English

\s-1VISIBILITY\s0

Visibility information.

\s-1WIND\s0

Wind information.

\s-1RUNWAY\s0

Runway information.

\s-1WEATHER\s0

Current weather (array)

\s-1WEATHER_LOG\s0

Current weather log (array)

\s-1SKY\s0

Current cloud cover (array)

\s-1TEMP_C\s0

Temperature in Celsius.

\s-1TEMP_F\s0

Temperature in Fahrenheit.

\s-1DEW_C\s0

Dew point in Celsius.

\s-1DEW_F\s0

Dew point in Fahrenheit.

\s-1HOURLY_TEMP_F\s0

Hourly current temperature, fahrenheit

\s-1HOURLY_TEMP_C\s0

Hourly current temperature, celcius

\s-1HOURLY_DEW_F\s0

Hourly dewpoint, fahrenheit

\s-1HOURLY_DEW_C\s0

Hourly dewpoint, celcius

\s-1ALT\s0

Altimeter setting (barometric pressure).

\s-1ALT_HP\s0

Altimeter setting in hectopascals.

\s-1REMARKS\s0

Any remarks in the report.

NOTES

Test suite is small and incomplete. Needs work yet.

Older versions of this module were installed as \*(L"\s-1METAR\s0\*(R" instaed of \*(L"Geo::METAR\*(R"

BUGS

The Geo::METAR is only initialized once, which means you'll get left-over crud in variables when you call the metar() function twice.

What is an invalid \s-1METAR\s0 in one country is a standard one in the next. The standard is interpreted and used by meteorologists all over the world, with local variations. This means there will always be METARs that will trip the parser.

TODO

There is a \s-1TODO\s0 file included in the Geo::METAR distribution listing the outstanding tasks that I or others have devised. Please check that list before you submit a bug report or request a new feture. It might already be on the \s-1TODO\s0 list.

AUTHORS AND COPYRIGHT

Copyright 1997-2000, Jeremy D. Zawodny <Jeremy [at] Zawodny.com>

Copyright 2007, Koos van den Hout <[email protected]>

Geo::METAR is covered under the \s-1GNU\s0 Public License (\s-1GPL\s0) version 2 or later.

The Geo::METAR Web site is located at:

http://idefix.net/~koos/perl/Geo-METAR/

CREDITS

In addition to our work on Geo::METAR, We've received ideas, help, and patches from the following folks:

* Ethan Dicks <ethan.dicks [at] gmail.com>

Testing of Geo::METAR at the South Pole. Corrections and pointers to interesting cases to test.

* Otterboy <jong [at] watchguard.com>

Random script fixes and initial debugging help

* Remi Lefebvre <remi [at] solaria.dhis.org>

Debian packaging as libgeo-metar-perl.deb.

* Mike Engelhart <mengelhart [at] earthtrip.com>

Wind direction naming corrections.

* Michael Starling <mstarling [at] logic.bm>

Wind direction naming corrections.

* Hans Einar Nielssen <hans.einar [at] nielssen.com>

Wind direction naming corrections.

* Nathan Neulinger <nneul [at] umr.edu>

Lots of enhancements and corrections. Too many to list here.

RELATED PROJECTS

lcdproc at http://www.lcdproc.org/ uses Geo::METAR in lcdmetar.pl to display weather data on an lcd.