metaf2xml: parse and decode METAR, TAF, and SYNOP and store as XML

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

metaf2xml parses and decodes aviation routine weather reports (METAR, SPECI), aerodrome forecasts (TAF), and synoptic observations (SYNOP) and stores the components as XML (all done in Perl). There are also XSLT style sheets to convert the XML to plain language (text, HTML), or XML with different schemas, and a command line and a web-based (CGI) user interface.

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 (2009-05-09) is 1.36 (TAR, 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 3,500 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):

SBGL 091200Z 05004KT 4500 HZ FEW010 SCT090 23/18 Q1018
KJFK 091251Z 14005KT 0SM BR OVC002 14/13 A2971
KJFK 091155Z 0912/1018 12005KT 1/4SM FG VV001 TEMPO 0912/0913 6SM BR BKN003 FM091400 19010KT P6SM SCT040
 BKN120 FM092100 21015KT P6SM BKN035CB BKN100 FM100200 26017G24KT P6SM SCT045 FM100600 29020G33KT P6SM SCT045
RJTT 091300Z 21013KT CAVOK 21/14 Q1012 RMK A2989
AAXX 09184 83746 31560 11608 10271 20177 40141 56015 70511 81100
AAXX 09184 74486 32764 81603 10206 20156 30029 40040 58014 91751 333 10206 20139 555 90918
AAXX 09184 47662 12970 72003 10180 20139 30064 40107 56009 60001 80002

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 is highly dependent 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 DTD).
The intention is to gain as much information as possible from a message without interpreting parts of it wrongly.

storing message contents as XML
The module XML.pm (man page) generates the XML data. This data only contains 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. Each XML top node for a message component has the attribute "s" containing the corresponding part from the original message.
The intention is that no parsing of items in the XML file should be necessary, so every information item gets a separate XML node.

source of messages
Messages can be specified simply as text. The CGI script "metaf.pl" can also fetch them from a public server (currently nearly all NOAA) or read from a local file. For that, the parameters "type_metaf" and "type_synop" must be "ICAO" and "WMO", respectively, and the entry fields need to contain the airport or station code(s).

display of XML file
The project includes 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 METAR and SYNOP, only) are shown in an abbreviated format, one line per message.

command line interface
The script metaf2xml.pl (man page) reads messages from standard input, processes them, and writes the XML data to standard output. This can then be fed to "xsltproc" or similar programs to get HTML or text. The script metaf.pl (man page), though intended as a CGI script, can be used to fetch 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 there are some that could not process some of the XSL directives in them. Also, not all browsers are XML capable. The CGI script metaf.pl (man page) provides an interface in pure HTML. The XML data can be seen by viewing the source of the web page if "XML" was selected as output format.

sources are 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.

Resources, demo version

The project's home page is at SourceForge.net, releases are also announced at freshmeat.net. The latest version includes the parser, the DTD schema, XSLT style sheets to convert the XML to plain language, the Perl scripts for the user interfaces, and everything to install all of them.

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 and are updated only from time to time. sourceforge.net does not allow outgoing connections, so they cannot be fetched directly from the internet.

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

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 server, as for the graphical demo version.

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

Examples for messages in plain language

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

msg: SBGL 091200Z 05004KT 4500 HZ FEW010 SCT090 23/18 Q1018
METAR METAR Report
SBGL station id: SBGL (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
091200Z Report time: on the 9., 12:00 UTC
05004KT Wind: from the NE (50° (+4°/-5°)) at 7.4 km/h 4 kt = 4.6 mph = 2.1 m/s
4500 Visibility: 4500 (.. <4600) m 2.8 miles
HZ Weather: haze
FEW010 SCT090 Sky condition: few clouds at 1000 ft 300 m
scattered clouds at 9000 ft 2740 m
23/18 Temperature: 23 °C 73.4 °F
Dewpoint: 18 °C 64.4 °F
relative humidity: 74%
Q1018 altimeter: 1018 hPa 30.06 in. Hg

msg: KJFK 091251Z 14005KT 0SM BR OVC002 14/13 A2971
METAR METAR Report
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
091251Z Report time: on the 9., 12:51 UTC
14005KT Wind: from the SE (140° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
0SM Visibility: 0 (.. <0.0625) miles 0 m
BR Weather: mist
OVC002 ceiling: at 200 ft 60 m
Sky condition: sky overcast at 200 ft 60 m
14/13 Temperature: 14 °C 57.2 °F
Dewpoint: 13 °C 55.4 °F
relative humidity: 94%
A2971 altimeter: 1006 hPa 29.71 in. Hg

msg: KJFK 091155Z 0912/1018 12005KT 1/4SM FG VV001 TEMPO 0912/0913 6SM BR BKN003 FM091400 19010KT P6SM SCT040 BKN120 FM092100 21015KT P6SM BKN035CB BKN100 FM100200 26017G24KT P6SM SCT045 FM100600 29020G33KT P6SM SCT045
TAF 30h aerodrome forecast
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
091155Z Issue time: on the 9., 11:55 UTC
0912/1018 Forecast period: 9., 12:00 - 10., 18:00 UTC
12005KT Wind: from the ESE (120° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
1/4SM Visibility: 0.25 (.. <0.3125) miles 400 m
FG Weather: fog
VV001 Vert. visibility: 100 ft 30 m
trend forecast:
TEMPO 0912/0913 from 9., 12:00 UTC till 9., 13:00 UTC temporarily:
6SM Visibility: 6 (.. <7) miles 9.7 km
BR Weather: mist
BKN003 ceiling: at 300 ft 90 m
Sky condition: broken clouds at 300 ft 90 m
FM091400 from 9., 14:00 UTC becoming:
19010KT Wind: from the S (190° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT040 BKN120 ceiling: at 12000 ft 3660 m
Sky condition: scattered clouds at 4000 ft 1220 m
broken clouds at 12000 ft 3660 m
FM092100 from 9., 21:00 UTC becoming:
21015KT Wind: from the SSW (210° (+4°/-5°)) at 27.8 km/h 15 kt = 17.3 mph = 7.7 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN035CB BKN100 ceiling: at 3500 ft 1070 m
Sky condition: broken clouds at 3500 ft
(cumulonimbus)
1070 m
broken clouds at 10000 ft 3050 m
FM100200 from 10., 02:00 UTC becoming:
26017G24KT Wind: from the W (260° (+4°/-5°)) at 31.5 km/h 17 kt = 19.6 mph = 8.7 m/s
with gusts at 44.4 km/h 24 kt = 27.6 mph = 12.3 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT045 Sky condition: scattered clouds at 4500 ft 1370 m
FM100600 from 10., 06:00 UTC becoming:
29020G33KT Wind: from the WNW (290° (+4°/-5°)) at 37 km/h 20 kt = 23 mph = 10.3 m/s
with gusts at 61.1 km/h 33 kt = 38 mph = 17 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT045 Sky condition: scattered clouds at 4500 ft 1370 m

msg: RJTT 091300Z 21013KT CAVOK 21/14 Q1012 RMK A2989
METAR METAR Report
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
091300Z Report time: on the 9., 13:00 UTC
21013KT Wind: from the SSW (210° (+4°/-5°)) at 24.1 km/h 13 kt = 15 mph = 6.7 m/s
CAVOK cloud and visibility OK
21/14 Temperature: 21 °C 69.8 °F
Dewpoint: 14 °C 57.2 °F
relative humidity: 64%
Q1012 altimeter: 1012 hPa 29.88 in. Hg
RMK Remarks:
A2989 altimeter: 1012 hPa 29.89 in. Hg

msg: AAXX 09184 83746 31560 11608 10271 20177 40141 56015 70511 81100
warning: station pressure missing
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0918 Report time: on the 9., 18:00 UTC
4 wind data: kt
83746 station id: 83746 (South America) (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
section 1:
3 precipitation data: omitted (no precipitation)
1 weather data: in section 1
5 base of lowest cloud: 600 m 1970 ft
to: 1000 m 3280 ft
60 Visibility: 10 (.. <11) km 6.2 miles
1 total cloud cover: 1/8 or less, but not 0/8
1608 Wind: from the SSE (160° (+4°/-5°)) at 14.8 km/h 8 kt = 9.2 mph = 4.1 m/s
10271 20177 Temperature: 27.1 °C 80.8 °F
Dewpoint: 17.7 °C 63.9 °F
relative humidity: 57%
40141 sea level pressure: 1014.1 hPa 29.95 in. Hg
56015 pressure change last 3h: -1.5 hPa, having decreased, then steady, or decreased then decreased more slowly
70511 Weather: haze
weather last 6h: cloud covering at times more than, at other times less than half of the sky
81100 cloud types: low: 1/8 or less, but not 0/8 cumulus (little vertical extent) (Cu humulis or fractus)
mid-level: no clouds
high: no clouds

msg: AAXX 09184 74486 32764 81603 10206 20156 30029 40040 58014 91751 333 10206 20139 555 90918
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0918 Report time: on the 9., 18:00 UTC
4 wind data: kt
74486 station id: 74486 (North and Central Amerika) (Kennedy International Airport, New York, New York, USA)
section 1:
3 precipitation data: omitted (no precipitation)
2 weather data: omitted (no significant phenomenon)
7 base of lowest cloud: 1520 m 5000 ft
to: 1980 m 6500 ft
64 Visibility: 9 (.. <10) miles 14.5 km
8 total cloud cover: 8/8
1603 Wind: from the SSE (160° (+4°/-5°)) at 5.6 km/h 3 kt = 3.5 mph = 1.5 m/s
10206 20156 Temperature: 20.6 °C 69.1 °F
Dewpoint: 15.6 °C 60.1 °F
relative humidity: 73%
30029 station level pressure: 1002.9 hPa 29.62 in. Hg
40040 sea level pressure: 1004.0 hPa 29.65 in. Hg
58014 pressure change last 3h: -1.4 hPa, steady or having increased, then decreased; or decreased then decreased more rapidly
91751 exact obs. time: 17:51 UTC
333 section 3:
10206 max. temperature last 12h: 20.6 °C 69.1 °F
20139 min. temperature last 24h: 13.9 °C 57.0 °F
555 section 5:
90918 Report time: on the 9., 18:00 UTC

msg: AAXX 09184 47662 12970 72003 10180 20139 30064 40107 56009 60001 80002
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0918 Report time: on the 9., 18: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)
9 base of lowest cloud: >=2500 m >=8200 ft
70 Visibility: 20 (.. <21) km 12.4 miles
7 total cloud cover: 7/8 or more, but not 8/8
2003 Wind: from the SSW (200° (+4°/-5°)) at 5.6 km/h 3 kt = 3.5 mph = 1.5 m/s
10180 20139 Temperature: 18.0 °C 64.4 °F
Dewpoint: 13.9 °C 57.0 °F
relative humidity: 77%
30064 station level pressure: 1006.4 hPa 29.72 in. Hg
40107 sea level pressure: 1010.7 hPa 29.85 in. Hg
56009 pressure change last 3h: -0.9 hPa, having decreased, then steady, or decreased then decreased more slowly
60001 precip. amount last 6h: 0 mm 0 in.
80002 cloud types: low: no clouds
mid-level: no clouds
high: cirrus (dense, with sproutings, or in tufts) (Ci spissatus, castellanus, or flocus)

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