metaf2xml::parser - parse a METAR/TAF/SYNOP/BUOY/AMDAR message
 use metaf2xml::parser 2.010;
 # 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();                              # mandatoryThis 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.
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|ARP} YYGGday of the month (UTC), and actual time, rounded downwards to the nearest hour UTC, of the first AMDAR report in the bulletin
 ipipip IA...IA LaLaLaLaA LoLoLoLoLoB YYGGgg (ShhIhIhI) SSTATATA ({SSTdTdTd|UUU}) ddd/fff (TBBA) (Ss1s2s3)phase of flight indicator
aircraft identifier
geographical location
day, hour, minute of measurement
pressure altitude, in hundreds of feet, relative to the standard datum plane of 1013.2 hPa
air temperature, in tenths of degrees Celsius
dew point temperature, in tenths of degrees Celsius, or relative humidity
/ffftrue direction, in whole degrees, from which wind is blowing, and wind speed, in knots
TBBAturbulence
Ss1s2s3type of navigation system, type of system used, and temperature precision
 333 Fhdhdhd VGfgfgfgFhdhdhdflight level (based on ICAO standard atmosphere for reports above 700 hPa, on airport QNH otherwise)
VGfgfgfgmaximum derived equivalent vertical gust, in tenths of a metre per second
 MiMiMjMj A1bwnbnbnb YYMMJ GGggiw QcLaLaLaLaLa LoLoLoLoLoLo (6QlQtQA/)station type
station id
day, month, units digit of year, hour, minute of observation, indicator for wind speed (unit)
position of the buoy
6QlQtQA/quality control indicators for position and time
 111QdQx 0ddff 1snTTT {2snTdTdTd|29UUU} 3P0P0P0P0 4PPPP 5appp111QdQxquality control indicators for section 1
0ddffwind direction and speed
1snTTTtemperature
2snTdTdTd | 29UUUdew point or relative humidity
3P0P0P0P0station level pressure
4PPPPsea level pressure
5apppthree-hourly pressure tendency (for station level pressure if provided)
 222QdQx 0snTwTwTw 1PwaPwaHwaHwa 20PwaPwaPwa 21HwaHwaHwa222QdQxquality control indicators for section 2
0snTwTwTwsea-surface temperature
1PwaPwaHwaHwaperiod and height of waves (instrumental data)
20PwaPwaPwa 21HwaHwaHwaperiod and height of waves (instrumental data) with tenths
 333Qd1Qd2 (8887k2  2z0z0z0z0 3T0T0T0T0 4S0S0S0S0
                    ...
                    2znznznzn 3TnTnTnTn 4SnSnSnSn)
           (66k69k3 2z0z0z0z0 d0d0c0c0c0
                    ...
                    2znznznzn dndncncncn)333Qd1Qd2quality 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
 444 1QPQ2QTWQ4 2QNQLQAQz {QcLaLaLaLaLa LoLoLoLoLoLo|YYMMJ GGgg/} (3ZhZhZhZh 4ZcZcZcZc) 5BtBtXtXt 6AhAhAhAN 7VBVBdBdB 8ViViViVi 9/ZdZdZd1QPQ2QTWQ4quality of: pressure measurement, housekeeping parameter, measurement of water-surface temperature, measurement of air temperature
2QNQLQAQzquality of buoy satellite transmission, quality of location, location quality class, indicator of depth correction
if QL=2: second possible solution for the position of the buoy
/if QL=1: day, month, units digit of year, hour, minute of the time of the last known position
3ZhZhZhZh 4ZcZcZcZchydrostatic pressure of lower end of cable, length of cable in metres (thermistor strings)
5BtBtXtXttype of buoy, type of drogue
6AhAhAhANanemometer height, type of anemometer
7VBVBdBdBdrifting speed and drift direction of the buoy at the last known position
8ViViViViengineering status of the buoy
9/ZdZdZdlength of the cable at which the drogue is attached
 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 h0h0h0h0imstation type
call sign or station id
call sign
day and hour of observation, indicator for wind speed (unit)
station identification
99LaLaLa QcLoLoLoLoposition of the station
position of the station (Marsden square, height)
NILmessage contains no observation data, end of message
 iRixhVV Nddff (00fff) 1snTTT {2snTdTdTd|29UUU} 3P0P0P0P0 {4PPPP|4a3hhh} 5appp 6RRRtR {7wwW1W2|7wawaWa1Wa2} 8NhCLCMCH 9GGggprecipitation indicator, weather indicator, base of lowest cloud
00fff)total cloud cover, wind direction and speed
1snTTTtemperature
2snTdTdTd | 29UUUdew point or relative humidity
3P0P0P0P0station level pressure
4PPPP | 4a3hhhsea level pressure or geopotential height of an agreed standard isobaric surface
5apppthree-hourly pressure tendency (for station level pressure if provided)
6RRRtRamount of precipitation for given period
7wwW1W2 | 7wawaWa1Wa2present and past weather
8NhCLCMCHcloud type for each level and cloud cover of lowest reported cloud type
9GGggexact observation time
 222Dsvs 0ssTwTwTw 1PwaPwaHwaHwa 2PwPwHwHw 3dw1dw1dw2dw2 4Pw1Pw1Hw1Hw1 5Pw2Pw2Hw2Hw2 {6IsEsEsRs|ICING plain language} 70HwaHwaHwa 8swTbTbTb ICE {ciSibiDizi|plain language}222Dsvsdirection and speed of displacement of the ship since 3 hours
0ssTwTwTwsea-surface temperature and its type of measurement
1PwaPwaHwaHwaperiod and height of waves (instrumental data)
2PwPwHwHwperiod and height of wind waves
3dw1dw1dw2dw2 4Pw1Pw1Hw1Hw1 5Pw2Pw2Hw2Hw2swell data
6IsEsEsRs | ICING plain languageice accretion on ships
70HwaHwaHwaheight of waves in units of 0.1 metre
8swTbTbTbdata from wet-bulb temperature measurement
ICE {ciSibiDizi | plain language}sea ice and ice of land origin
(partially implemented)
The WMO regions are:
I (Africa)
II (Asia)
III (South America)
IV (North and Central America)
V (South-West Pacific)
VI (Europe)
Antarctic
 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 9SPSPspsp0TgTgRcRtminimum ground temperature last night, character and start/end of precipitation
0EsnT'gT'gstate of the ground without snow or measurable ice cover, ground temperature
0CsDLDMDHstate of sky in tropics
0dmdmfmfm (00200)maximum wind during the preceding six hours
1snTxTxTxmaximum 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)
2snTnTnTnminimum 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)
3EsnTgTgstate of the ground without snow or measurable ice cover, minimum ground temperature last night (DE: 12/15 hours)
3E///state of the ground without snow or measurable ice cover
4E'sssstate 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
6RRRtRamount of precipitation for given period
7R24R24R24R24amount of precipitation in the last 24 hours
7DmDLDMDHmaximum wind during the preceding six hours
8NsChshscloud cover and height for cloud layers
9SPSPspspsupplementary information (partially implemented)
TORNADO/ONE-MINUTE MAXIMUM x KNOTS AT x UTCwind speed for tornado or maximum wind
 N'C'H'H'Ctdata for clouds with base below station level
(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/ 88R24R24R241snTxTxTxmaximum temperature on the previous day from 06:00 to 18:00 UTC
6RRR/amount of precipitation on the previous day from 06:00 to 18:00 UTC
1snTxTxTxmaximum temperature on the next day from 00:00 to 24:00 UTC
2snTnTnTnminimum temperature on the next day from 00:00 to 24:00 UTC
1ssssamount of snowfall, in tenths of a centimetre, for the 24-hour period ending at 06:00 UTC
2swswswswamount of water equivalent, in tenths of a millimetre, for the 24-hour snowfall ending at 06:00 UTC
3dmdmfmfmmaximum (mean or gust) wind speed, in knots, for the 24-hour period ending at 06:00 UTC and its direction
4fhftftfitogether 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
2snTnTnTnminimum temperature last 14 hours
4snTgTgTgminimum ground (10 cm) temperature last 14 hours
511ffmaximum wind gust speed last hour
512ffmaximum mean wind speed last hour
indicator for temperature record(s)
0ittDtDtDtide data
1snTT snTxTxsnTnTn RECORD* 2R24R24R24R24city data: temperature, maximum and minimum temperature, indicator for temperature record(s), precipitation last 24 hours
44snTwTwwater temperature
9YYGGadditional day and hour of observation (repeated from Section 0)
11fff 22fffequivalent wind speeds at 10 and 20 meters
3GGgg 4ddfmfmmaximum wind speed since the last observation and the time when it occurred
6GGggend time of the latest 10-minute continuous wind measurements
6 10-minute continuous wind measurements
8ddfmfm 9GGgghighest 1-minute wind speed and the time when it occurred
1dsdsfsfswind direction and speed from tower measurement
2fsmfsmfsxfsxmaximum wind gust speed over 10 minute period and the period W1W2
3UU//relative humidity
5snT5T5T5 6snT10T10T10 7snT20T20T20 8snT50T50T50 9snT100T100T100soil temperature at the depths of 5, 10, 20, 50, and 100 cm
1EsnT'gT'gstate of the ground without snow or measurable ice cover, temperature of the ground surface
2snTnTnTnminimum temperature last night
3EsnTgTgstate of the ground without snow or measurable ice cover, minimum temperature of the ground surface last night
4E'sssstate of the ground if covered with snow or ice, snow depth
52snT2T2minimum air temperature at 2 cm last 12 hours (last night)
530f12f12maximum wind gust speed in the last 12 hours
6RRRtRamount of precipitation for given period
7R24R24R24/amount of precipitation in the last 24 hours
88R24R24R24amount of precipitation in the last 24 hours if >=30 mm (to confirm the values in 7R24R24R24/)
(partially implemented)
 DE: 0dxdxfxfx0dxdxfxfxmaximum wind gust direction and speed in the last 3 hours
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).
 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.
reporting station (ICAO location indicator without leading C)
reporting station (ICAO location indicator)
NILmessage contains no observation data, end of message
SA | RS | SPreport type:
SARecord Observation, scheduled
RS(Record Special) on significant change in weather
SP(Special), observation taken between Record Observations on significant change in weather
hour, minute of observation
AUTOistation type:
AUTO1MARS I (capable of reporting cloud, visibility index)
AUTO2MARS II (capable of reporting cloud, visibility index)
AUTO3MAPS I
AUTO4MAPS II (capable of reporting visibility index)
AUTO5READAC (capable of reporting cloud, visibility index, present weather, gust speed, altimeter setting)
AUTO6HURRICANE
AUTO7non-AES automatic station
AUTO8other AES automatic station
AUTOAaugmented AUTO5 report
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
AMOS (Automatic Meteorological Observing Station)reports temperature, dew point, wind direction and speed, pressure (altimeter setting), peak wind speed, precipitation accumulation
AUTOB (Automatic Observing Station)like AMOS but with sky conditions, visibility and precipitation occurrence
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
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.
prevailing visibility (in SM), optionally with tenths. Optionally, I can be V (variable) or + (greater than).
prevailing visibility (in SM), optionally with fractions of SM
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.
mean sea level pressure (in hPa, last 3 digits)
/TdTdair temperature and dew point temperature (CA: in °C, US: in F). Both or either can be M (missing).
+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.
altimeter setting (in hundredths of inHg, last 3 digits), or M (missing)
precipitation since previous main synoptic hour (tenths of mm)
There may be remarks, similar to the ones in METAR.
three-hourly pressure tendency for station level pressure
temperature tenths value, dew point tenths value, total opacity (sky hidden, in tenths) and total amount (sky covered, in tenths) of sky cover
First, the message is checked for typical errors and corrected. Errors for METARs could be:
QNH with spaces
temperature or dew point with spaces
misspelled keywords, or with missing or additional spaces
missing keywords
removal of slashes before and after some components
If the message is modified there will be a warning.
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)}COR and/or AMD and/or ADVkeywords to indicate a corrected and/or amended and/or advisory message.
reporting station (ICAO location indicator)
ZMETAR: day, hour, minute of observation; SPECI: day, hour, minute of occurrence of change; TAF: day, hour, minute of origin of forecast
NIL | AUTO | COR | RTD | BBBreport 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??)
NIL | COR | AMDreport modifier(s). NIL: message contains no forecast data, end of message; COR: message corrected; AMD: message amended
/Y2Y2G2G2forecast period with format before or after August, 2007
CNLcancelled forecast
NILmessage contains no forecast data, end of message
FCST NOT AVBL DUE {NO | INSUFFICIENT} OBSmessage contains no forecast data
ADVISORY OFFSITEmessage is advisory
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
Vdxdxdxvariable wind direction if the speed is >=3 (US: >6) knots
CAVOKIf 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).
NDVprevailing 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.
RDRDR/VRVRVRVR(VVRVRVRVR)(i)runway visibility range(s) for the touchdown zone, with optional trend, or RVRNO if they are not available
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.
TCU | CB) | CLR | SKC | NSC | NCDup 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).
/T'dT'dcurrent air temperature and dew point. If both are given, the relative humidity can be determined.
Q | A}PHPHPHPHQNH (in hectopascal) or altimeter (in hundredths in. Hg.). Some stations report both, some stations report QFE, only.
REw'w'recent weather
WS {RDRDR | ALL RWY}wind shear for certain or all runways
WTsTs/{SS' | HHsHsHs}sea-surface temperature, state of the sea or significant wave height
RDRDR(/)ERCReReRBRBRstate 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.
TXTFTF/YFYFGFGFZ  TNTFTF/YFYFGFGFZoperationally 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)}
  ...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.
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:
cbreference to the callback function
The callback function is invoked for each node of the extracted data. The following arguments are passed:
pathreference to an array containing the names of all parent nodes of the current node
typeone 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.
nodename 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:
0An error occurred which should abort the processing.
1No error occurred.
The function will return one of the following values:
0An error occurred. Possible error causes:
the function was invoked in improper sequence, or
the argument cb was not a reference to a function, or
the callback function cb returned an error for "/data" or "/data/reports".
1No error occurred.
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:
optsreference to hash of options
The following keys of the hash are recognised:
o, contains the value for out_fileenables 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_fileinclude DOCTYPE and reference to the DTD dtd_file
S, contains the value for xslt_fileinclude reference to the stylesheet xslt_file
O, contains the value for optionsinclude options (a space separated list of parameters from/for metaf.pl)
The function will return one of the following values:
0An error occurred. Possible error causes:
the function was invoked in improper sequence, or
the internal callback function encountered an error while trying to open the output file or write to it.
1No error occurred.
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:
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 message type
It can be METAR, SPECI, TAF or undefined. This argument will be ignored if the message starts with:
METAR, SPECI or TAFthis will be used as message type
AAXX, BBXX or OOXXthe message type SYNOP will be used
ZZYYthe message type BUOY will be used
AMDARthe message type AMDAR will be used
: 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:
descriptor: 000001
data: X
descriptor: 000001
data: (missing)
descriptor: 000001
associated significance: 7 (percentage confidence) with value 50
data: X
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:
0An error occurred. Possible error causes:
the function was invoked in improper sequence, or
one or both arguments are invalid, or
the registered callback function returned an error while processing the data.
1No error occurred.
This function processes a decoded BUFR message provided as arrays of values and descriptors.
The following arguments are expected:
array of values
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:
0An error occurred. Possible error causes:
the function was invoked in improper sequence, or
one or both arguments are invalid, or
the registered callback function returned an error while processing the data.
1No error occurred.
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:
0An error occurred. Possible error causes:
the function was invoked in improper sequence, or
the registered callback function returned an error while processing the data.
1No error occurred.
The Perl module metaf2xml::bufr is required.
metaf2xml::src2raw(3pm), metaf2xml::bufr(3pm), metaf2xml(1), metafsrc2raw(1), https://metaf2xml.sourceforge.io/
copyright (c) 2006-2024 metaf2xml @ 
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/.