metaf2xml: parse and decode METAR, TAF, SYNOP and BUOY and write data as XML

(deutsche Version, versión en Español)

metaf2xml parses and decodes aviation routine weather reports (METAR, SPECI), aerodrome forecasts (TAF), synoptic observations (SYNOP) and observations from buoys (BUOY). The extracted data can be written as XML or passed to a user-defined function (all done in Perl).
It also provides XSLT style sheets to convert the XML to plain language (text, HTML), or XML with different schemas. A web-based (CGI) user interface can be used to fetch and display current weather data from NOAA, Ogimet, and other sources.

Content

decoded TAF SBGL (HTML, español)
TAF SBGL
(HTML, español)
decoded METAR KJFK (HTML, english)
METAR KJFK
(HTML, english)
decoded METAR UUEE (HTML, Русский)
METAR UUEE
(HTML, Русский)

Latest version

The latest version (2012-01-04) is 1.47 (TAR, RPM, ZIP), and includes also README, change log, ToDo, distinfo, and DTD.

Background

METAR and SPECI (weather observation) and TAF (weather forecast) information is essential for flight planning and in-flight decisions (real flight and simulation). It is regularily compiled by meteorologists at about 3500 airports worldwide and distributed via reliable, non-public networks. Information for SYNOP is collected by more than 11 000 manned and unmanned meteorological stations around the world and is used for weather forecasting and climatic statistics. The format of the original messages is abbreviated, some items are coded. Here are some METAR, TAF, and SYNOP messages from Rio (SBGL, 83746), New York (KJFK, 74486), and Tokyo (RJTT, 47662) and BUOY messages from a buoy nearby (31550, 41997, 53596):

SBGL 040600Z 30003KT 9999 FEW030 22/19 Q1011
KJFK 040551Z 32019G25KT 10SM CLR M09/M20 A3015
KJFK 040837Z 0409/0512 31012KT P6SM SKC FM041500 28011KT P6SM SCT150 BKN250 FM041800
 25011KT P6SM SCT070 BKN150 FM042200 24014KT P6SM BKN070 FM050600 25009KT P6SM FEW050 SCT070 BKN150
RJTT 040630Z 34016KT 9999 FEW030 SCT080 09/M04 Q1001 TEMPO 34018G28KT RMK 1CU030
 3AC080 A2958 VIRGA ABT 20KM NE AND SE-SW MOV SE
RJTT 040846Z 0409/0512 33016KT 9999 FEW030 TEMPO 0409/0412 34020G30KT TEMPO 0506/0512 34020G30KT
AAXX 04064 74486 NIL
AAXX 04064 47662 12/80 63409 10085 21068 39982 40026 55000 60001 82202
ZZYY 41595 04012 0540/ 731764 040662 6111/ 11119 30293 40293 52247 22219 00205 444
 20110 04012 0522/ 50101 80120 80013 9/015
ZZYY 53524 04012 0640/ 130012 144649 6111/ 22219 00207 444 20110 04012 0628/ 50101 80072 80027 9/015

The format of the messages (and a lot more about observing and reporting weather) is specified in WMO Manual No. 306 or in Annex 3 to the Convention on International Civil Aviation; some countries deviate from that standard or extend it, some have published documentation (e.g. Federal Meteorological Handbook No. 1 and No. 2 for the USA). Especially the format of the remarks for METAR and TAF messages, or the coding of sections 3 and 5 for SYNOP messages depend on the country or even the observing station.

metaf2xml can be used for flight simulations or by private pilot (students) who want to extend their knowledge about the message formats, and everyone who just wants to know the current or forecast weather at some station in plain language (see examples below).

Why another METAR/TAF parser?

There are other projects that deal with METAR and TAF messages, e.g.:

But somehow I always missed a feature I liked to have.

Features of metaf2xml

processing of messages
The parser module (man page) accepts (= processes) or tolerates (= marks as error) many extensions to the standard; they are marked with "EXTENSION" in the source code. Many common minor errors in the format are corrected before parsing, more combinations of weather phenomenons are allowed, missing information is recognised in many cases, too.
All remarks are processed, some of them are interpreted depending on the issuing country or station, e.g. 'MON INVIS VAL FOSCHIA' and QUL/QUK (Italy), 'JP' (some carribean countries), 'YLO1' (military), everything from the Federal Meteorological Handbook No. 1 and the Air Force Manual 15-111 (19.12.2003), 'RSNK' and 'LAG PK' (data from other observing stations), and many more. Currently, more than 80 types of METAR remarks are recognised, excluding trivial keywords (see also the DTD).
The intention is to gain as much information as possible from a message without interpreting parts of it wrongly.

output of message data
The module XML.pm (man page) can write the data as XML. Alternatively, this module can be used to register a callback function which is passed step by step the same data in the same order as for the XML output.
The data contains solely information from the original message, with 2 exceptions: the relative humidity (actually 4 different values from 4 different formulas) and the ceiling (if there is one); these 2 items are cumbersome to compute with XSLT. For each data element, the corresponding text from the message is provided.
The intention is that no parsing of the output data should be necessary.

source of messages
Messages can be specified simply as text. Additionally, the script metaf.pl (man page) can be used from the command line or as CGI script to fetch up-to-date messages for airports (METAR/TAF) and stations (SYNOP, BUOY) from a public server or read messages from a local file.
metaf.pl uses the module src2raw.pm (man page) to extract correctly formatted messages from the files provided by public servers.

display of XML file
The project also provides XSLT style sheets to convert the XML to plain language as text or HTML in English, German, Spanish, and Russian (corrections and additions are welcome). The output in the text format is similar to the one of the program "metar" from the FlightGear project. The HTML output displays each message in a separate table. The leftmost column contains the original text for each element of the message, the top row contains the original message (see also project screenshots or examples below). To convert the content to text or HTML, the program "xsltproc" is used, but others that work similar shouldn't be a problem.
There are also XSLT style sheets to create a summary or overview: only some items of each message (currently no TAF) are shown in an abbreviated format, one line per message.

command line interface
The script metaf2xml.pl (man page) reads messages, processes them, and writes the XML data to standard output. It can serve as input for "xsltproc" or similar programs to get HTML or text.
The script metaf.pl (man page) can be used to fetch up-to-date messages from other sources.

web interface
Ideally, any XML capable browser should be able to process the XML with the XSLT style sheet specified in the file, and display the formatted result, but not all browsers are XML capable. The script metaf.pl (man page) provides an interface using either XML/XSLT or pure HTML. The XML data can be seen by viewing the source of the web page if "XML" was selected as output format.

source code is available and GPL
Everybody who wants to contribute is invited to do so. If you want to help you might pick a task from the ToDo.

Demo version on SourceForge

With the demo version with graphics (uses Ajax), the stations are marked with a dot on a map. The map can be viewed in different enlargements and can be moved by click and drag. The processed messages are displayed beneath the map, with the latest request on top. The list of stations is fixed but it also could be created dynamically, e.g. from a database.

The messages for the stations are fetched from files on the SourceForge server. These are messages from the past, the files are updated manually from time to time, only. SourceForge does not allow outgoing connections, so messages cannot be fetched directly from the internet.

It is also possible to enter weather messages as text. This requires the selection of the message type (METAR, TAF, SYNOP, BUOY).

With the text-based demo version, weather messages can be entered. If the option "ICAO id(s)" or "WMO id(s)" is selected, station id's can be entered, too. The messages for the stations will be fetched from files on the SourceForge server, as for the graphical demo version.

Several organisations and providers offer public access to up-to-date and older weather messages, e.g.:

Useful links

Demo version

(see also Demo version on SourceForge)

Files from the latest version

Man pages (generated from the perl sources)

Project links

Examples for messages in plain language

The result of the parsing of the above example messages can be found in example.xml (XML without XSLT style sheet reference). Using the XSLT style sheets from the project, the output in plain language (here: as HTML, summary first, then detailed) looks as follows:

Warning: The information below may be out-dated, inaccurate, or both. It is not suited for use in aviation.

station time (UTC) wind (kt) vis weather clouds temp (°C) hum pressure (hPa) N/R
METAR SBGL 04., 06:00 WNW 3 >=10 km FEW030 22 83% QNH1011
METAR KJFK 04., 05:51 NW 19 (G25) 16.1 km CLR -9 40% QNH1021
METAR RJTT 04., 06:30 NNW 16 >=10 km FEW030 SCT080 9 40% QNH1001 QNH1002 ABT 20KM NE AND SE-SW MOV SE
TEMPO NNW 18

type time (UTC) station vis cloud wind (kt) temp (°C) hum pressure (hPa)/GP (gpm) precip weather low,middle,high clouds cloud lvl N/P
SYNOP NIL AAXX 04., 06:00 74486 ?
SYNOP AAXX 04., 06:00 47662 30 km 6/8 NNW 9 8.5 33% SP998.2 (0.0/3h) SLP1002.6 0 mm/6h - 2/8 CU con 0/8 CI spi/cas/flo

type time (UTC) buoy wind (kt) temp (°C) hum pressure (hPa) N/P
BUOY ZZYY 04.01. xxx2, 05:40 41595 SP1029.3 (+24.7/3h) SLP1029.3 20110 04012 0522/ 50101 80120 80013 9/015
BUOY ZZYY 04.01. xxx2, 06:40 53524 20110 04012 0628/ 50101 80072 80027 9/015

Warning: The information below may be out-dated, inaccurate, or both. It is not suited for use in aviation.

Values of entries marked with * do not originate directly from the message, but are derived from its data.

SBGL 040600Z 30003KT 9999 FEW030 22/19 Q1011
METAR METAR Report
SBGL station id: SBGL (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
040600Z Report time: on the 4., 06:00 UTC
30003KT Wind: from the WNW (300° (+4°/-5°)) at 5.6 km/h 3 kt = 3.5 mph = 1.5 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW030 Sky condition: few clouds at 3000 ft 910 m
22/19 Temperature: 22 °C 71.6 °F
Dewpoint: 19 °C 66.2 °F
relative humidity*: 83%
Q1011 altimeter: 1011 hPa 29.85 in. Hg = 758 mmHg

KJFK 040551Z 32019G25KT 10SM CLR M09/M20 A3015
METAR METAR Report
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
040551Z Report time: on the 4., 05:51 UTC
32019G25KT Wind: from the NW (320° (+4°/-5°)) at 35.2 km/h 19 kt = 21.9 mph = 9.8 m/s
with gusts at 46.3 km/h 25 kt = 28.8 mph = 12.9 m/s
10SM Visibility: 10 (.. <11) miles 16.1 km
CLR Sky condition: no clouds below 10000 ft
M09/M20 Temperature: -9 °C 15.8 °F
Dewpoint: -20 °C -4.0 °F
relative humidity*: 40%
A3015 altimeter: 30.15 in. Hg 1021 hPa = 766 mmHg

KJFK 040837Z 0409/0512 31012KT P6SM SKC FM041500 28011KT P6SM SCT150 BKN250 FM041800 25011KT P6SM SCT070 BKN150 FM042200 24014KT P6SM BKN070 FM050600 25009KT P6SM FEW050 SCT070 BKN150
TAF 27h aerodrome forecast
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
040837Z Issue time: on the 4., 08:37 UTC
0409/0512 Forecast period: from the 4., 09:00 UTC till the 5., 12:00 UTC
31012KT Wind: from the NW (310° (+4°/-5°)) at 22.2 km/h 12 kt = 13.8 mph = 6.2 m/s
P6SM Visibility: >=6 miles >=9.7 km
SKC Sky condition: sky clear
trend forecast:
FM041500 from the 4., 15:00 UTC:
28011KT Wind: from the W (280° (+4°/-5°)) at 20.4 km/h 11 kt = 12.7 mph = 5.7 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT150 BKN250 Sky condition: scattered clouds at 15000 ft 4570 m
broken clouds at 25000 ft 7620 m
FM041800 from the 4., 18:00 UTC:
25011KT Wind: from the WSW (250° (+4°/-5°)) at 20.4 km/h 11 kt = 12.7 mph = 5.7 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT070 BKN150 ceiling*: at 15000 ft 4570 m
Sky condition: scattered clouds at 7000 ft 2130 m
broken clouds at 15000 ft 4570 m
FM042200 from the 4., 22:00 UTC:
24014KT Wind: from the WSW (240° (+4°/-5°)) at 25.9 km/h 14 kt = 16.1 mph = 7.2 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN070 ceiling*: at 7000 ft 2130 m
Sky condition: broken clouds at 7000 ft 2130 m
FM050600 from the 5., 06:00 UTC:
25009KT Wind: from the WSW (250° (+4°/-5°)) at 16.7 km/h 9 kt = 10.4 mph = 4.6 m/s
P6SM Visibility: >=6 miles >=9.7 km
FEW050 SCT070 BKN150 ceiling*: at 15000 ft 4570 m
Sky condition: few clouds at 5000 ft 1520 m
scattered clouds at 7000 ft 2130 m
broken clouds at 15000 ft 4570 m

RJTT 040630Z 34016KT 9999 FEW030 SCT080 09/M04 Q1001 TEMPO 34018G28KT RMK 1CU030 3AC080 A2958 VIRGA ABT 20KM NE AND SE-SW MOV SE
METAR METAR Report
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
040630Z Report time: on the 4., 06:30 UTC
34016KT Wind: from the NNW (340° (+4°/-5°)) at 29.6 km/h 16 kt = 18.4 mph = 8.2 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW030 SCT080 Sky condition: few clouds at 3000 ft 910 m
scattered clouds at 8000 ft 2440 m
09/M04 Temperature: 9 °C 48.2 °F
Dewpoint: -4 °C 24.8 °F
relative humidity*: 40%
Q1001 altimeter: 1001 hPa 29.56 in. Hg = 751 mmHg
trends within the next 2 hours:
TEMPO temporarily:
34018G28KT Wind: from the NNW (340° (+4°/-5°)) at 33.3 km/h 18 kt = 20.7 mph = 9.3 m/s
with gusts at 51.9 km/h 28 kt = 32.2 mph = 14.4 m/s
RMK Remarks:
1CU030 phenomenon w. opacity: 1/8 cumulus at 3000 ft 910 m
3AC080 phenomenon w. opacity: 3/8 altocumulus at 8000 ft 2440 m
A2958 altimeter: 29.58 in. Hg 1002 hPa = 751 mmHg
VIRGA virga
ABT 20KM NE AND SE-SW MOV SE NOT RECOGNISED: ABT 20KM NE AND SE-SW MOV SE

RJTT 040846Z 0409/0512 33016KT 9999 FEW030 TEMPO 0409/0412 34020G30KT TEMPO 0506/0512 34020G30KT
TAF 27h aerodrome forecast
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
040846Z Issue time: on the 4., 08:46 UTC
0409/0512 Forecast period: from the 4., 09:00 UTC till the 5., 12:00 UTC
33016KT Wind: from the NNW (330° (+4°/-5°)) at 29.6 km/h 16 kt = 18.4 mph = 8.2 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW030 Sky condition: few clouds at 3000 ft 910 m
trend forecast:
TEMPO 0409/0412 from the 4., 09:00 UTC till the 4., 12:00 UTC temporarily:
34020G30KT Wind: from the NNW (340° (+4°/-5°)) at 37 km/h 20 kt = 23 mph = 10.3 m/s
with gusts at 55.6 km/h 30 kt = 34.5 mph = 15.4 m/s
TEMPO 0506/0512 from the 5., 06:00 UTC till the 5., 12:00 UTC temporarily:
34020G30KT Wind: from the NNW (340° (+4°/-5°)) at 37 km/h 20 kt = 23 mph = 10.3 m/s
with gusts at 55.6 km/h 30 kt = 34.5 mph = 15.4 m/s

AAXX 04064 74486 NIL
SYNOP Synoptic observation (main hour) (report missing)
section 0:
AAXX fixed land station
0406 Report time: on the 4., 06:00 UTC
4 wind data: kt
74486 station id: 74486 (North and Central Amerika) (Kennedy International Airport, New York, New York, USA)

AAXX 04064 47662 12/80 63409 10085 21068 39982 40026 55000 60001 82202
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0406 Report time: on the 4., 06:00 UTC
4 wind data: kt
47662 station id: 47662 (Asia) (Metropolitan Area Heliport Tokyo, Japan)
section 1:
1 precipitation data: in section 1
2 weather data: omitted (no significant phenomenon)
/ base of lowest cloud: (not available)
80 Visibility: 30 (.. <31) km 18.6 miles
6 total cloud cover: 6/8 (7..8/10)
3409 Wind: from the NNW (340° (+4°/-5°)) at 16.7 km/h 9 kt = 10.4 mph = 4.6 m/s
10085 21068 Temperature: 8.5 °C 47.3 °F
Dewpoint: -6.8 °C 19.8 °F
relative humidity*: 33%
39982 station level pressure: 998.2 hPa 29.48 in. Hg = 749 mmHg
40026 sea level pressure: 1002.6 hPa 29.61 in. Hg = 752 mmHg
55000 pressure change (station level) since 3 hour(s): 0.0 hPa, having decreased then increased
60001 precip. amount since 6 hour(s): 0 mm 0 in.
82202 cloud types: low: 2/8 (2..3/10) cumulus (moderate/strong vertical extent or towering cumulus) (Cu mediocris or congestus)
mid-level: no clouds
high: cirrus (dense, with sproutings, or in tufts) (Ci spissatus, castellanus, or flocus)

ZZYY 41595 04012 0540/ 731764 040662 6111/ 11119 30293 40293 52247 22219 00205 444 20110 04012 0522/ 50101 80120 80013 9/015
warning: not processed: 20110 04012 0522/ 50101 80120 80013 9/015
BUOY Buoy observation
section 0:
ZZYY buoy
41595 buoy id: 41595 (North and Central Amerika) (41595, )
04012 0540 Report time: on the 4.1. xxx2, 05:40 UTC
/ wind data: (not available)
731764 040662 station position: 31.764° N 40.662° W
6111/ quality of position: data is good
quality of time: data is good
position error (66% probab.) from: >=500 m >=1640 ft
to: <1500 m <4920 ft
111 section 1:
19 quality of this section: data is good
30293 station level pressure: 1029.3 hPa 30.40 in. Hg = 772 mmHg
40293 sea level pressure: 1029.3 hPa 30.40 in. Hg = 772 mmHg
52247 pressure change (station level) since 3 hour(s): +24.7 hPa, having increased steadily or unsteadily
222 section 2:
19 quality of this section: data is good
00205 surface temperature: 20.5 °C 68.9 °F
444 section 4:

ZZYY 53524 04012 0640/ 130012 144649 6111/ 22219 00207 444 20110 04012 0628/ 50101 80072 80027 9/015
warning: not processed: 20110 04012 0628/ 50101 80072 80027 9/015
BUOY Buoy observation
section 0:
ZZYY buoy
53524 buoy id: 53524 (South-West Pacific) (53524, )
04012 0640 Report time: on the 4.1. xxx2, 06:40 UTC
/ wind data: (not available)
130012 144649 station position: 30.012° N 144.649° E
6111/ quality of position: data is good
quality of time: data is good
position error (66% probab.) from: >=500 m >=1640 ft
to: <1500 m <4920 ft
222 section 2:
19 quality of this section: data is good
00207 surface temperature: 20.7 °C 69.3 °F
444 section 4:

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