metaf.pl - download and display METAR/TAF/SYNOP/BUOY/AMDAR messages
as a standalone script used from the command line:
metaf.pl type_metaf=... type_synop=... type_buoy=... type_amdar=... lang=... format=... src_metaf=... src_synop=... src_buoy=... src_amdar=... mode=... hours=... msg_metaf='...' msg_synop='...' msg_buoy='...' msg_amdar='...'
or as a CGI script used by an HTML form (HTTP method GET):
<form method="GET" action="metaf.pl">
<input name="type_metaf" ... >
<input name="type_synop" ... >
<input name="type_buoy" ... >
<input name="type_amdar" ... >
<input name="lang" ... >
<input name="format" ... >
<input name="src_metaf" ... >
<input name="src_synop" ... >
<input name="src_buoy" ... >
<input name="src_amdar" ... >
<input name="mode" ... >
<input name="hours" ... >
<input name="msg_metaf" ... >
<input name="msg_synop" ... >
<input name="msg_buoy" ... >
<input name="msg_amdar" ... >
This script can download and display in plain language up-to-date or historical
weather information (METAR, TAF, SYNOP, BUOY or AMDAR messages) from Internet
servers, an SQL database, or a local file. It can be used from the command
line, or with GET or POST requests if it is installed to be called via CGI by
a web server.
If the script is called from a web server and the file $CGI_LOG_FILE is writable
by the user running the web server (e.g. "wwwrun"), metaf.pl will
log the requests there.
The Perl modules "CGI", "metaf2xml::parser" and
"metaf2xml::src2raw" are required.
The Perl module "DBI" and the module "DBD" (for the
configured type of data source) are required if an SQL database is used as the
The program "curl" is required to download weather messages from
The program "xsltproc" is required if the script is to convert the XML
to HMTL or text.
- National Oceanic and Atmospheric Administration
- the National Weather Service department of the NOAA
- the Internet Weather Source of the NWS
- the Aviation Digital Data Service of the NWS
- the experimental data server of the Aviation Digital Data Service of the
- College of DuPage
- Florida State University
- print version of metaf.pl and exit
The following variables can be set from CGI parameters or on the command line:
- type of content in "msg_metaf":
- METAR/SPECI/SAO message (default)
- TAF message
- ICAO id(s)
If "msg_metaf" starts with "METAR", "SPECI" or
"TAF", "type_metaf" is set to metar
If "msg_metaf" is not a list of ICAO id(s), "type_metaf" is
set to metar
If "type_metaf" is icao
and one or more ICAO ids are given,
messages for the specified airports are fetched from
- type of content in "msg_synop":
- SYNOP message (default)
- WMO SYNOP id(s)
- national id(s) STATION-COUNTRY
- SYNOP SHIP id(s)
- SYNOP MOBIL id(s)
If "msg_synop" starts with "AAXX", "BBXX" or
"OOXX" or is not a list of SYNOP ids, "type_synop" is set
If "type_synop" is wmo
and one or more SYNOP ids are given, messages for the specified stations are
fetched from "src_synop".
- type of content in "msg_buoy":
- BUOY message (default)
- WMO buoy id(s)
If "msg_buoy" is not a list of WMO buoy ids, "type_buoy" is
set to buoy
If "type_buoy" is wmo
and one or more WMO buoy ids are given,
messages for the specified buoys are fetched from "src_buoy".
- type of content in "msg_amdar":
- AMDAR message (default)
- aircraft id(s)
If "msg_amdar" starts with "AMDAR" or is not a list of
aircraft ids, "type_amdar" is set to amdar
If "type_amdar" is ac
and one or more aircraft ids are given,
messages for the specified aircrafts are fetched from
- language for output of script and display of parsed message: de
(default), en, es, ru
If "lang" is not set the first allowed value of the HTTP header
"Accept-Language" is used.
- output format: html (default), text, xml (with style
- source for METAR/TAF messages to be fetched: noaa (NOAA/IWS)
(default), adds, addsds, ogimet,
nws, cod (no TAF), fsu (no TAF). It is
ignored if a source in "DB_DATA_SOURCES" could be opened or
Note: cod and fsu are not available in the web-based
- source for SYNOP messages to be fetched: nws (default),
ogimet, cod, fsu. It is ignored if a source
in "DB_DATA_SOURCES" could be opened or
$CGI_DATA_DIR /synop.txt exists.
Note: fsu is not available in the web-based interfaces.
- source for BUOY messages to be fetched: nws (default),
ogimet. It is ignored if a source in
"DB_DATA_SOURCES" could be opened or
$CGI_DATA_DIR /buoy.txt exists.
- source for AMDAR messages to be fetched: nws (default),
fsu. It is ignored if a source in "DB_DATA_SOURCES"
could be opened or $CGI_DATA_DIR/amdar.txt
- which messages to show and how to show them:
- show all messages in selected time period, show one row per message (TAF:
one row per forecast period, AMDAR: one row per observation)
- any other value (or omitted)
- show only latest messsage for each station in selected time period, show
values in detail
- for mode summary: number of hours to fetch messages for (0..72,
Note: The exact time range for which data can be fetched depends on the
source of messages.
- METAR/TAF message to be processed, or ICAO id(s)
- SYNOP message to be processed, or WMO id(s)
- BUOY message to be processed, or WMO id(s)
- AMDAR message to be processed, or aircraft id(s)
: Files will be fetched from the server and searched. Note: The parameter
is used to select files by their time stamp or name; the selected
files do not necessarily contain only messages for the choosen hours
: the HTML form provided by the server will be used
: For the description of the configuration variable $DB_DATA_SOURCES see the
for "DB_DATA_SOURCES" below.
: For the format required for the files in $CGI_DATA_DIR
see the USAGE NOTES
for "CGI_DATA_DIR" below.
The length of the body of the POST request (not the length of query string of
the URL) is restricted to 600 bytes.
The following variables can be adapted to local needs; this is typically done
during the installation:
- directory for the XSL style sheets
- directory for files with pre-processed METAR/TAF/SYNOP/BUOY/AMDAR messages
The messages in these files must have the format specified by the WMO
Manual No. 306, without modifications due to distribution like
providing the initial part of messages only once for several messages or
appending an "=" (equal sign) to terminate a message, with the
data type "T1T2" prepended. This format can be obtained using:
metafsrc2raw.pl -F<FORMAT> -H1 [FILE] ...
- complete path for log file
- path and options for "curl"
- options for "curl" if an HTTP proxy should be used
- space delimited strings to describe possible data sources
If the string "sqlite" is in the list, the file
$CGI_DATA_DIR /sqlite.db is used as database. For
other strings, the file
$CGI_DATA_DIR/"string" .db should
contain the connect string ("DBI:"...) in the first line. The
database username is "metaf2xml", it has no password; the user
"metaf2xml" should have only SELECT rights.
The first data source which can be opened is used. If the last data source
fails to open or "DB_DATA_SOURCES" is empty, the parameters
"src_"* are used.
However, if a string ends in "/f", this is the last data source to
try and the parameters "src_"* are not used, either. If this
source fails to open, the script will exit with the HTTP error 503.
The Perl module "DBI" and the module "DBD" for the
configured data source are required if a database is to be used.
If there are any CGI errors the type of error is reported and the script
The parameters "msg_"* are truncated to 3000 characters. Letters are
converted to upper case. Any characters that are not allowed in a message are
If an invalid option was provided, the script will exit with status 1, otherwise
it will exit with status 0.
Parse a METAR message and print the result as HTML:
metaf.pl msg_metaf="YUDO 090600Z 00000KT CAVOK 22/15 Q1021"
Fetch up-to-date METAR and TAF messages (from NOAA/IWS), SYNOP messages (from
NOAA/NWS land) for Rio (SBGL, 83746), New York (KJFK, 74486), and Tokyo (RJTT,
47662) and BUOY messages from a buoy nearby (from NOAA/NWS) and print the
result as XML:
metaf.pl format=xml type_metaf=icao type_synop=wmo type_buoy=wmo msg_metaf="SBGL KJFK RJTT" msg_synop="83746 74486 47662" msg_buoy="31550 41997 53596"
metaf2xml::parser(3pm), metaf2xml::src2raw(3pm), metafsrc2raw(1),
copyright (c) 2006-2017 metaf2xml @ <http://metaf2xml.sourceforge.net/>
This program 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 2 of the License, or (at your option) any later
This program 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
this program. If not, see <https://www.gnu.org/licenses/>.