Skip to content

Modern C++ library for parsing METAR weather report and TAF weather forecast

License

Notifications You must be signed in to change notification settings

nnaumenko/metaf

Repository files navigation

Modern C++ library for parsing METAR and TAF

pipeline status Codacy Badge codecov MIT license Try online

Highlights

  • Dependency-free: No external dependencies except standard C++ library.
  • Versatile: recognises large number of group types including rare and regional formats.
  • Thoroughly tested: 100% test coverage.
  • Easy to integrate: Header-only library, integrated by including a single .hpp file.
  • WASM: Metaf works in Webassembly and allows parsing METARs and TAFs on the client.

Introduction

Metaf is a header-only, dependency-free modern C++ library for parsing METAR weather reports and TAF weather forecasts used in aviation.

Live demo: Short weather summary for aerodromes near your location based on METAR/TAF weather data.

Live demo: Decode METAR or TAF report and explain in English language.

Metaf can do the following:

  • Parse METAR or TAF report and autodetect its type.
  • Check the validity of the report syntax, detect malformed reports and report errors.
  • Convert METAR or TAF groups into classes wrapped in std::variant; each of these classes represents a particular type of group coded in weather report or forecast.

Compatible compilers

The following compiler are compatible (with C++17 standard enabled):

  • webassembly / emscripten emcc 1.38.28 (based on clang)
  • gcc 7.4.0
  • clang 8.0.0

The compatibility with the compilers above is routinely tested using Gitlab CI after each commit.

Prerequisites and dependencies

Metaf requires C++17.

Metaf library itself is dependency-free and requires only standard C++ library. Boost is not used.

Unit tests included with the project use Google Test framework.

Limitations

Old TAF format, used before November 2008 employs different format for time spans and trends (time without date); the current version does not decode this old format.

License

Metaf is released under MIT license.

Documentation

Please refer to documentation for details.

Tutorial on basic usage of Metaf library.

METAR and TAF

What is METAR?

METAR is current weather report format used in aviation. Typical METAR report contains information such as location, report issue time, wind, visibility, clouds, weather phenomena, temperature, dewpoint and atmospheric pressure.

METAR in raw form is human-readable though it might look cryptic for untrained person.

Example of a simple METAR report is as follows:

METAR EICK 092100Z 23007KT 9999 FEW038 BKN180 11/08 Q1019 NOSIG=

What is TAF?

TAF (Terminal Aerodrome Forecast) is a weather forecast report format used in aviation. TAF report is quite similar to METAR and reports trends and changes in visibility, wind, clouds, weather, etc over periods of time.

TAF in raw form is also human-readable but requires training to decode.

Example of a TAF report is as follows:

TAF EICK 091700Z 0918/1018 27012KT 9999 BKN025 BECMG 0920/0923 24007KT BECMG 1002/1005 21007KT BECMG 1009/1012 21015KT TEMPO 1010/1013 -RA BKN012 TEMPO 1010/1018 21018G28KT BECMG 1013/1016 6000 -RA SCT003 BKN010 TEMPO 1014/1018 3000 -RADZ BKN003 PROB40 TEMPO 1015/1018 1200 BR BKN002=

Which groups Metaf is able to recognize?

  • Report type METAR, SPECI, and TAF
  • Various amended or correctional report indicators
  • Indicators for missing report, cancelled TAF report, and various indicator for missing data given in remarks section
  • Automated report indicator, automated station type remark, and maintenance indicator
  • ICAO location
  • Report issue time
  • Wind direction, speed and gust speed
  • Wind shear, peak wind and wind shift information
  • Prevailing or directional visibility (including variable visibility groups specified in remarks) in meters or statute miles
  • Surface visibility and visibility from air traffic control tower.
  • Cloud layer information, clear sky conditions, 'no significant cloud' / 'no cloud detected information', and detailed cloud layers information specified in remarks
  • Cloud cover of variable density and variable ceiling height
  • Indicator of no significant cloud and good visibility CAVOK
  • Indicatiors for certain secondary locations (e.g. wind shear in the lower levels at path of runway approach, ceiling, etc), and indicators for missing visibility or ceiling data.
  • Current and recent weather information, and indicator or weather phenomena end NSW
  • Beginning and ending time of recent weather phenomena
  • Temperature and dew point, including more precise values given in remarks
  • Temperature forecast from TAF reports
  • 6-hourly and 24-hourly minimum and maximum temperature
  • Current atmospheric pressure, including QNH, QFE, SLP remarks, atmospheric pressure tendency remark, and groups indicating rapid pressure rise or fall
  • Forecast lowest atmospheric pressure
  • Runway visual range with trend
  • State of runway, type and amount of deposits, extent of runway contamination, surface friction and braking action
  • Groups indicating that runway or airport is closed due to snow accumulation
  • Groups indicating that deposits on runway were cleared or ceased to exist
  • Rainfall groups used in Australia
  • Various precipitation, snowfall, and ice buildup groups reported in remarks section in North and South America
  • Temperature and state of sea surface or wave height
  • Colour codes used by NATO militaries to quickly assess visibility and cloud conditions
  • Trend groups NOSIG, BECMG, TEMPO, INTER, FMxxxxxx and various time span groups
  • Indicator of no unscheduled reports being issued by station
  • Groups indicating non-operational sensors
  • Icing and turbulence forecast used by NATO militaries
  • Recent precipitation beginning and ending time
  • Lightning data such as strike type and frequency
  • Groups reporting various phenomena in vicinity of the station (thunderstorm, towering cumulus, altocumulus castellanus, cumulonimbus, mammatus, lenticular and rotor clouds, virga, etc.)
  • Sunshine duration
  • Density altitude
  • Largest hailstone size
  • Military report issuer identifier

Performance

The following statistics were acquired by parsing all METAR and TAF reports collected during year 2020. The parsing was done using single thread and the statistics do not include IO operations' lag.

1973075048 microseconds, 76416000 reports, 38729 reports per second.
1973075048 microseconds, 916172097 groups, 464337 groups per second.

Basically, it took 33 minutes to parse all METARs and TAFs from 2020 using one CPU core on the old laptop with i5 CPU.

Roadmap

Version 6.0.0 is currently planned (no release date set), with a number of new groups to be added (the candidates are runway wind, additional sea surface groups, first/last report, next scheduled report time remarks, variable cloud cover, additional visibility groups etc).

There are also plans to change the handling of CNL keyword because some cancelled reports have additional remarks and some reports use CNL as a part of plain-text remark. Currently Metaf is unable to parse such reports.

After version 6.0.0 is released, the priority is to fix bugs, improve test coverage and documentation, and perform 'under the hood' changes such as optimisation and refactoring.

Acknowledgements

This project uses Emscripten to compile examples into Webassembly.

Unit tests included with the project use Google Test framework.

Gitlab CI/CD is used for deployment of the project website.

METAR, TAF, and weather station data used in weather summary example are from Aviation Weather Center Text Data Server.

Weather widget uses the following external content: Weather Icons by Erik Flowers distributed under SIL OFL 1.1 license, Source Sans Pro Font by Paul D. Hunt distributed under Open Font License, 'eye-regular' and 'icicles-solid' icons by Font Awesome distributed under Creative Commons Attribution 4.0 International license. METAR, TAF, and weather station data are acquired using CORS-anywhere.

The project repository is hosted on Gitlab and mirrored to Github.

Thanks to Ogimet for providing access to historical METAR and TAF data.

About

Modern C++ library for parsing METAR weather report and TAF weather forecast

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages