metaf2xml Logo

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

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 (2012-04-18) is 1.48 (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 (31743, 41595, 53524):

SBGL 180600Z 00000KT 9999 FEW008 22/20 Q1018
KJFK 180551Z 36016KT 10SM BKN250 16/M01 A3016
KJFK 180831Z 1809/1912 01012KT P6SM BKN120 FM181600 VRB05KT P6SM BKN150 FM181900
 18011KT P6SM BKN150 FM182300 18008KT P6SM BKN100 FM190200 16005KT P6SM BKN100
RJTT 180630Z 09010KT 9999 FEW025 18/11 Q1016 NOSIG RMK 2CU025 A3002
RJTT 180840Z 1809/1912 10010KT 9999 FEW015 SCT030 BECMG 1811/1813 04013KT BECMG 1900/1903 08008KT
AAXX 18064 74486 NIL
AAXX 18064 47662 12/70 30606 10195 20066 30127 40170 56008 60001 83200
ZZYY 41595 18042 0540/ 729282 042978 6112/ 11119 30227 40227 52247 22219 00214 444
 20120 18042 0449/ 50101 80100 80017 9/015
ZZYY 53524 18042 0559/ 126760 145932 6112/ 22219 00197 444 20120 18042 0546/ 50101 80028 80014 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 clouds temp (°C) hum pressure (hPa) N/R
METAR SBGL 18., 06:00 calm >=10 km FEW008 22 88% QNH1018
METAR KJFK 18., 05:51 N 16 16.1 km BKN250 16 31% QNH1021
METAR RJTT 18., 06:30 E 10 >=10 km FEW025 18 64% QNH1016 QNH1017

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 18., 06:00 74486 ?
SYNOP AAXX 18., 06:00 47662 20 km 3/8 ENE 6 19.5 43% SP1012.7 (-0.8/3h) SLP1017.0 0 mm/6h - 3/8 CU con 0/8 0/8

type time (UTC) buoy wind (kt) temp (°C) hum pressure (hPa) N/P
BUOY ZZYY 18.04. xxx2, 05:40 41595 SP1022.7 (+24.7/3h) SLP1022.7 18042 0449/ 50101 80100 80017 9/015
BUOY ZZYY 18.04. xxx2, 05:59 53524 18042 0546/ 50101 80028 80014 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 180600Z 00000KT 9999 FEW008 22/20 Q1018
METAR METAR Report
SBGL station id: SBGL (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
180600Z Report time: on the 18., 06:00 UTC
00000KT Wind: calm
9999 Visibility: >=10 km >=6.2 miles
FEW008 Sky condition: few clouds at 800 ( .. <900) ft 240 m
22/20 Temperature: 22 °C 71.6 °F
Dewpoint: 20 °C 68.0 °F
relative humidity*: 88%
Q1018 altimeter: 1018 hPa 30.06 in. Hg = 764 mmHg

KJFK 180551Z 36016KT 10SM BKN250 16/M01 A3016
METAR METAR Report
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
180551Z Report time: on the 18., 05:51 UTC
36016KT Wind: from the N (360° (+4°/-5°)) at 29.6 km/h 16 kt = 18.4 mph = 8.2 m/s
10SM Visibility: 10 ( .. <11) miles 16.1 km
BKN250 Sky condition: broken clouds at 25000 (>24500 .. 25500) ft 7620 m
16/M01 Temperature: 16 °C 60.8 °F
Dewpoint: -1 °C 30.2 °F
relative humidity*: 31%
A3016 altimeter: 30.16 in. Hg 1021 hPa = 766 mmHg

KJFK 180831Z 1809/1912 01012KT P6SM BKN120 FM181600 VRB05KT P6SM BKN150 FM181900 18011KT P6SM BKN150 FM182300 18008KT P6SM BKN100 FM190200 16005KT P6SM BKN100
TAF 27h aerodrome forecast
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
180831Z Issue time: on the 18., 08:31 UTC
1809/1912 Forecast period: from the 18., 09:00 UTC till the 19., 12:00 UTC
01012KT Wind: from the N (10° (+4°/-5°)) at 22.2 km/h 12 kt = 13.8 mph = 6.2 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN120 ceiling*: at 12000 ft 3660 m
Sky condition: broken clouds at 12000 ft 3660 m
trend forecast:
FM181600 from the 18., 16:00 UTC:
VRB05KT Wind: from variable directions at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN150 ceiling*: at 15000 ft 4570 m
Sky condition: broken clouds at 15000 ft 4570 m
FM181900 from the 18., 19:00 UTC:
18011KT Wind: from the S (180° (+4°/-5°)) at 20.4 km/h 11 kt = 12.7 mph = 5.7 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN150 ceiling*: at 15000 ft 4570 m
Sky condition: broken clouds at 15000 ft 4570 m
FM182300 from the 18., 23:00 UTC:
18008KT Wind: from the S (180° (+4°/-5°)) at 14.8 km/h 8 kt = 9.2 mph = 4.1 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN100 ceiling*: at 10000 ft 3050 m
Sky condition: broken clouds at 10000 ft 3050 m
FM190200 from the 19., 02:00 UTC:
16005KT Wind: from the SSE (160° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN100 ceiling*: at 10000 ft 3050 m
Sky condition: broken clouds at 10000 ft 3050 m

RJTT 180630Z 09010KT 9999 FEW025 18/11 Q1016 NOSIG RMK 2CU025 A3002
METAR METAR Report
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
180630Z Report time: on the 18., 06:30 UTC
09010KT Wind: from the E (90° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW025 Sky condition: few clouds at 2500 ( .. <2600) ft 760 m
18/11 Temperature: 18 °C 64.4 °F
Dewpoint: 11 °C 51.8 °F
relative humidity*: 64%
Q1016 altimeter: 1016 hPa 30.00 in. Hg = 762 mmHg
trends within the next 2 hours:
NOSIG no significant change
RMK Remarks:
2CU025 phenomenon w. opacity: 2/8 cumulus at 2500 ft 760 m
A3002 altimeter: 30.02 in. Hg 1017 hPa = 763 mmHg

RJTT 180840Z 1809/1912 10010KT 9999 FEW015 SCT030 BECMG 1811/1813 04013KT BECMG 1900/1903 08008KT
TAF 27h aerodrome forecast
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
180840Z Issue time: on the 18., 08:40 UTC
1809/1912 Forecast period: from the 18., 09:00 UTC till the 19., 12:00 UTC
10010KT Wind: from the E (100° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
9999 Visibility: >=10 km >=6.2 miles
FEW015 SCT030 Sky condition: few clouds at 1500 ft 460 m
scattered clouds at 3000 ft 910 m
trend forecast:
BECMG 1811/1813 from the 18., 11:00 UTC till the 18., 13:00 UTC transition to:
04013KT Wind: from the NE (40° (+4°/-5°)) at 24.1 km/h 13 kt = 15 mph = 6.7 m/s
BECMG 1900/1903 from the 19., 00:00 UTC till the 19., 03:00 UTC transition to:
08008KT Wind: from the E (80° (+4°/-5°)) at 14.8 km/h 8 kt = 9.2 mph = 4.1 m/s

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

AAXX 18064 47662 12/70 30606 10195 20066 30127 40170 56008 60001 83200
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
1806 Report time: on the 18., 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)
70 Visibility: 20 ( .. <21) km 12.4 miles
3 total cloud cover: 3/8 (4/10)
0606 Wind: from the ENE (60° (+4°/-5°)) at 11.1 km/h 6 kt = 6.9 mph = 3.1 m/s
10195 20066 Temperature: 19.5 °C 67.1 °F
Dewpoint: 6.6 °C 43.9 °F
relative humidity*: 43%
30127 station level pressure: 1012.7 hPa 29.91 in. Hg = 760 mmHg
40170 sea level pressure: 1017.0 hPa 30.03 in. Hg = 763 mmHg
56008 pressure change (station level) since 3 hour(s): -0.8 hPa, having decreased, then steady; or decreased then decreased more slowly
60001 precip. amount since 6 hour(s): 0 mm 0 in.
83200 cloud types: low: 3/8 (4/10) cumulus (moderate/strong vertical extent or towering cumulus) (Cu mediocris or congestus)
mid-level: no clouds
high: no clouds

ZZYY 41595 18042 0540/ 729282 042978 6112/ 11119 30227 40227 52247 22219 00214 444 20120 18042 0449/ 50101 80100 80017 9/015
warning: not processed: 18042 0449/ 50101 80100 80017 9/015
BUOY Buoy observation
section 0:
ZZYY buoy
41595 buoy id: 41595 (North and Central Amerika) (41595, )
18042 0540 Report time: on the 18.4. xxx2, 05:40 UTC
/ wind data: (not available)
729282 042978 station position: 29.282° N 42.978° W
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
111 section 1:
19 quality of this section: data is good
30227 station level pressure: 1022.7 hPa 30.20 in. Hg = 767 mmHg
40227 sea level pressure: 1022.7 hPa 30.20 in. Hg = 767 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
00214 surface temperature: 21.4 °C 70.5 °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

ZZYY 53524 18042 0559/ 126760 145932 6112/ 22219 00197 444 20120 18042 0546/ 50101 80028 80014 9/015
warning: not processed: 18042 0546/ 50101 80028 80014 9/015
BUOY Buoy observation
section 0:
ZZYY buoy
53524 buoy id: 53524 (South-West Pacific) (53524, )
18042 0559 Report time: on the 18.4. xxx2, 05:59 UTC
/ wind data: (not available)
126760 145932 station position: 26.760° N 145.932° 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
00197 surface temperature: 19.7 °C 67.5 °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

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