metaf2xml: manual for metaf.pl 2.9

NAME

metaf.pl - download and display METAR/TAF/SYNOP/BUOY/AMDAR messages

SYNOPSIS

metaf.pl can be run from the command line like this:

 metaf.pl 'type_metaf=...&type_synop=...&type_buoy=...&type_amdar=...&lang=...&unit_temp=...&format=...&src_metaf=...&src_synop=...&src_buoy=...&src_amdar=...&mode=...&hours=...&msg_metaf=...&msg_synop=...&msg_buoy=...&msg_amdar=...'

or like this:

 metaf.pl type_metaf=... type_synop=... type_buoy=... type_amdar=... lang=... unit_temp=... format=... src_metaf=... src_synop=... src_buoy=... src_amdar=... mode=... hours=... msg_metaf='...' msg_synop='...' msg_buoy='...' msg_amdar='...'

It can also be used as a CGI script via an HTML form like this:

 <form method=GET action=metaf.pl>
  <input name=type_metaf value=... >
  <input name=type_synop value=... >
  <input name=type_buoy value=... >
  <input name=type_amdar value=... >
  <input name=lang value=... >
  <input name=unit_temp value=... >
  <input name=format value=... >
  <input name=src_metaf value=... >
  <input name=src_synop value=... >
  <input name=src_buoy value=... >
  <input name=src_amdar value=... >
  <input name=mode value=... >
  <input name=hours value=... >
  <input name=msg_metaf value="..." >
  <input name=msg_synop value="..." >
  <input name=msg_buoy value="..." >
  <input name=msg_amdar value="..." >
 </form>

DESCRIPTION

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 executed as a CGI script by a web server with HTTP GET requests via an HTML form.

If the script is executed by 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.

DEPENDENCIES

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 data source.

The program curl is required to download weather messages from Internet servers.

The program xsltproc is required if the script is to convert the XML to HMTL or text.

ABBREVIATIONS

noaa

National Oceanic and Atmospheric Administration

nws

the National Weather Service department of the NOAA

iws

the Internet Weather Source of the NWS

addsds

the Text Data Server API service of the Aviation Weather Center of the NOAA

cod

College of DuPage

OPTIONS

-v

print version of metaf.pl and exit

ARGUMENTS

The following variables can be set from CGI parameters or on the command line:

type_metaf

type of content in msg_metaf:

metar

METAR/SPECI/SAO message (default)

taf

TAF message

icao

ICAO id(s)

If msg_metaf starts with METAR, SPECI or TAF, type_metaf is set to metar or taf, respectively.

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 src_metaf.

type_synop

type of content in msg_synop:

synop

SYNOP message (default)

wmo

WMO SYNOP id(s)

nat

national id(s) STATION-COUNTRY

ship

SYNOP SHIP id(s)

mobil

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 to synop.

If type_synop is wmo, ship, mobil or nat and one or more SYNOP ids are given, messages for the specified stations are fetched from src_synop.

type_buoy

type of content in msg_buoy:

buoy

BUOY message (default)

wmo

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_amdar

type of content in msg_amdar:

amdar

AMDAR message (default)

ac

aircraft id(s)

If msg_amdar starts with AMDAR or ARP, 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 src_amdar.

lang

language for output of script and display of parsed message: de (default), en, es

If lang is not set the first allowed value of the HTTP header Accept-Language is used.

unit_temp

unit for temperatures in summary mode: C (default), F

format

output format: html (default), text, xml (with style sheet reference)

src_metaf

source for METAR/TAF messages to be fetched: noaa (NOAA/IWS)[1] (default), addsds[2], ogimet[2], nws[1], cod[1] (no TAF). It is ignored if a source in DB_DATA_SOURCES[3] could be opened or $CGI_DATA_DIR/metaf.txt[4] exists.

Note: cod is not available in the web-based interfaces.

src_synop

source for SYNOP messages to be fetched: nws[1] (default), ogimet[2], cod[1]. It is ignored if a source in DB_DATA_SOURCES[3] could be opened or $CGI_DATA_DIR/synop.txt[4] exists.

src_buoy

source for BUOY messages to be fetched: nws[1] (default), ogimet[2]. It is ignored if a source in DB_DATA_SOURCES[3] could be opened or $CGI_DATA_DIR/buoy.txt[4] exists.

src_amdar

source for AMDAR messages to be fetched: nws[1] (default). It is ignored if a source in DB_DATA_SOURCES[3] could be opened or $CGI_DATA_DIR/amdar.txt[4] exists.

mode

which messages to show and how to show them:

summary

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 message for each station in selected time period, show values in detail

hours

for mode summary: number of hours to fetch messages for (0..72, default: 24)

Note: The exact time range for which data can be fetched depends on the source of messages.

msg_metaf

METAR/TAF message to be processed, or ICAO id(s)

msg_synop

SYNOP message to be processed, or WMO id(s)

msg_buoy

BUOY message to be processed, or WMO id(s)

msg_amdar

AMDAR message to be processed, or aircraft id(s)

[1]: Files will be fetched from the server and searched. Note: The parameter hours is used to select files by their time stamp or name; the selected files do not necessarily contain only messages for the chosen hours.

[2]: the HTML form provided by the server will be used

[3]: For the description of the configuration variable $DB_DATA_SOURCES see the USAGE NOTES for DB_DATA_SOURCES below.

[4]: For the format required for the files in $CGI_DATA_DIR see the USAGE NOTES for CGI_DATA_DIR below.

USAGE NOTES

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:

METAF2XML_SHARE

directory for the XSL style sheets

CGI_DATA_DIR

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] ...
CGI_LOG_FILE

complete path for log file

CURL_PATH

full path for curl

CURL_OPTS

options for curl

CURL

path and options for curl

CURL_PROXY_OPTS

options for curl if an HTTP proxy should be used

XSLTPROC_PATH

full path for xsltproc

DB_DATA_SOURCES

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 Data Source Name (DBI:...) in the first line. If the second line starts with user=, the rest of the line is used as user name for the authentication. If a user name was given and the third line starts with pass=, the rest of the line is used as password for the authentication.

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, an error will be reported.

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 terminates.

The parameters msg_* are truncated to 3000 characters. Letters are converted to upper case. Any characters that are not allowed in a message are removed.

EXIT STATUS

If an invalid option was provided, the script will exit with status 1, otherwise it will exit with status 0.

EXAMPLES

Parse a METAR message and print the result as HTML:

 metaf.pl msg_metaf="QUDO 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"

SEE ALSO

metaf2xml::parser(3pm), metaf2xml::src2raw(3pm), metafsrc2raw(1), https://metaf2xml.sourceforge.io/

copyright (c) 2006-2023 metaf2xml @ SourceForge.net Logo

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 version.

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/.