metaf2xml: manual for metaf2xml::parser 2.9

NAME

metaf2xml::parser - parse a METAR/TAF/SYNOP/BUOY/AMDAR message

SYNOPSIS

 use metaf2xml::parser 2.009;

 # pass the data to a callback function:
 metaf2xml::parser::start_cb(\&cb);                        # mandatory
 metaf2xml::parser::parse_report($msg,$default_msg_type);  # repeat as necessary
 metaf2xml::parser::process_bufr(\@data,\@desc);           # repeat as necessary
 metaf2xml::parser::finish();                              # optional

 # write the data as XML:
 metaf2xml::parser::start_xml(\%opts);                     # mandatory
 metaf2xml::parser::parse_report($msg,$default_msg_type);  # repeat as necessary
 metaf2xml::parser::process_bufr(\@data,\@desc);           # repeat as necessary
 metaf2xml::parser::finish();                              # mandatory

DESCRIPTION

This Perl module provides a function to analyse a string (per default as a METAR message), a function to process a decoded BUFR message, and functions to control the output.

Parsing of AMDAR messages

From WMO-No. 306 Vol I.1, Part A: AMDAR is the name of the code for an automatic meteorological report from an aircraft. Observations are made at specified levels, time intervals or when the highest wind is encountered, and shall be included in individual reports. Data transmitted from the aircraft are encoded in binary code and are translated into the quasi-AIREP format for the convenience of human users.

AMDAR Section 1

 {AMDAR|ARP} YYGG
YYGG (not processed)

day of the month (UTC), and actual time, rounded downwards to the nearest hour UTC, of the first AMDAR report in the bulletin

AMDAR Section 2

 ipipip IA...IA LaLaLaLaA LoLoLoLoLoB YYGGgg (ShhIhIhI) SSTATATA ({SSTdTdTd|UUU}) ddd/fff (TBBA) (Ss1s2s3)
ipipip

phase of flight indicator

IA...IA

aircraft identifier

LaLaLaLaA LoLoLoLoLoB

geographical location

YYGGgg

day, hour, minute of measurement

optional: ShhIhIhI

pressure altitude, in hundreds of feet, relative to the standard datum plane of 1013.2 hPa

SSTATATA

air temperature, in tenths of degrees Celsius

optional: SSTdTdTd | UUU

dew point temperature, in tenths of degrees Celsius, or relative humidity

ddd/fff

true direction, in whole degrees, from which wind is blowing, and wind speed, in knots

optional: TBBA

turbulence

optional: Ss1s2s3

type of navigation system, type of system used, and temperature precision

AMDAR Section 3 (optional)

 333 Fhdhdhd VGfgfgfg
Fhdhdhd

flight level (based on ICAO standard atmosphere for reports above 700 hPa, on airport QNH otherwise)

VGfgfgfg

maximum derived equivalent vertical gust, in tenths of a metre per second

Parsing of BUOY messages

BUOY Section 0: information about the identification, time and position data

 MiMiMjMj A1bwnbnbnb YYMMJ GGggiw QcLaLaLaLaLa LoLoLoLoLoLo (6QlQtQA/)
MiMiMjMj

station type

A1bwnbnbnb

station id

YYMMJ GGggiw

day, month, units digit of year, hour, minute of observation, indicator for wind speed (unit)

QcLaLaLaLaLa LoLoLoLoLo

position of the buoy

6QlQtQA/

quality control indicators for position and time

BUOY Section 1: meteorological and other non-marine data (optional)

 111QdQx 0ddff 1snTTT {2snTdTdTd|29UUU} 3P0P0P0P0 4PPPP 5appp
111QdQx

quality control indicators for section 1

0ddff

wind direction and speed

1snTTT

temperature

2snTdTdTd | 29UUU

dew point or relative humidity

3P0P0P0P0

station level pressure

4PPPP

sea level pressure

5appp

three-hourly pressure tendency (for station level pressure if provided)

BUOY Section 2: surface marine data (optional)

 222QdQx 0snTwTwTw 1PwaPwaHwaHwa 20PwaPwaPwa 21HwaHwaHwa
222QdQx

quality control indicators for section 2

0snTwTwTw

sea-surface temperature

1PwaPwaHwaHwa

period and height of waves (instrumental data)

20PwaPwaPwa 21HwaHwaHwa

period and height of waves (instrumental data) with tenths

BUOY Section 3: temperatures, salinity and current at selected depths (optional)

 333Qd1Qd2 (8887k2  2z0z0z0z0 3T0T0T0T0 4S0S0S0S0
                    ...
                    2znznznzn 3TnTnTnTn 4SnSnSnSn)
           (66k69k3 2z0z0z0z0 d0d0c0c0c0
                    ...
                    2znznznzn dndncncncn)
333Qd1Qd2

quality of the temperature and salinity profile, quality of the current speed and direction profile

8887k2 2z0z0z0z0 3T0T0T0T0 4S0S0S0S0 ...

method of salinity measurement, selected depth, temperature, salinity

66k69k3 2z0z0z0z0 c0c0d0d0d0 ...

method of removing the velocity and motion of the buoy from current measurement, duration and time of current measurement, selected depth, direction and speed of the current

BUOY Section 4: information on engineering and technical parameters (optional)

 444 1QPQ2QTWQ4 2QNQLQAQz {QcLaLaLaLaLa LoLoLoLoLoLo|YYMMJ GGgg/} (3ZhZhZhZh 4ZcZcZcZc) 5BtBtXtXt 6AhAhAhAN 7VBVBdBdB 8ViViViVi 9/ZdZdZd
1QPQ2QTWQ4

quality of: pressure measurement, housekeeping parameter, measurement of water-surface temperature, measurement of air temperature

2QNQLQAQz

quality of buoy satellite transmission, quality of location, location quality class, indicator of depth correction

QcLaLaLaLaLa LoLoLoLoLo

if QL=2: second possible solution for the position of the buoy

YYMMJ GGgg/

if QL=1: day, month, units digit of year, hour, minute of the time of the last known position

3ZhZhZhZh 4ZcZcZcZc

hydrostatic pressure of lower end of cable, length of cable in metres (thermistor strings)

5BtBtXtXt

type of buoy, type of drogue

6AhAhAhAN

anemometer height, type of anemometer

7VBVBdBdB

drifting speed and drift direction of the buoy at the last known position

8ViViViVi

engineering status of the buoy

9/ZdZdZd

length of the cable at which the drogue is attached

Parsing of SYNOP messages

SYNOP Section 0: information about the observation and the observing station

 MiMiMjMj
 FM12 (fixed land):  AAXX                     YYGGiw IIiii
 FM13 (sea):         BBXX {D....D|A1bwnbnbnb} YYGGiw 99LaLaLa QcLoLoLoLo
 FM14 (mobile land): OOXX D....D              YYGGiw 99LaLaLa QcLoLoLoLo MMMULaULo h0h0h0h0im
MiMiMjMj

station type

BBXX: D....D | A1bwnbnbnb

call sign or station id

OOXX: D....D

call sign

YYGGiw

day and hour of observation, indicator for wind speed (unit)

AAXX: IIiii

station identification

BBXX, OOXX: 99LaLaLa QcLoLoLoLo

position of the station

OOXX: MMMULaULo h0h0h0h0im

position of the station (Marsden square, height)

optional: NIL

message contains no observation data, end of message

SYNOP Section 1: land observations (data for global exchange common for all code forms)

 iRixhVV Nddff (00fff) 1snTTT {2snTdTdTd|29UUU} 3P0P0P0P0 {4PPPP|4a3hhh} 5appp 6RRRtR {7wwW1W2|7wawaWa1Wa2} 8NhCLCMCH 9GGgg
iRixhVV

precipitation indicator, weather indicator, base of lowest cloud

Nddff (00fff)

total cloud cover, wind direction and speed

1snTTT

temperature

2snTdTdTd | 29UUU

dew point or relative humidity

3P0P0P0P0

station level pressure

4PPPP | 4a3hhh

sea level pressure or geopotential height of an agreed standard isobaric surface

5appp

three-hourly pressure tendency (for station level pressure if provided)

6RRRtR

amount of precipitation for given period

7wwW1W2 | 7wawaWa1Wa2

present and past weather

8NhCLCMCH

cloud type for each level and cloud cover of lowest reported cloud type

9GGgg

exact observation time

SYNOP Section 2: sea surface observations (maritime data for global exchange, optional)

 222Dsvs 0ssTwTwTw 1PwaPwaHwaHwa 2PwPwHwHw 3dw1dw1dw2dw2 4Pw1Pw1Hw1Hw1 5Pw2Pw2Hw2Hw2 {6IsEsEsRs|ICING plain language} 70HwaHwaHwa 8swTbTbTb ICE {ciSibiDizi|plain language}
222Dsvs

direction and speed of displacement of the ship since 3 hours

0ssTwTwTw

sea-surface temperature and its type of measurement

1PwaPwaHwaHwa

period and height of waves (instrumental data)

2PwPwHwHw

period and height of wind waves

3dw1dw1dw2dw2 4Pw1Pw1Hw1Hw1 5Pw2Pw2Hw2Hw2

swell data

6IsEsEsRs | ICING plain language

ice accretion on ships

70HwaHwaHwa

height of waves in units of 0.1 metre

8swTbTbTb

data from wet-bulb temperature measurement

ICE {ciSibiDizi | plain language}

sea ice and ice of land origin

SYNOP Section 3: climatological data (data for regional exchange, optional)

(partially implemented)

The WMO regions are:

 region I: 0TgTgRcRt 1snTxTxTx 2snTnTnTn 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7R24R24R24R24 8NsChshs 9SPSPspsp 80000 0LnLcLdLg (1sLdLDLve)

 region II: 0EsnT'gT'g 1snTxTxTx 2snTnTnTn 3EsnTgTg 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7R24R24R24R24 8NsChshs 9SPSPspsp

 region III: 1snTxTxTx 2snTnTnTn 3EsnTgTg 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7R24R24R24R24 8NsChshs 9SPSPspsp

 region IV: 0CsDLDMDH 1snTxTxTx 2snTnTnTn 3E/// 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7R24R24R24R24 8NsChshs 9SPSPspsp TORNADO/ONE-MINUTE MAXIMUM x KNOTS AT x UTC

 region V: 1snTxTxTx 2snTnTnTn 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7R24R24R24R24 8NsChshs 9SPSPspsp

 region VI: 1snTxTxTx 2snTnTnTn 3EsnTgTg 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7R24R24R24R24 8NsChshs 9SPSPspsp

 Antarctic: 0dmdmfmfm (00200) 1snTxTxTx 2snTnTnTn 4E'sss 5j1j2j3j4 (j5j6j7j8j9) 6RRRtR 7DmDLDMDH 8NsChshs 9SPSPspsp
region I: 0TgTgRcRt

minimum ground temperature last night, character and start/end of precipitation

region II: 0EsnT'gT'g

state of the ground without snow or measurable ice cover, ground temperature

region IV: 0CsDLDMDH

state of sky in tropics

Antarctic: 0dmdmfmfm (00200)

maximum wind during the preceding six hours

1snTxTxTx

maximum temperature (regions I, II except CN, MG: last 12 hours day-time; MG: 24 hours before 14:00, region III: day-time; region IV: at 00:00 and 18:00 last 12 hours, at 06:00 last 24 hours, at 12:00 previous day; region V, CN: last 24 hours, region VI: last 12 hours, DE at 09:00 UTC: 15 hours, Antarctic: last 12 hours)

2snTnTnTn

minimum temperature (regions I, II except CN, MG: night-time last 12 hours; MG: 24 hours before 04:00, region III: last night; region IV: at 00:00 last 18 hours, at 06:00 and 18:00 last 24 hours, at 12:00 last 12 hours; region V, CN: last 24 hours, region VI: last 12 hours, DE at 09:00 UTC: 15 hours, Antarctic: last 12 hours)

regions II, III, VI: 3EsnTgTg

state of the ground without snow or measurable ice cover, minimum ground temperature last night (DE: 12/15 hours)

region IV: 3E///

state of the ground without snow or measurable ice cover

4E'sss

state of the ground if covered with snow or ice, snow depth

5j1j2j3j4 (j5j6j7j8j9)

evaporation, temperature change, duration of sunshine, radiation type and amount, direction of cloud drift, direction and elevation of cloud, pressure change

6RRRtR

amount of precipitation for given period

regions I..VI: 7R24R24R24R24

amount of precipitation in the last 24 hours

Antarctic: 7DmDLDMDH

maximum wind during the preceding six hours

8NsChshs

cloud cover and height for cloud layers

9SPSPspsp

supplementary information (partially implemented)

region IV: TORNADO/ONE-MINUTE MAXIMUM x KNOTS AT x UTC

wind speed for tornado or maximum wind

SYNOP Section 4: clouds with base below station level (data for national use, optional)

 N'C'H'H'Ct
N'C'H'H'Ct

data for clouds with base below station level

SYNOP Section 5: data for national use (optional)

(partially implemented)

 AT:      1snTxTxTx 6RRR/
 BE:      1snTxTxTx 2snTnTnTn
 CA:      1ssss 2swswswsw 3dmdmfmfm 4fhftftfi
 NL:      2snTnTnTn 4snTgTgTg 511ff 512ff
 US land: RECORD* 0ittDtDtD 1snTT snTxTxsnTnTn RECORD* 2R24R24R24R24 44snTwTw 9YYGG
 US sea:  11fff 22fff 3GGgg 4ddfmfm 6GGgg dddfff dddfff dddfff dddfff dddfff dddfff 8ddfmfm 9GGgg
 CZ:      1dsdsfsfs 2fsmfsmfsxfsx 3UU// 5snT5T5T5 6snT10T10T10 7snT20T20T20 8snT50T50T50 9snT100T100T100
 LT:      1EsnT'gT'g (2SnTnTnTn|2snTwTwTw) 3EsnT'gT'g 4E'sss 52snT2T2 530f12f12 6RRRtR 7R24R24R24/ 88R24R24R24
 RU:      1EsnT'gT'g 2snTnTnTn 3EsnTgTg 4E'sss (5snT24T24T24) (52snT2T2) (530f12f12) 7R24R24R24/ 88R24R24R24
AT: 1snTxTxTx

maximum temperature on the previous day from 06:00 to 18:00 UTC

AT: 6RRR/

amount of precipitation on the previous day from 06:00 to 18:00 UTC

BE: 1snTxTxTx

maximum temperature on the next day from 00:00 to 24:00 UTC

BE: 2snTnTnTn

minimum temperature on the next day from 00:00 to 24:00 UTC

CA: 1ssss

amount of snowfall, in tenths of a centimetre, for the 24-hour period ending at 06:00 UTC

CA: 2swswswsw

amount of water equivalent, in tenths of a millimetre, for the 24-hour snowfall ending at 06:00 UTC

CA: 3dmdmfmfm

maximum (mean or gust) wind speed, in knots, for the 24-hour period ending at 06:00 UTC and its direction

CA: 4fhftftfi

together with the previous group, the hundreds digit of the maximum wind speed (in knots), the time of occurrence of the maximum wind speed, and the speed range of the maximum two-minute mean wind speed, for the 24-hour period ending at 06:00 UTC and its direction

NL: 2snTnTnTn

minimum temperature last 14 hours

NL: 4snTgTgTg

minimum ground (10 cm) temperature last 14 hours

NL: 511ff

maximum wind gust speed last hour

NL: 512ff

maximum mean wind speed last hour

US land: RECORD

indicator for temperature record(s)

US land: 0ittDtDtD

tide data

US land: 1snTT snTxTxsnTnTn RECORD* 2R24R24R24R24

city data: temperature, maximum and minimum temperature, indicator for temperature record(s), precipitation last 24 hours

US land: 44snTwTw

water temperature

US land: 9YYGG

additional day and hour of observation (repeated from Section 0)

US sea: 11fff 22fff

equivalent wind speeds at 10 and 20 meters

US sea: 3GGgg 4ddfmfm

maximum wind speed since the last observation and the time when it occurred

US sea: 6GGgg

end time of the latest 10-minute continuous wind measurements

US sea: 6 x dddfff

6 10-minute continuous wind measurements

US sea: 8ddfmfm 9GGgg

highest 1-minute wind speed and the time when it occurred

CZ: 1dsdsfsfs

wind direction and speed from tower measurement

CZ: 2fsmfsmfsxfsx

maximum wind gust speed over 10 minute period and the period W1W2

CZ: 3UU//

relative humidity

CZ: 5snT5T5T5 6snT10T10T10 7snT20T20T20 8snT50T50T50 9snT100T100T100

soil temperature at the depths of 5, 10, 20, 50, and 100 cm

LT, RU: 1EsnT'gT'g

state of the ground without snow or measurable ice cover, temperature of the ground surface

LT, RU: 2snTnTnTn

minimum temperature last night

LT, RU: 3EsnTgTg

state of the ground without snow or measurable ice cover, minimum temperature of the ground surface last night

LT, RU: 4E'sss

state of the ground if covered with snow or ice, snow depth

LT, RU: 52snT2T2

minimum air temperature at 2 cm last 12 hours (last night)

LT, RU: 530f12f12

maximum wind gust speed in the last 12 hours

LT, RU: 6RRRtR

amount of precipitation for given period

LT, RU: 7R24R24R24/

amount of precipitation in the last 24 hours

LT, RU: 88R24R24R24

amount of precipitation in the last 24 hours if >=30 mm (to confirm the values in 7R24R24R24/)

SYNOP Section 9: data for national use (optional)

(partially implemented)

 DE: 0dxdxfxfx
DE: 0dxdxfxfx

maximum wind gust direction and speed in the last 3 hours

Parsing of SAO messages

SAO (Surface Aviation Observation) was the official format of aviation weather reports until 1996-06-03. However, CWAO still (as of 2020) provides them for about 700 automatic stations in Canada. KWBC publishes some of them as METAR, but the translation is partially buggy (the 6-hour precipitation is shown as 3-hour pressure change, a dew point between 0.1 and 0.4 becomes negative, the day of observation is the current day instead of yesterday if published after midnight).

Observational data for aviation requirements

 CA: III (SA|SP|RS) GGgg AUTOi <sky> V.VI PPI PPP/TT/TdTd/ddff(+fmfm)/AAA/RRRR (remarks) appp TTdOA
 US: CCCC (SA|SP|RS) GGgg AWOS <sky> V PPI TT/TdTd/ddff(Gfmfm)/AAA (remarks)

If the delimiter is a '<' (less than) instead of a '/' (slash), the parameter exceeds certain quality control soft limits.

CA: III

reporting station (ICAO location indicator without leading C)

US: CCCC

reporting station (ICAO location indicator)

optional: NIL

message contains no observation data, end of message

SA | RS | SP

report type:

SA

Record Observation, scheduled

RS

(Record Special) on significant change in weather

SP

(Special), observation taken between Record Observations on significant change in weather

GGgg

hour, minute of observation

CA: AUTOi

station type:

AUTO1

MARS I (capable of reporting cloud, visibility index)

AUTO2

MARS II (capable of reporting cloud, visibility index)

AUTO3

MAPS I

AUTO4

MAPS II (capable of reporting visibility index)

AUTO5

READAC (capable of reporting cloud, visibility index, present weather, gust speed, altimeter setting)

AUTO6

HURRICANE

AUTO7

non-AES automatic station

AUTO8

other AES automatic station

AUTOA

augmented AUTO5 report

US: AWOS (Automated Weather Observing Systems)

reports ceiling/sky conditions, visibility, temperature, dew point, wind direction/speeds/gusts, altimeter setting, automated remarks containing density altitude, variable visibility and variable wind direction, precipitation accumulation

US: AMOS (Automatic Meteorological Observing Station)

reports temperature, dew point, wind direction and speed, pressure (altimeter setting), peak wind speed, precipitation accumulation

US: AUTOB (Automatic Observing Station)

like AMOS but with sky conditions, visibility and precipitation occurrence

US: RAMOS (Remote Automatic Meteorological Observing System)

like AMOS but with 3-hour pressure change, maximum/minimum temperature, and 24-hour precipitation accumulation

SAWR (Supplemental Aviation Weather Report)

unscheduled and made by observers at stations not served by a regularly reporting weather station

sky

can be M or MM (missing), CLR or CLR BLO ..., W... (vertical visibility), or optionally X or -X (sky (partially) obstructed) and one or more cloud groups. If the height is prefixed by E or M, this is the estimated or measured ceiling. If the height is suffixed by V it is variable. If the cloud cover is prefixed by -, the cover is thin.

CA: V.VI

prevailing visibility (in SM), optionally with tenths. Optionally, I can be V (variable) or + (greater than).

US: V

prevailing visibility (in SM), optionally with fractions of SM

PPI

groups to describe the present weather: precipitation (L, R, S, SG, IP, A, SP, IN, U), obscuration (F, K, BD, BN, H) or other (PO, Q, T). Certain precipitation and dust storm can have the intensity (+, - or --) appended.

CA: PPP

mean sea level pressure (in hPa, last 3 digits)

TT/TdTd

air temperature and dew point temperature (CA: in °C, US: in F). Both or either can be M (missing).

CA: ddff(+fmfm), US: ddff(Gfmfm)

wind direction and speed (in KT), optionally gust speed, or MMMM (missing). If the direction is greater than 50, 100 must be added to the speed(s) and 50 subtracted from the direction.

AAA

altimeter setting (in hundredths of inHg, last 3 digits), or M (missing)

CA: RRRR

precipitation since previous main synoptic hour (tenths of mm)

Remarks

There may be remarks, similar to the ones in METAR.

CA: Additional groups

appp

three-hourly pressure tendency for station level pressure

TTdOA

temperature tenths value, dew point tenths value, total opacity (sky hidden, in tenths) and total amount (sky covered, in tenths) of sky cover

Parsing of METAR, SPECI and TAF messages

First, the message is checked for typical errors and corrected. Errors for METARs could be:

If the message is modified there will be a warning.

Observational data for aviation requirements

METAR, SPECI:

 (COR|AMD|ADV) CCCC YYGGggZ (NIL|AUTO|COR|RTD|BBB) dddff(f)(Gfmfm(fm)){KMH|KT|MPS} (dndndnVdxdxdx)
   {CAVOK|{VVVV (VNVNVNVNDv)|VVVVNDV} (RDRDR/VRVRVRVR(VVRVRVRVR)(i)) (w'w')
          ({NsNsNs|VVV}hshshs|CLR|SKC|NSC|NCD)}
   T'T'/T'dT'd {Q|A}PHPHPHPH
   (REw'w') (WS {RDRDR|ALL RWY}) (WTsTs/{SS'|HHsHsHs}) (RDRDR/ERCReReRBRBR)

TAF:

 (COR|AMD) CCCC YYGGggZ (NIL|COR|AMD) {Y1Y1G1G1G2G2|Y1Y1G1G1/Y2Y2G2G2} (CNL) (NIL) dddff(f)(Gfmfm(fm)){KMH|KT|MPS} (dndndnVdxdxdx)
  {CAVOK|VVVV (w'w') ({NsNsNs|VVV}hshshs|NSC) (TXTFTF/YFYFGFGFZ TNTFTF/YFYFGFGFZ)}
optional: COR and/or AMD and/or ADV

keywords to indicate a corrected and/or amended and/or advisory message.

CCCC

reporting station (ICAO location indicator)

YYGGggZ

METAR: day, hour, minute of observation; SPECI: day, hour, minute of occurrence of change; TAF: day, hour, minute of origin of forecast

METAR, SPECI: optional: NIL | AUTO | COR | RTD | BBB

report modifier(s) NIL: message contains no observation data, end of message; AUTO: message created by an automated station; COR: corrected message; RTD: retarded message.

CA: BBB: report has been retarded (RR?), corrected (CC?), amended (AA?), or segmented (P??)

TAF: optional: NIL | COR | AMD

report modifier(s). NIL: message contains no forecast data, end of message; COR: message corrected; AMD: message amended

TAF: Y1Y1G1G1G2G2 | Y1Y1G1G1/Y2Y2G2G2

forecast period with format before or after August, 2007

TAF: optional: CNL

cancelled forecast

TAF: optional: NIL

message contains no forecast data, end of message

TAF: optional: FCST NOT AVBL DUE {NO | INSUFFICIENT} OBS

message contains no forecast data

TAF: optional: ADVISORY OFFSITE

message is advisory

dddff(f)(Gfmfm(fm)){KMH | KT | MPS}

surface wind with optional gust (if it exceeds the wind speed by 10 knots or more)

METAR, SPECI: mean true direction in degrees rounded off to the nearest 10 degrees from which the wind is blowing and mean speed of the wind over the 10-minute period immediately preceding the observation; TAF: mean direction and speed of forecast wind

wind direction may be VRB for variable if the speed is <3 (US: <=6) knots or if the variation of wind direction is 180° or more or cannot be determined (not US); wind direction and speed may be 00000 for calm wind

optional: dndndnVdxdxdx

variable wind direction if the speed is >=3 (US: >6) knots

CAVOK

If the weather conditions allow (visibility 10 km or more, no significant weather, no clouds below 5000 ft (or minimum sector altitude, whichever is greater) and no CB or TCU) this may be indicated by the keyword CAVOK. The next component after that should be the temperature (see below).

VVVV (VNVNVNDv) | VVVVNDV

prevailing visibility (or lowest if not the same in different directions and fluctuating rapidly). It can have a compass direction attached or NDV if no directional variations can be given. There may be an additional group for the minimum visibility. However, if the minimum visibility is less than 1500 m and the visibility in another direction is more than 5000 m, the minimum and maximum visibility will be reported instead.

METAR: optional: RDRDR/VRVRVRVR(VVRVRVRVR)(i)

runway visibility range(s) with optional trend, or RVRNO if they are not available

optional: w'w'

up to 3 groups to describe the present weather: precipitation (DZ, RA, SN, SG, PL, GR, GS, IC, UP, JP), obscuration (BR, FG, FU, VA, DU, SA, HZ), or other (PO, SQ, FC, SS, DS). Mixed precipitation is indicated by concatenating, e.g. RASN. Certain precipitation, dust storm and sandstorm can have the intensity (+ or -) prepended. Prepended VC means in the vicinity (within 5 SM / 8 km to 10 SM / 16 km) but not at the station. Certain phenomena can also be combined with an appropriate descriptor (MI, BC, PR, DR, BL, SH, TS, FZ), e.g. TSRA, FZFG, BLSN.

optional: {NsNsNs | VVV}hshshs(TCU | CB) | CLR | SKC | NSC | NCD

up to 3 (US: 6) groups to describe the sky condition (cloud cover and base or vertical visibility) optionally with cloud type. The keywords CLR, SKC, NSC, or NCD may indicate different sky conditions if no cloud cover is given. Height values (given in hundreds of feet) are rounded to the nearest reportable amount (<=5000 ft: 100 ft, <=10000 ft: 500 ft, otherwise 1000 ft) (for US), or rounded down to the nearest 30 m (WMO).

METAR: T'T'/T'dT'd

current air temperature and dew point. If both are given, the relative humidity can be determined.

METAR: {Q | A}PHPHPHPH

QNH (in hectopascal) or altimeter (in hundredths in. Hg.). Some stations report both, some stations report QFE, only.

METAR: optional: REw'w'

recent weather

METAR: optional: WS {RDRDR | ALL RWY}

wind shear for certain or all runways

METAR: optional: WTsTs/{SS' | HHsHsHs}

sea-surface temperature, state of the sea or significant wave height

METAR: optional: RDRDR(/)ERCReReRBRBR

state of the runway: runway deposits, extent of runway contamination, depth of deposit, and friction coefficient or braking action

ERCReReRBRBR can also be SNOCLO (airport closed due to snow), ERCReReR can also be CLRD if contaminations have been cleared. The runway designator DRDR can also be 88 (all runways), 99 (runway repeated); otherwise, if it is greater than 50, subtract 50 and append R.

A METAR may also contain supplementary information, like colour codes. Additionally, there can be country or station specific information: pressure, worst cloud cover, runway winds, relative humidity.

TAF: optional: TXTFTF/YFYFGFGFZ TNTFTF/YFYFGFGFZ

operationally significant maximum or minimum temperatures within the validity period

A TAF may also contain supplementary information: turbulence, icing, wind shear, QNH. Some stations provide additional information, like obscuration, or temperature and QNH forecast.

METAR, SPECI:

 {NOSIG|TTTTT TTGGgg dddff(f)(Gfmfm(fm)){KMH|KT|MPS} {CAVOK|VVVV {w'w'|NSW}} ({NsNsNs|VVV}hshshs|NSC) ...}

TAF:

 {TTYYGGgg|{PROB C2C2 (TTTTT)|TTTTT} YYGG/YeYeGeGe} dddff(f)(Gfmfm(fm)){KMH|KT|MPS}
  {CAVOK|VVVV {w'w'|NSW} ({NsNsNs|VVV}hshshs|NSC)}
  ...

Remarks

Finally, there may be remarks.

 RMK ...

The parser recognises more than 80 types of remarks for METARs, plus about 50 keywords/keyword groups, and 5 types of remarks for TAFs. They include (additional) information about wind and visibility (at different locations, also max./min.), cloud (also types), pressure (also change), temperature (more accurate, also max. and min.), runway state, duration of sunshine, precipitation (also amounts, start, end), weather phenomena (with location, moving direction), as well as administrative information (e.g. correction/amendment, LAST, NEXT, broken measurement equipment). Some countries publish documentation about the contents, but this section can contain any free text.

SUBROUTINES/METHODS

start_cb(\&cb)

This function registers the provided callback function. It also immediately invokes it for "/data" and "/data/reports" with type "start".

See finish() for how to complete the processing of reports.

The following argument is expected:

cb

reference to the callback function

The callback function is invoked for each node of the extracted data. The following arguments are passed:

path

reference to an array containing the names of all parent nodes of the current node

type

one of the values empty, start or end

For each start, the callback function is also invoked with the matching end after all subnodes have been processed. For empty (a node without subnodes, but possibly attributes and character data (an attribute with an empty string for the name)), the function is only invoked once.

node

name of the current node

[name, value, ...]

(optionally empty) list of pairs of node attribute names and values

This list is always empty if type is end.

For BUFR messages with multiple observations, multiple reports will be generated and the callback function will be invoked for all of them before parse_report() or process_bufr() return.

The callback function should return one the following values:

0

An error occurred which should abort the processing.

1

No error occurred.

The function will return one of the following values:

0

An error occurred. Possible error causes:

1

No error occurred.

start_xml(\%opts)

This function sets the options relevant for writing the data as XML. It then invokes start_cb() with an internal callback function. The callback function opens out_file and writes to it the XML items according to the options. After that, it invokes it for "/data" and "/data/reports" with type "start".

See finish() for how to complete the processing of reports.

The following argument is expected:

opts

reference to hash of options

The following keys of the hash are recognised:

o, contains the value for out_file

enables writing the data to out_file (- (minus) means standard output)

If this key is not provided, no output is generated.

D, contains the value for dtd_file

include DOCTYPE and reference to the DTD dtd_file

S, contains the value for xslt_file

include reference to the stylesheet xslt_file

O, contains the value for options

include options (a space separated list of parameters from/for metaf.pl)

The function will return one of the following values:

0

An error occurred. Possible error causes:

1

No error occurred.

parse_report($msg,$default_msg_type)

This function parses a METAR, TAF, SYNOP, BUOY or AMDAR message or processes a decoded BUFR message provided as space delimited list of descriptor:data pairs.

The following arguments are expected:

msg

message to parse/process

A METAR, TAF, SYNOP, BUOY or AMDAR message in Traditional Alphanumeric Code (TAC) format must be in the format specified by the WMO Manual No. 306, without modifications due to distribution like providing the initial part of messages only once for several messages or appending an "=" (equal sign) to terminate a message.

The Perl module metaf2xml::src2raw or the program metafsrc2raw.pl can be used to create messages with the required format from files provided by various public Internet servers.

A decoded BUFR message must be a space delimited list of descriptor:data pairs (see below).

default_msg_type

default message type

It can be METAR, SPECI, TAF or undefined. This argument will be ignored if the message starts with:

METAR, SPECI or TAF

this will be used as message type

AAXX, BBXX or OOXX

the message type SYNOP will be used

ZZYY

the message type BUOY will be used

AMDAR

the message type AMDAR will be used

FXXYYY: or FXXYYY/ or FXXYYY-

the message will be processed as a decoded BUFR message

The data of the BUFR message is mapped to one or more reports of the message types SYNOP, BUOY, or AMDAR, depending on the content of the BUFR message.

The message must be provided as a space delimited list of descriptor:data pairs in the format FXXYYY:data. F must be 0, i.e. only values are allowed. If there are associated fields, they must be provided as a / (slash) delimited list of significance:value pairs directly after the descriptor. If a data field contains a substring which looks like a descriptor, / (slash) and the length of the data field must be appended directly after the descriptor (or the list of associated fields if it exists). If the data is missing (undefined), a - (minus) is used instead of the : (colon).

Examples:

000001:X

descriptor: 000001

data: X

000001-

descriptor: 000001

data: (missing)

000001/7:50:X

descriptor: 000001

associated significance: 7 (percentage confidence) with value 50

data: X

000001/7:50/8:0/10:X 000002:Y

descriptor: 000001

1st associated significance: 7 (percentage confidence) with value 50

2nd associated significance: 8 (2 bits quality information) with value 0

data (10 characters): X 000002:Y

Leading and trailing spaces are removed, multiple spaces are replaced by a single one. Characters that are invalid in HTML or XML are also removed.

Then the correct function to parse the message is called.

After parsing, the registered callback function is invoked for each data item. For BUFR messages with multiple observations, multiple reports will be generated and the registered callback function will be invoked for all of them before this function returns.

See finish() for how to complete the processing of reports.

The function will return one of the following values:

0

An error occurred. Possible error causes:

1

No error occurred.

process_bufr(\@data,\@desc)

This function processes a decoded BUFR message provided as arrays of values and descriptors.

The following arguments are expected:

data

array of values

desc

array of descriptors for these values

After processing, the registered callback function is invoked for each data item. For BUFR messages with multiple observations, multiple reports will be generated and the registered callback function will be invoked for all of them before this function returns.

See finish() for how to complete the processing of reports.

The function will return one of the following values:

0

An error occurred. Possible error causes:

1

No error occurred.

finish()

This function must be invoked if start_xml() was invoked initially, or if start_xml() or start_cb() are to be invoked again. Otherwise it needs to be invoked only if the callback function requires it.

This function invokes the registered callback function for the nodes "reports" and "data" with type "end".

No arguments are expected.

The function will return one of the following values:

0

An error occurred. Possible error causes:

1

No error occurred.

DEPENDENCIES

The Perl module metaf2xml::bufr is required.

SEE ALSO

metaf2xml::src2raw(3pm), metaf2xml::bufr(3pm), metaf2xml(1), metafsrc2raw(1), https://metaf2xml.sourceforge.io/

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

This file is part of metaf2xml.

metaf2xml is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

metaf2xml is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with metaf2xml. If not, see https://www.gnu.org/licenses/.