Assignment 2
Working individually you will create a series of regular expressions that identify different parts composing a METAR.
METARs are reports assembled with a particular format that is easy to decode with computer systems using regular expressions.
These reports typically come in two forms: North American METARs and International METARs. Create a series of regular expressions that decode each token of information using the North American METAR form.
You can find METAR reports at the following address:
In order to find the weather information you need to get a METAR report from any airport you wish utilizing the appropriate code (Baltimore-Washington International is KBWI) and then apply the different regular expressions to identify each token and eventually extract it from the report.
Your homework submission should be a script that reads a single line METAR from a file named: metar.txt Your script output (to the shell screen) should include:
- the report type: either METAR or SPECI for “Special Report”
- the station identifies (four characters starting with a K)
- Day of the month and time the report was filed
- If the token ‘AUTO’ is present, you should output “This is a fully automated report”
- If the token ‘COR’ is present, you should output “This is a corrected observation”
- Wind direction and speed, wind gusting, and variable wind directions
- Visibility in statute miles
- Light, medium, or heavy rain (-RA|RA|+RA)
- Cloud Conditions: [0 or more occurrences of each of the following]
- Sky Clear
- Few Clouds <altitude>
- Scattered Clouds <altitude>
- Broken Clouds <altitude>
- Overcast Clouds <altitude>
- Temperature
- Dew Point
- Barometric Pressure
- If the token ‘TH’ is present, you should output “Thunderstorms reported in the area”
| KEY TO DECODING THE U.S. METAR OBSERVATION REPORT |
| KEY TO DECODING A METAR REPORT | ||
| METAR | TYPE OF REPORT | METAR: hourly (scheduled) report; SPECI: special (unscheduled) report. |
| KABC | ICAO STATION (location) IDENTIFIER | Four character ICAO location identifier. |
| 121755Z | DATE/TIME group | All dates and times in UTC using a 24-hour clock; two-digit date and four-digit time; always appended with Z to indicate UTC. |
| AUTO | REPORT MODIFIER | AUTO: Indicates a fully automated report with no human intervention. It is removed when an observer logs on to the system. COR: Indicates a corrected observation. No modifier indicates human observer or automated system with human logged on for oversight functions. |
| 21016G24KT 180V240 | WIND DIRECTION AND SPEED | Direction in tens of degrees from true north (first three digits); next two digits: speed in whole knots; if needed, include character as: Gusts (character) followed by maximum observed speed; always appended with KT to indicate knots; 00000KT for calm; if direction varies by 60o or more and speed greater than 6 knots, a Variable wind direction group is reported, otherwise omitted. If wind direction is variable and speed 6 knots or less, replace wind direction with VRB followed by wind speed in knots. |
| 1SM | VISIBILITY | Prevailing visibility in statute miles and fractions with space between whole miles and fractions; always appended with SM to indicate statute miles; values <1/4SM reported as M1/4SM. |
| R11/P6000FT | RUNWAY VISUAL RANGE | A 10-minute RVR evaluation value in hundreds of feet is reported if prevailing visibility is < or = 1 mile or RVR < or = 6000 feet; always appended with FT to indicate feet; value prefixed with M or P to indicate value is lower or higher than the reportable RVR value. See |
| -RA BR | WEATHER PHENOMENA | Present weather: QUALIFIER Intensity or Proximity – Light “no sign” Moderate + Heavy VC Vicinity: but not at aerodrome; in U.S. METAR, between 5SM and 10SM of the point(s) of observation. Descriptor MI Shallow BL Blowing BC Patches SH showers PR Partial DR Drifting TS Thunderstorm FZ Freezing WEATHER PHENOMENA Precipitation DZ Drizzle IC Ice Crystals UP Unknown in automated observations RA Rain PL Ice pellets SN Snow GR Hail SG Snow grains GS Small hail/ snow pellets Obscuration BR Mist (< or = 5/8SM) SA Sand FU Smoke HZ Haze VA Volcanic Ash PY Spray DU Widespread Dust Other SQ Squall FC Funnel Cloud SS Sandstorm +FC Tornado/ Waterspout DS Duststorm PO Well developed dust/sand whirls |
| BKN015 OVC025 | SKY CONDITION | Cloud amount and height: CLR (In automated METAR reports only, no clouds detected below 12000 feet.); SKy Clear 0/8; FEW 1/8-2/8; SCattered 3/8-4/8; BroKeN 5/8-7/8; OVerCast 8/8; 3-digit height of base in hundreds of feet; followed by Towering CUmulus or CumulonimBus if present. For an observed sky: Vertical Visibility followed by vertical veisibility in hundreds of feet into the obscuration, example: VV004. More than 1 layer may be reported. |
| 06/04 | TEMPERATURE/DEW POINT | Each is reported in whole degrees Celsius using two digits; values are separated by a solidus (/); sub-zero values are prefixed with an M (minus). |
| A2990 | ALTIMETER | Altimeter setting (in U.S. reports) is always prefixed with an A indicating inches of mercury; reported using four digits: tens, units, tenths, and hundredths. |
| The following groups are reported in the Remarks section of the METAR report | ||
| RMK | REMARKS IDENTIFIER | Remarks includes clarifying or augmenting data concerning elements in the body of the METAR, additive coded data and maintenance data. |
| TORNADO, FUNNEL CLOUD or WATERSPOUT | TORNADIC ACTIVITY | Augmented; report should include TORNADO, FUNNEL CLOUD or WATERSPOUT, time (after the hour) of beginning/end, location, movement; e.g., TORNADO B25 N MOVE E |
| AO2 | TYPE OF AUTOMATED STATION | AO1; automated station without a precipitation descriminator. AO2; automated station with precipitation descriminator. |
| PK WND 20032/25 | PEAK WIND | PK WND dddff(F)/(hh)mm; direction in tens of degrees, speed in whole knots, time in minutes after the hour. Only minutes after the hour is included if the hour can be inferred from the report. |
| WSHFT 1715 | WIND SHIFT | WSHFT followed by hours and minutes of occurrence. The term FROPA may be entered after the time if it is reasonably certain that the wind shift was a result of a frontal passage. |
| VIS 3/4V1 1/2 | VARIABLE PREVAILING VISIBILITY | VIS vnvnvnvn vnVvxvxvx vxvx; reported if prevailing visibility is <3 statute miles and variable. |
| VIS 3/4 RWY11 | VISIBILITY AT SECOND LOCATION | VIS vvvvv(LOC); reported if different than the reported prevailing visibility in the body of the report. |
| RAB07 | BEGINNING AND ENDING OF PRECIPITATION AND THUNDERSTORMS | w’w’B(hh)mmE(hh)mm; TSB(hh)mmE(hh)mm, where w’w’ is the present weather precipitation contraction, B indicates began, E indicates ended; (hh) indicates the hour the phenomena began or ended and can be omitted if the hour can be inferred from the report, mm indicates the minutes after the hour the phenomenon began or ended. |
| CIG 013V017 | VARIABLE CEILING | CIG hnhnhnVhx hxhx; reported if the ceiling in the body of the report is < 3000 feet and variable. |
| CIG 017 RWY11 | CEILING HEIGHT AT SECOND LOCATION | CIG hhh[LOC]; Ceiling height reported if secondary ceilometer site ceiling value is different than the ceiling height in the body of the report. |
| PRESFR | PRESSURE RISING OR FALLING RAPIDLY | PRESRR or PRESFR; pressure rising or falling rapidly at time of observation. |
| SLP125 | SEA LEVEL PRESSURE | SLPppp; sea level pressure reported for ppp in tens, units, and tenths of hPa. |
| P0003 | HOURLY PRECIPITATION AMOUNT | Prrrr; in tens, units, tenths and hundredths of an inch since last regular hourly METAR. A trace is reported as P0000.. |
| 60009 | 3- AND 6-HOUR PRECIPITATION AMOUNT | 6RRRR; precipitation amount, including water equivalent, to nearest 0.01 inches for past 6 hours reported in 00, 06, 12, and 18 UTC observations and for past 3 hours in 03, 09, 15, and 21 UTC observations. A trace is 60000. |
| T00640036 | HOURLY TEMPERATURE AND DEW POINT | TsnTaTaTa snT’aT’aT’a; reported to nearest tenth of oC; sn: 1 if temperature or dew point below 0oC and 0 if temperature/dew point 0oC or higher. |
| 10066 | 6-HOUR MAXIMUM TEMPERATURE | 1snTxTxTx; maximum temperature for past 6 hours reported to nearest tenth of degree Celsius; reported on 00, 06, 12, 18 UTC reports; sn = 1 if temperature below 0oC and 0 if temperature 0oC or higher.. |
| 21012 | 6-HOUR MINIMUM TEMPERATURE | 2snTnTnTn; minimum temperature for past 6 hours reported to nearest tenth of degree Celsius; reported on 00, 06, 12, 18 UTC reports; sn = 1 if temperature below 0oC and 0 if temperature 0oC or higher. |
| 58033 | PRESSURE TENDENCY | 5appp; the character (a) and amount of change in pressure (ppp) in tenths of hPa for the past 3 hours. |
| TSNO | SENSOR STATUS INDICATORS | RVRNO: RVR missing; PWINO: precipitation identifier information not available; PNO: precipitation amount not available; FZRANO: freezing rain information not available; TSNO: thunderstorm information not available (may indicate augmenting weather observer not logged on); VISNO [LOC} visibility at second location not available, e.g. VISNO RWY06; CHINO [LOC}: (cloud-height- indicator) sky condition at secondary location not available, e.g., CHINO RWY06. |
| $ | MAINTENANCE CHECK INDICATOR | Maintenance is needed on the system. |
If an element or phenomena does not occur, is missing, or cannot be observed, the corresponding group and space are omitted (body and/or remarks) from that particular report, except for Sea-level Pressure (SLPppp). SLPNO shall be reported in a METAR when the SLP is not available.
Example of a decoded METAR:
- METAR KBWI 031754Z 29008KT 250V320 10SM FEW023 SCT041 BKN080 BKN140 13/07 A3003 RMK AO2 SLP170 60001 T01280067 10133 20072 58002
- Report type: METAR
- Location: KBWI
- Day of month: 03
- Time: 17:54 UTC
- Wind: True direction = 290 degrees, Speed: 8 knots
- Wind direction is variable between 250 and 320
- Visibility: 10 Statute Miles
- Clouds: A few , at 2300 feet above sea level
- Clouds: Scattered , at 4100 feet above sea level
- Clouds: Broken clouds , at 8000 feet above sea level
- Clouds: Broken clouds , at 14000 feet above sea level
- Temperature: 13 degrees Celsius
- Dew point: 07 degrees Celsius
- Altimeter: 30.03 inHg


0 comments