METAR reader
Statement
Goal
When you fly an aircraft, one of the most important thing to check is the weather. Airmen receive weather information through different forms, the most classical being the METAR, short for METeorological Aerodrome Report.METAR are easy to read for trained people but it looks quite cryptic for newcomers. Your mission is to write a METAR decoder for them.
You will have to display:
- The location (4 chars ICAO code for the airport)
- Time in UTC (hh:mm, 24h format)
- The wind : direction, speed and gusts
- Cloud layers
- Visibility
- Temperature and dew point
- Atmospheric pressure at sea level in inHg (inch of mercury). Beware, some METAR uses hectoPascals, which you'll have to convert, rounded with 2 decimals. Input is Qxxxx when in hPa, Axxxx when in mmHg
Other data may be present in the METAR, and should not be decoded.
For instance, the METAR "010830Z LFPN 27010KT 2900 DZ BR OVC003 11/10 Q0995" must be decoded this way:
Airport: LFPN
Time: 8:30 UTC
Wind: From 270° at 10 knots
Visibility : 2900 m
Cloud: Overcast at 300 feet
Temperature is 11 °c, dew point is 10 °c
Atmospheric pressure at sea level is 29.38 inHg
Input
1 line: METAR to decode
Output
7 lines in the following format:
Airport: ABCD
Time: hh:mm UTC
Wind: From yyy° at zz knots[, gusts at gg knots]
Visibility : nnnn m
Cloud: CLOUD_TYPE at xxx feet,
Temperature is xx °c, dew point is xx °c
Atmospheric pressure at sea level is xx.xx inHg
Airport: ABCD
Time: hh:mm UTC
Wind: From yyy° at zz knots[, gusts at gg knots]
Visibility : nnnn m
Cloud: CLOUD_TYPE at xxx feet,
Temperature is xx °c, dew point is xx °c
Atmospheric pressure at sea level is xx.xx inHg
Constraints
In case of CAVOK, consider visibility at 10000 m, and No significant cloud
Cloud coverage can be :
NSC : No significant cloud
FEW: Few
SCT: Scattered
BKN: Broken
OVC: Overcast
Cloud coverage can be :
NSC : No significant cloud
FEW: Few
SCT: Scattered
BKN: Broken
OVC: Overcast
Example
Input
010830Z LFPN 27010KT 2900 DZ BR BKN008 OVC030 11/10 Q0995
Output
Airport: LFPN Time: 8:30 UTC Wind: From 270° at 10 knots Visibility: 2900 m Cloud: Broken at 800 feet, Overcast at 3000 feet Temperature is 11 °c, dew point is 10 °c Atmospheric pressure at sea level is 29.38 inHg
Tags
Regular expressions, String manipulation
Difficulty
Easy
Test cases
Example Test
Input
010830Z LFPN 27010KT 2900 DZ BR BKN008 OVC030 11/10 Q0995
Output
Airport: LFPN
Time: 8:30 UTC
Wind: From 270° at 10 knots
Visibility: 2900 m
Cloud: Broken at 800 feet, Overcast at 3000 feet
Temperature is 11 °c, dew point is 10 °c
Atmospheric pressure at sea level is 29.38 inHg
Simple Validator
Input
011330Z EPZG 09009KT 4700 HZ NSC M01/M08 Q1001
Output
Airport: EPZG
Time: 13:30 UTC
Wind: From 90° at 9 knots
Visibility: 4700 m
Cloud: No significant cloud
Temperature is -1 °c, dew point is -8 °c
Atmospheric pressure at sea level is 29.56 inHg
Test 2 Test
Input
011330Z EPZG 09009KT 4700 HZ NSC M01/M10 A3012
Output
Airport: EPZG
Time: 13:30 UTC
Wind: From 90° at 9 knots
Visibility: 4700 m
Cloud: No significant cloud
Temperature is -1 °c, dew point is -10 °c
Atmospheric pressure at sea level is 30.12 inHg
Validator 2 Validator
Input
010830Z LFPN 27010KT 2900 DZ BR FEW018 SCT110 22/05 A2982
Output
Airport: LFPN
Time: 8:30 UTC
Wind: From 270° at 10 knots
Visibility: 2900 m
Cloud: Few at 1800 feet, Scattered at 11000 feet
Temperature is 22 °c, dew point is 5 °c
Atmospheric pressure at sea level is 29.82 inHg
CAVOK Test
Input
021200Z KBBN 00000KT CAVOK 15/10 Q1012 NOSIG
Output
Airport: KBBN
Time: 12:00 UTC
Wind: From 0° at 0 knots
Visibility: 10000 m
Cloud: No significant cloud
Temperature is 15 °c, dew point is 10 °c
Atmospheric pressure at sea level is 29.88 inHg
CAVOK Validator
Input
021232Z UKTP 09002KT CAVOK 11/08 A2992 NOSIG
Output
Airport: UKTP
Time: 12:32 UTC
Wind: From 90° at 2 knots
Visibility: 10000 m
Cloud: No significant cloud
Temperature is 11 °c, dew point is 8 °c
Atmospheric pressure at sea level is 29.92 inHg
Extra text Test
Input
021155Z LIMS 36004KT 1200 R30/P1500 R12//// BR OVC002 05/05 Q1013
Output
Airport: LIMS
Time: 11:55 UTC
Wind: From 360° at 4 knots
Visibility: 1200 m
Cloud: Overcast at 200 feet
Temperature is 5 °c, dew point is 5 °c
Atmospheric pressure at sea level is 29.91 inHg
Extra text Validator
Input
021200Z LKNA 13006KT 0600 R12/1500D FZFG OVC002 M01/M02 Q1007 NOSIG
Output
Airport: LKNA
Time: 12:00 UTC
Wind: From 130° at 6 knots
Visibility: 0600 m
Cloud: Overcast at 200 feet
Temperature is 12 °c, dew point is 15 °c
Atmospheric pressure at sea level is 29.74 inHg
Gusts Test
Input
021200Z LFBH 23020G30KT 4800 -RA BR BKN003 BKN011 OVC020 12/12 Q1008
Output
Airport: LFBH
Time: 12:00 UTC
Wind: From 230° at 20 knots, gusts at 30 knots
Visibility: 4800 m
Cloud: Broken at 300 feet, Broken at 1100 feet, Overcast at 2000 feet
Temperature is 12 °c, dew point is 12 °c
Atmospheric pressure at sea level is 29.77 inHg
Gusts Validator
Input
021230Z LFRL 23015G30KT 7000 BKN006 OVC009 13/11 Q1003
Output
Airport: LFRL
Time: 12:30 UTC
Wind: From 230° at 15 knots, gusts at 30 knots
Visibility: 7000 m
Cloud: Broken at 600 feet, Overcast at 900 feet
Temperature is 13 °c, dew point is 11 °c
Atmospheric pressure at sea level is 29.62 inHg
Solution language
Solution
Stub generator input