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-08-09) is 1.37 (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 090700Z 00000KT CAVOK 18/15 Q1016
SBGL 090330Z 0906/1006 07005KT 8000 NSC TN20/0908Z TX31/0917Z PROB30 0908/0912 5000 BR BECMG 0911/0913
 02005KT BECMG 0915/0917 17010KT CAVOK BECMG 0921/0923 07005KT BECMG 1001/1003 02005KT 8000 NSC
KJFK 090751Z 17006KT 10SM SCT028 BKN080 OVC120 22/16 A3016 RMK AO2 SLP213 T02220161
KJFK 302055Z 3021/3124 21012KT P6SM FEW050 SCT250 FM310200 21007KT P6SM SCT070 BKN250 FM310900 19005KT
 P6SM BKN070 OVC150 FM311200 18010KT 5SM -SHRA BR OVC040 FM311500 19012KT 3SM RA BR OVC015CB FM311800 19015KT 5SM -SHRA BR SCT015CB OVC025
SPECI RJTT 090730Z 12008KT 080V160 9999 VCSH FEW025 FEW030CB BKN035 BKN/// 30/25 Q1010
RJTT 090700Z 15009KT 9999 VCSH FEW025 FEW030CB SCT050 BKN/// 31/24 Q1010 RMK 1CU025 1CB030 4SC050 A2983
 CB 30KM E AND 15KM NW MOV NE
RJTT 310026Z 3100/3124 03010KT 9000 FEW010 SCT020 BKN030 TEMPO 3100/3103 4000 -RA BR FEW004 BKN007 BECMG
 3104/3106 07010KT BECMG 3109/3112 04012KT TEMPO 3118/3121 FEW005 BKN009
AAXX 09064 83746 31962 01201 10186 20159 40169 57012 71000
AAXX 09064 74486 12766 81706 10222 20156 30212 40222 58002 69901 90551 333 10222 20172 555 90906
AAXX 09064 47662 12/65 81603 10308 20242 30059 40100 58005 60001 8327/

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 090700Z 00000KT CAVOK 18/15 Q1016
METAR METAR Report
SBGL station id: SBGL (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
090700Z Report time: on the 9., 07:00 UTC
00000KT Wind: calm
CAVOK cloud and visibility OK
18/15 Temperature: 18 °C 64.4 °F
Dewpoint: 15 °C 59.0 °F
relative humidity: 83%
Q1016 altimeter: 1016 hPa 30.00 in. Hg

msg: SBGL 090330Z 0906/1006 07005KT 8000 NSC TN20/0908Z TX31/0917Z PROB30 0908/0912 5000 BR BECMG 0911/0913 02005KT BECMG 0915/0917 17010KT CAVOK BECMG 0921/0923 07005KT BECMG 1001/1003 02005KT 8000 NSC
TAF 24h aerodrome forecast
SBGL station id: SBGL (Aeroporto Internacional do Rio de Janeiro/Galeão, Brazil)
090330Z Issue time: on the 9., 03:30 UTC
0906/1006 Forecast period: from the 9., 06:00 UTC till the 10., 06:00 UTC
07005KT Wind: from the ENE (70° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
8000 Visibility: 8000 (.. <9000) m 5 miles
NSC Sky condition: nil significant clouds
trend forecast:
PROB30 0908/0912 with 30% probability from the 9., 08:00 UTC till the 9., 12:00 UTC:
5000 Visibility: 5000 (.. <6000) m 3.1 miles
BR Weather: mist
BECMG 0911/0913 from the 9., 11:00 UTC till the 9., 13:00 UTC becoming:
02005KT Wind: from the NNE (20° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
BECMG 0915/0917 from the 9., 15:00 UTC till the 9., 17:00 UTC becoming:
17010KT Wind: from the S (170° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
CAVOK cloud and visibility OK
BECMG 0921/0923 from the 9., 21:00 UTC till the 9., 23:00 UTC becoming:
07005KT Wind: from the ENE (70° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
BECMG 1001/1003 from the 10., 01:00 UTC till the 10., 03:00 UTC becoming:
02005KT Wind: from the NNE (20° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
8000 Visibility: 8000 (.. <9000) m 5 miles
NSC Sky condition: nil significant clouds

TN20/0908Z min. temperature: 20 °C on the 9., 08:00 UTC 68.0 °F
TX31/0917Z max. temperature: 31 °C on the 9., 17:00 UTC 87.8 °F

msg: KJFK 090751Z 17006KT 10SM SCT028 BKN080 OVC120 22/16 A3016 RMK AO2 SLP213 T02220161
METAR METAR Report
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
090751Z Report time: on the 9., 07:51 UTC
17006KT Wind: from the S (170° (+4°/-5°)) at 11.1 km/h 6 kt = 6.9 mph = 3.1 m/s
10SM Visibility: 10 (.. <11) miles 16.1 km
SCT028 BKN080 OVC120 ceiling: at 8000 ft 2440 m
Sky condition: scattered clouds at 2800 ft 850 m
broken clouds at 8000 ft 2440 m
sky overcast at 12000 ft 3660 m
22/16 Temperature: 22 °C 71.6 °F
Dewpoint: 16 °C 60.8 °F
relative humidity: 69%
A3016 altimeter: 1021 hPa 30.16 in. Hg
RMK Remarks:
AO2 automated station with precipitation discriminator (ASOS)
SLP213 sea level pressure: 1021.3 hPa 30.16 in. Hg
T02220161 1h avg. temperature: 22.2 °C 72.0 °F
1h avg. dewpoint: 16.1 °C 61.0 °F

msg: KJFK 302055Z 3021/3124 21012KT P6SM FEW050 SCT250 FM310200 21007KT P6SM SCT070 BKN250 FM310900 19005KT P6SM BKN070 OVC150 FM311200 18010KT 5SM -SHRA BR OVC040 FM311500 19012KT 3SM RA BR OVC015CB FM311800 19015KT 5SM -SHRA BR SCT015CB OVC025
TAF 27h aerodrome forecast
KJFK station id: KJFK (Kennedy International Airport, New York, New York, USA)
302055Z Issue time: on the 30., 20:55 UTC
3021/3124 Forecast period: from the 30., 21:00 UTC till the 31., 24:00 UTC
21012KT Wind: from the SSW (210° (+4°/-5°)) at 22.2 km/h 12 kt = 13.8 mph = 6.2 m/s
P6SM Visibility: >=6 miles >=9.7 km
FEW050 SCT250 Sky condition: few clouds at 5000 ft 1520 m
scattered clouds at 25000 ft 7620 m
trend forecast:
FM310200 from the 31., 02:00 UTC becoming:
21007KT Wind: from the SSW (210° (+4°/-5°)) at 13 km/h 7 kt = 8.1 mph = 3.6 m/s
P6SM Visibility: >=6 miles >=9.7 km
SCT070 BKN250 Sky condition: scattered clouds at 7000 ft 2130 m
broken clouds at 25000 ft 7620 m
FM310900 from the 31., 09:00 UTC becoming:
19005KT Wind: from the S (190° (+4°/-5°)) at 9.3 km/h 5 kt = 5.8 mph = 2.6 m/s
P6SM Visibility: >=6 miles >=9.7 km
BKN070 OVC150 ceiling: at 7000 ft 2130 m
Sky condition: broken clouds at 7000 ft 2130 m
sky overcast at 15000 ft 4570 m
FM311200 from the 31., 12:00 UTC becoming:
18010KT Wind: from the S (180° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
5SM Visibility: 5 (.. <6) miles 8 km
-SHRA BR Weather: light rain showers
mist
OVC040 ceiling: at 4000 ft 1220 m
Sky condition: sky overcast at 4000 ft 1220 m
FM311500 from the 31., 15:00 UTC becoming:
19012KT Wind: from the S (190° (+4°/-5°)) at 22.2 km/h 12 kt = 13.8 mph = 6.2 m/s
3SM Visibility: 3 (.. <4) miles 4.8 km
RA BR Weather: moderate rain
mist
OVC015CB ceiling: at 1500 ft 460 m
Sky condition: sky overcast at 1500 ft
(cumulonimbus)
460 m
FM311800 from the 31., 18:00 UTC becoming:
19015KT Wind: from the S (190° (+4°/-5°)) at 27.8 km/h 15 kt = 17.3 mph = 7.7 m/s
5SM Visibility: 5 (.. <6) miles 8 km
-SHRA BR Weather: light rain showers
mist
SCT015CB OVC025 ceiling: at 2500 ft 760 m
Sky condition: scattered clouds at 1500 ft
(cumulonimbus)
460 m
sky overcast at 2500 ft 760 m

msg: SPECI RJTT 090730Z 12008KT 080V160 9999 VCSH FEW025 FEW030CB BKN035 BKN/// 30/25 Q1010
SPECI SPECI Report
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
090730Z Report time: on the 9., 07:30 UTC
12008KT 080V160 Wind: from the ESE (120° (+4°/-5°)) at 14.8 km/h 8 kt = 9.2 mph = 4.1 m/s
variable from E to SSE (80°--160°)
9999 Visibility: >=10 km >=6.2 miles
VCSH Weather: showers in the vicinity
FEW025 FEW030CB BKN035 BKN/// ceiling: at 3500 ft 1070 m
Sky condition: few clouds at 2500 ft 760 m
few clouds at 3000 ft
(cumulonimbus)
910 m
broken clouds at 3500 ft 1070 m
broken clouds, cloud base below station level
30/25 Temperature: 30 °C 86.0 °F
Dewpoint: 25 °C 77.0 °F
relative humidity: 75%
Q1010 altimeter: 1010 hPa 29.83 in. Hg

msg: RJTT 090700Z 15009KT 9999 VCSH FEW025 FEW030CB SCT050 BKN/// 31/24 Q1010 RMK 1CU025 1CB030 4SC050 A2983 CB 30KM E AND 15KM NW MOV NE
METAR METAR Report
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
090700Z Report time: on the 9., 07:00 UTC
15009KT Wind: from the SSE (150° (+4°/-5°)) at 16.7 km/h 9 kt = 10.4 mph = 4.6 m/s
9999 Visibility: >=10 km >=6.2 miles
VCSH Weather: showers in the vicinity
FEW025 FEW030CB SCT050 BKN/// Sky condition: few clouds at 2500 ft 760 m
few clouds at 3000 ft
(cumulonimbus)
910 m
scattered clouds at 5000 ft 1520 m
broken clouds, cloud base below station level
31/24 Temperature: 31 °C 87.8 °F
Dewpoint: 24 °C 75.2 °F
relative humidity: 66%
Q1010 altimeter: 1010 hPa 29.83 in. Hg
RMK Remarks:
1CU025 phenomenon w. opacity: 1/8 cumulus at 2500 ft 760 m
1CB030 phenomenon w. opacity: 1/8 cumulonimbus at 3000 ft 910 m
4SC050 phenomenon w. opacity: 4/8 stratocumulus at 5000 ft 1520 m
A2983 altimeter: 1010 hPa 29.83 in. Hg
CB 30KM E AND 15KM NW MOV NE cumulonimbus 30 km east, 15 km north-west, moving to the north-east

msg: RJTT 310026Z 3100/3124 03010KT 9000 FEW010 SCT020 BKN030 TEMPO 3100/3103 4000 -RA BR FEW004 BKN007 BECMG 3104/3106 07010KT BECMG 3109/3112 04012KT TEMPO 3118/3121 FEW005 BKN009
TAF 24h aerodrome forecast
RJTT station id: RJTT (東京国際空港 (羽田空港) (Tōkyō Kokusai Kūkō (Haneda)), Japan)
310026Z Issue time: on the 31., 00:26 UTC
3100/3124 Forecast period: from the 31., 00:00 UTC till the 31., 24:00 UTC
03010KT Wind: from the NNE (30° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
9000 Visibility: 9000 (.. <10000) m 5.6 miles
FEW010 SCT020 BKN030 ceiling: at 3000 ft 910 m
Sky condition: few clouds at 1000 ft 300 m
scattered clouds at 2000 ft 610 m
broken clouds at 3000 ft 910 m
trend forecast:
TEMPO 3100/3103 from the 31., 00:00 UTC till the 31., 03:00 UTC temporarily:
4000 Visibility: 4000 (.. <4100) m 2.5 miles
-RA BR Weather: light rain
mist
FEW004 BKN007 ceiling: at 700 ft 210 m
Sky condition: few clouds at 400 ft 120 m
broken clouds at 700 ft 210 m
BECMG 3104/3106 from the 31., 04:00 UTC till the 31., 06:00 UTC becoming:
07010KT Wind: from the ENE (70° (+4°/-5°)) at 18.5 km/h 10 kt = 11.5 mph = 5.1 m/s
BECMG 3109/3112 from the 31., 09:00 UTC till the 31., 12:00 UTC becoming:
04012KT Wind: from the NE (40° (+4°/-5°)) at 22.2 km/h 12 kt = 13.8 mph = 6.2 m/s
TEMPO 3118/3121 from the 31., 18:00 UTC till the 31., 21:00 UTC temporarily:
FEW005 BKN009 ceiling: at 900 ft 270 m
Sky condition: few clouds at 500 ft 150 m
broken clouds at 900 ft 270 m

msg: AAXX 09064 83746 31962 01201 10186 20159 40169 57012 71000
warning: station pressure missing
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0906 Report time: on the 9., 06: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
9 base of lowest cloud: >=2500 m >=8200 ft
62 Visibility: 12 (.. <13) km 7.5 miles
0 total cloud cover: 0/8
1201 Wind: from the ESE (120° (+4°/-5°)) at 1.9 km/h 1 kt = 1.2 mph = 0.5 m/s
10186 20159 Temperature: 18.6 °C 65.5 °F
Dewpoint: 15.9 °C 60.6 °F
relative humidity: 84%
40169 sea level pressure: 1016.9 hPa 30.03 in. Hg
57012 pressure change since 3 hour(s): -1.2 hPa, having decreased steadily or unsteadily
71000 Weather: mist
weather since 6 hour(s): cloud covering half or less of the sky

msg: AAXX 09064 74486 12766 81706 10222 20156 30212 40222 58002 69901 90551 333 10222 20172 555 90906
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0906 Report time: on the 9., 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)
7 base of lowest cloud: 1520 m 5000 ft
to: 1980 m 6500 ft
66 Visibility: 10 (.. <11) miles 16.1 km
8 total cloud cover: 8/8
1706 Wind: from the S (170° (+4°/-5°)) at 11.1 km/h 6 kt = 6.9 mph = 3.1 m/s
10222 20156 Temperature: 22.2 °C 72.0 °F
Dewpoint: 15.6 °C 60.1 °F
relative humidity: 66%
30212 station level pressure: 1021.2 hPa 30.16 in. Hg
40222 sea level pressure: 1022.2 hPa 30.19 in. Hg
58002 pressure change since 3 hour(s): -0.2 hPa, steady or having increased, then decreased; or decreased then decreased more rapidly
69901 precip. amount since 6 hour(s): traces
90551 exact obs. time: at 05:51 UTC
333 section 3:
10222 max. temperature since 24 hour(s): 22.2 °C 72.0 °F
20172 min. temperature since 24 hour(s): 17.2 °C 63.0 °F
555 section 5:
90906 Report time: on the 9., 06:00 UTC

msg: AAXX 09064 47662 12/65 81603 10308 20242 30059 40100 58005 60001 8327/
SYNOP Synoptic observation (main hour)
section 0:
AAXX fixed land station
0906 Report time: on the 9., 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)
65 Visibility: 15 (.. <16) km 9.3 miles
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
10308 20242 Temperature: 30.8 °C 87.4 °F
Dewpoint: 24.2 °C 75.6 °F
relative humidity: 68%
30059 station level pressure: 1005.9 hPa 29.70 in. Hg
40100 sea level pressure: 1010.0 hPa 29.83 in. Hg
58005 pressure change since 3 hour(s): -0.5 hPa, steady or having increased, then decreased; or decreased then decreased more rapidly
60001 precip. amount since 6 hour(s): 0 mm 0 in.
8327/ cloud types: low: 3/8 cumulus (moderate/strong vertical extent or towering cumulus) (Cu mediocris or congestus)
mid-level: altocumulus (mainly opaque, not expanding; or with altostratus) (Ac transludicus or opacus, Ac and As or Ns)
high: (not available)

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