METAR parsing libraries

METAR, the weather observation format, is a great little text format

KOAK 032353Z 00000KT 5SM BR SCT200 11/08 A3029 RMK AO2 SLP256 VIS SE 1 1/2

It’s also not a very standardized format, making parsing a bit of an art. Here’s a few different METAR parsing libraries I’ve found:

  1. Tom Pollard’s python-metar, (sourceforge, github). This is what I used to prepare windhistory.com and it’s pretty good.
  2. Joe Yates’ metar-parser for Ruby. Has some test coverage. Also references other Ruby implementations.
  3. METAR decoding software from NWS. The closest thing to official code, written by Eric McCarthy, now on SourceForge. It’s 12,000+ lines of C code (!), albeit with a lot of comments, unit tests, etc. Has some interesting code for interpreting the meaning of METARs, like whether it codes for a tornado or the like.

There’s lots of other parsers for various languages: PHP, .NET, etc.