metaf2xml Logo

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

(deutsche Version, versión española)

metaf2xml parses and decodes aviation routine weather reports (METAR, SPECI, SAO), 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

Screenshots

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 (2013-02-20) is 1.51 (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 (31764, 43573, 21210):

SBGL 200600Z 07006KT 9999 FEW017 26/23 Q1013
KJFK 200651Z 28016G22KT 10SM FEW048 02/M07 A2975 RMK AO2 PK WND 26030/0610 SLP072 T00221067
KJFK 200539Z 2006/2112 28016G25KT P6SM SCT040 FM201400 28022G33KT P6SM BKN040 FM210200
 28017G28KT P6SM FEW040
RJTT 200630Z 14009KT 9999 FEW030 07/M04 Q1013 NOSIG RMK 1CU030 A2992 MOD TURB OBS
 AT 0604Z STONE 11000FT BY B738
AAXX 20064 74486 12666 22921 10028 21056 30060 40071 51015 69951 90551 333 91028 555 92006
AAXX 20064 47662 12/80 11705 10075 21073 30093 40138 56015 60001 81200
ZZYY 31374 20023 04001 528487 047361 6113/ 11119 03603 10261 20237 40139 22219 00270
 10804 20080 21021 33311 66699 20007 22033 20030 02033 20055 20031 444 20130 20023 0354/ 518// 60371
ZZYY 41739 20023 0600/ 723541 065700 6113/ 11119 40204 57016 444 20130 20023 0600/
 50101 80142 80015 9/015
ZZYY 52616 20023 0605/ 131717 138252 6112/ 22219 00190 444 20120 20023 0603/ 50101 80102 80028 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.

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 sky temp (°C) hum pressure (hPa) N/R
METAR SBGL 20., 06:00 ENE 6 >=10 km FEW017 26 84 % QNH1013
METAR KJFK 20., 06:51 W 16 (G22, G30@06:10) 16.1 km FEW048 2 (2.2) 51 % (52 %) QNH1007 SLP1007.2
METAR RJTT 20., 06:30 SE 9 >=10 km FEW030 7 45 % QNH1013 QNH1013 MOD TURB OBS AT 0604Z STONE 11000FT BY B738

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 AAXX 20., 06:00 74486 16.1 km 2/8 3250..<4950 ft WNW 21 (G28/10m) 2.8 54 % SP1006.0 (+1.5/3h) SLP1007.1 0.5 mm/6h -
SYNOP AAXX 20., 06:00 47662 30 km 1/8 S 5 7.5 34 % SP1009.3 (-1.5/3h) SLP1013.8 0 mm/6h - 1/8 CU con 0/8 0/8

type time (UTC) buoy wind (kt) temp (°C) hum pressure (hPa) N/P
BUOY ZZYY 20.02. xxx3, 04:00 31374 N 5.8 26.1 87 % SLP1013.9
BUOY ZZYY 20.02. xxx3, 06:00 41739 SLP1020.4 (-1.6/3h)
BUOY ZZYY 20.02. xxx3, 06:05 52616

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 200600Z 07006KT 9999 FEW017 26/23 Q1013
METAR METAR Report
SBGL station id: SBGL (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
200600Z Report time: on the 20., 06:00 UTC
07006KT Wind: from the east-north-east (70° (+4°/-5°)) at 11.1 km/h 6 kt = 6.9 mph = 3.1 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW017 Sky condition: few clouds at 510 (.. <540) m 1700 ft
26/23 Temperature: 26 °C 78.8 °F
Dewpoint: 23 °C 73.4 °F
relative humidity*: 84 %
Q1013 altimeter: 1013 hPa 29.91 in. Hg = 760 mmHg

KJFK 200651Z 28016G22KT 10SM FEW048 02/M07 A2975 RMK AO2 PK WND 26030/0610 SLP072 T00221067
METAR METAR Report
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
200651Z Report time: on the 20., 06:51 UTC
28016G22KT Wind: from the west (280° (+4°/-5°)) at 29.6 km/h 16 kt = 18.4 mph = 8.2 m/s
with gusts at 40.7 km/h 22 kt = 25.3 mph = 11.3 m/s
10SM Visibility: 10 (.. <11) miles 16.1 km
FEW048 Sky condition: few clouds at 4800 (>4750 .. 4850) ft 1440 m
02/M07 Temperature: 2 °C 35.6 °F
Dewpoint: -7 °C 19.4 °F
relative humidity*: 51 %
A2975 altimeter: 29.75 in. Hg 1007 hPa = 756 mmHg
RMK Remarks:
AO2 automated station with precipitation discriminator (ASOS)
PK WND 26030/0610 peak wind at 06:10 UTC: from the west (260°) at 55.6 km/h 30 kt = 34.5 mph = 15.4 m/s
SLP072 sea level pressure: 1007.2 hPa 29.74 in. Hg = 755 mmHg
T00221067 Temperature: 2.2 °C 36.0 °F
Dewpoint: -6.7 °C 19.9 °F
relative humidity*: 52 %

KJFK 200539Z 2006/2112 28016G25KT P6SM SCT040 FM201400 28022G33KT P6SM BKN040 FM210200 28017G28KT P6SM FEW040
TAF 30h aerodrome forecast
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
200539Z Issue time: on the 20., 05:39 UTC
2006/2112 Forecast period: from the 20., 06:00 UTC till the 21., 12:00 UTC
28016G25KT Wind: from the west (280° (+4°/-5°)) at 29.6 km/h 16 kt = 18.4 mph = 8.2 m/s
with gusts at 46.3 km/h 25 kt = 28.8 mph = 12.9 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT040 Sky condition: scattered clouds at 4000 (>3950 .. 4050) ft 1200 m
trend forecast:
FM201400 from the 20., 14:00 UTC:
28022G33KT Wind: from the west (280° (+4°/-5°)) at 40.7 km/h 22 kt = 25.3 mph = 11.3 m/s
with gusts at 61.1 km/h 33 kt = 38 mph = 17 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN040 ceiling*: at 4000 (>3950 .. 4050) ft 1200 m
Sky condition: broken clouds at 4000 (>3950 .. 4050) ft 1200 m
FM210200 from the 21., 02:00 UTC:
28017G28KT Wind: from the west (280° (+4°/-5°)) at 31.5 km/h 17 kt = 19.6 mph = 8.7 m/s
with gusts at 51.9 km/h 28 kt = 32.2 mph = 14.4 m/s
P6SM Visibility: >=6 miles >=9.7 km
FEW040 Sky condition: few clouds at 4000 (>3950 .. 4050) ft 1200 m

RJTT 200630Z 14009KT 9999 FEW030 07/M04 Q1013 NOSIG RMK 1CU030 A2992 MOD TURB OBS AT 0604Z STONE 11000FT BY B738
METAR METAR Report
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
200630Z Report time: on the 20., 06:30 UTC
14009KT Wind: from the south-east (140° (+4°/-5°)) at 16.7 km/h 9 kt = 10.4 mph = 4.6 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW030 Sky condition: few clouds at 900 (.. <930) m 3000 ft
07/M04 Temperature: 7 °C 44.6 °F
Dewpoint: -4 °C 24.8 °F
relative humidity*: 45 %
Q1013 altimeter: 1013 hPa 29.91 in. Hg = 760 mmHg
trends within the next 2 hours:
NOSIG no significant change
RMK Remarks:
1CU030 phenomenon w. opacity: 1/8 (1/10) or less, but not 0/8 (0/10) cumulus at 900 (.. <930) m 3000 ft
A2992 altimeter: 29.92 in. Hg 1013 hPa = 760 mmHg
MOD TURB OBS AT 0604Z STONE 11000FT BY B738 NOT RECOGNISED: MOD TURB OBS AT 0604Z STONE 11000FT BY B738

AAXX 20064 74486 12666 22921 10028 21056 30060 40071 51015 69951 90551 333 91028 555 92006
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
2006 Report time: on the 20., 06:00 UTC
4 wind data: kt
74486 station id: 74486 (North and Central Amerika) (Kennedy International Airport, New York, New York, USA)
section 1:
1 precipitation data: in section 1
2 weather data: omitted (no significant phenomenon)
6 base of lowest cloud from: 3250 ft 990 m
to: <4950 ft <1510 m
66 Visibility: 10 (.. <11) miles 16.1 km
2 total cloud cover: 2/8 (2..3/10)
2921 Wind: from the west-north-west (290° (+4°/-5°)) at 38.9 km/h 21 kt = 24.2 mph = 10.8 m/s
10028 21056 Temperature: 2.8 °C 37.0 °F
Dewpoint: -5.6 °C 21.9 °F
relative humidity*: 54 %
30060 station level pressure: 1006.0 hPa 29.71 in. Hg = 755 mmHg
40071 sea level pressure: 1007.1 hPa 29.74 in. Hg = 755 mmHg
51015 pressure change (station level) since 3 hour(s): +1.5 hPa, having increased, then steady; or increased then increased more slowly
69951 precip. amount since 6 hour(s): 0.5 mm 0.02 in.
90551 exact obs. time: at 05:51 UTC
333 section 3:
91028 highest gust since 10 min.: 51.9 km/h 28 kt = 32.2 mph = 14.4 m/s
555 section 5:
92006 Report time: on the 20., 06:00 UTC

AAXX 20064 47662 12/80 11705 10075 21073 30093 40138 56015 60001 81200
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
2006 Report time: on the 20., 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
1 total cloud cover: 1/8 (1/10) or less, but not 0/8 (0/10)
1705 Wind: from the south (170° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
10075 21073 Temperature: 7.5 °C 45.5 °F
Dewpoint: -7.3 °C 18.9 °F
relative humidity*: 34 %
30093 station level pressure: 1009.3 hPa 29.80 in. Hg = 757 mmHg
40138 sea level pressure: 1013.8 hPa 29.94 in. Hg = 760 mmHg
56015 pressure change (station level) since 3 hour(s): -1.5 hPa, having decreased, then steady; or decreased then decreased more slowly
60001 precip. amount since 6 hour(s): 0 mm 0 in.
81200 cloud types: low: 1/8 (1/10) or less, but not 0/8 (0/10) cumulus (moderate/strong vertical extent or towering cumulus) (Cu mediocris or congestus)
mid-level: no clouds
high: no clouds

ZZYY 31374 20023 04001 528487 047361 6113/ 11119 03603 10261 20237 40139 22219 00270 10804 20080 21021 33311 66699 20007 22033 20030 02033 20055 20031 444 20130 20023 0354/ 518// 60371
BUOY Buoy observation
section 0:
ZZYY buoy
31374 buoy id: 31374 (South America) (31374, )
20023 0400 Report time: on the 20.2. xxx3, 04:00 UTC
1 wind data: m/s
528487 047361 station position: 28.487° S 47.361° W
6113/ quality of position: data is good
quality of time: data is good
position error (66 % confidence): <250 m <820 ft
111 section 1:
19 quality of this section: data is good
03603 Wind: from the north (360° (+4°/-5°)) at 10.8 km/h 5.8 kt = 6.7 mph = 3 m/s
10261 20237 Temperature: 26.1 °C 79.0 °F
Dewpoint: 23.7 °C 74.7 °F
relative humidity*: 87 %
40139 sea level pressure: 1013.9 hPa 29.94 in. Hg = 760 mmHg
222 section 2:
19 quality of this section: data is good
00270 surface temperature: 27.0 °C 80.6 °F
10804 wind waves (from instruments): period: 8 sec., height: 1.75 .. <2.25 m
20080 21021 wind waves (from instruments): period: 8.0 sec., height: 2.1 m
333 section 3:
1 quality of temp. and salinity profile measurement: data is good
1 quality of current profile measurement: data is good
666 correction of measurement: (Doppler method not used)
99 measurement of the current: (Vector or Doppler method not used)
20007 22033 at a depth of 7 m
current: from the south-west (220° (+4°/-5°)) at 33 cm/sec.
20030 02033 at a depth of 30 m
current: from the north-north-east (20° (+4°/-5°)) at 33 cm/sec.
20055 20031 at a depth of 55 m
current: from the south-south-west (200° (+4°/-5°)) at 31 cm/sec.
444 section 4:
20130 quality of satellite transmission: good
quality of location: values at the beginning of the report are the latest known values
position error (66 % confidence): <250 m <820 ft
correction for values for the depth: depth are not corrected
20023 0354/ time of last known position: on the 20.2. xxx3, 03:54 UTC
518 type of buoy: 3-meter discus
// type of drogue: (not available)
60371 anemometer: propeller rotor, height: 37 dm

ZZYY 41739 20023 0600/ 723541 065700 6113/ 11119 40204 57016 444 20130 20023 0600/ 50101 80142 80015 9/015
BUOY Buoy observation
section 0:
ZZYY buoy
41739 buoy id: 41739 (North and Central Amerika) (41739, )
20023 0600 Report time: on the 20.2. xxx3, 06:00 UTC
/ wind data: (not available)
723541 065700 station position: 23.541° N 65.700° W
6113/ quality of position: data is good
quality of time: data is good
position error (66 % confidence): <250 m <820 ft
111 section 1:
19 quality of this section: data is good
40204 sea level pressure: 1020.4 hPa 30.13 in. Hg = 765 mmHg
57016 pressure change (station level) since 3 hour(s): -1.6 hPa, having decreased steadily or unsteadily
444 section 4:
20130 quality of satellite transmission: good
quality of location: values at the beginning of the report are the latest known values
position error (66 % confidence): <250 m <820 ft
correction for values for the depth: depth are not corrected
20023 0600/ time of last known position: on the 20.2. xxx3, 06:00 UTC
501 type of buoy: Standard Lagrangian drifting buoy
01 type of drogue: holey sock
80142 80015 engineering status of buoy: 80142 80015
9/015 length of drogue cable: 15 m

ZZYY 52616 20023 0605/ 131717 138252 6112/ 22219 00190 444 20120 20023 0603/ 50101 80102 80028 9/015
BUOY Buoy observation
section 0:
ZZYY buoy
52616 buoy id: 52616 (South-West Pacific) (52616, )
20023 0605 Report time: on the 20.2. xxx3, 06:05 UTC
/ wind data: (not available)
131717 138252 station position: 31.717° N 138.252° E
6112/ quality of position: data is good
quality of time: data is good
position error (66 % confidence) from: >=250 m >=820 ft
to: <500 m <1640 ft
222 section 2:
19 quality of this section: data is good
00190 surface temperature: 19.0 °C 66.2 °F
444 section 4:
20120 quality of satellite transmission: good
quality of location: values at the beginning of the report are the latest known values
position error (66 % confidence) from: >=250 m >=820 ft
to: <500 m <1640 ft
correction for values for the depth: depth are not corrected
20023 0603/ time of last known position: on the 20.2. xxx3, 06:03 UTC
501 type of buoy: Standard Lagrangian drifting buoy
01 type of drogue: holey sock
80102 80028 engineering status of buoy: 80102 80028
9/015 length of drogue cable: 15 m

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