avwx

Parse aviation weather reports https://www.hcesperer.org/posts/2016-09-20-avwx.html

Version on this page:0.3.0.2
LTS Haskell 9.9:0.3.0.2
Stackage Nightly 2017-10-13:0.3.0.2
Latest on Hackage:0.3.0.2
MIT licensed and maintained by Hans-Christian Esperer

Module documentation for 0.3.0.2

Build Status

avwx

Fetch and parse aviation weather reports.

METARs and TAFs are quite well parseable; however, they were designed primarily to be easily read by humans, not machines. Subtle differences between countries (and even between weather stations) and lack of comprehensive documentation make it very difficult to create a reliable parser. This is subject to ongoing testing. Patches and success reports are most welcome!

Important: "For educational purposes only, not for flight planning! Use at your own risk."

Example session

 ~> metar --metar edny
Parsing "METAR EDNY 220820Z 02005KT 5000 BR SCT008 OVC010 10/09 Q1022"
METAR
  { _metardate = Date { _dayOfMonth = 22 , _hour = 8 , _minute = 20 }
  , _station = ICAO "EDNY"
  , _flags = []
  , _metarwind =
      Just
        Wind
          { _winddirection = Just (Degrees 20)
          , _velocity = Just (Knots 5)
          , _gusts = Nothing
          }
  , _metarvisibility = [ SpecificVisibility (Metres 5000) Nothing ]
  , _runwayvis = []
  , _runwaycond = []
  , _wx =
      [ Phenomenon
          { _intensity = Moderate
          , _desc = Nothing
          , _prec = Nothing
          , _obfus = Just Mist
          , _other = Nothing
          }
      ]
  , _clouds =
      [ ObservedCloud SCT (Height 800) Unclassified
      , ObservedCloud OVC (Height 1000) Unclassified
      ]
  , _metarpressure = Just (QNH 1022)
  , _temperature = Just 10
  , _dewPoint = Just 9
  , _weathertrend = NOTAVAIL
  , _remark = Nothing
  , _maintenance = False
  }

~> metar --taf edny
Parsing "TAF        AMD EDNY 220900Z 2209/2306 24005KT 6000 BKN010        BECMG 2209/2211 SCT020"
Right
  TAF
    { _tafissuedat =
        Date { _dayOfMonth = 22 , _hour = 9 , _minute = 0 }
    , _flags = [ AMD ]
    , _station = ICAO "EDNY"
    , _tafvalidfrom =
        Date { _dayOfMonth = 22 , _hour = 9 , _minute = 0 }
    , _tafvaliduntil =
        Date { _dayOfMonth = 23 , _hour = 6 , _minute = 0 }
    , _tafinitialconditions =
        [ TransWind
            Wind
              { _winddirection = Just (Degrees 240)
              , _velocity = Just (Knots 5)
              , _gusts = Nothing
              }
        , TransVis [ SpecificVisibility (KM 6) Nothing ]
        , TransRunwayVis []
        , TransWX []
        , TransClouds [ ObservedCloud BKN (Height 1000) Unclassified ]
        , TransPressure []
        ]
    , _tafchanges =
        [ BECMG
            (Just Date { _dayOfMonth = 22 , _hour = 9 , _minute = 0 })
            (Just Date { _dayOfMonth = 22 , _hour = 11 , _minute = 0 })
            [ TransClouds [ ObservedCloud SCT (Height 2000) Unclassified ] ]
        ]
    }

Changes

0.3.0.2

  • Fix a TAF parsing bug

0.3.0.0

  • Parse TAFs
  • More tests

0.2.0.0

Many improvements by Tony Morris:

  • Turn on GHC warnings
  • The parser uses hackage/parsers library, so a user can choose the parser implementation e.g. attoparsec, parsec.
  • A METAR optionally ends in $ or = instead of necessarily.
  • Added a field to Weather for ending in $ (meaning the station requires maintenance).
  • Added classy lenses to the data types.
  • Updated the new noaa.gov METAR publication website for fetching.
  • Moved parseWeather over to the Fetcher module so the parser does not ever import attoparsec.
  • Make Station a newtype.

Jun 28 2016

  • First release.
comments powered byDisqus