Bruno Bord
Fun with Metar, Twitter and Python

METARs are, in case you don’t know: METeorological Airport Reports. They are very accurate and very reliable weather reports published by Airports around the world, using a quite mysterious syntax. See a real-world example:

LBBG 041600Z 12003MPS 310V290 1400 R04/P1500N
R22/P1500U +SN BKN022 OVC050 M04/M07 Q1020
NOSIG 9949//91=

This is the Wikipedia example of a report made by Burgas Airport in Burgas, Bulgaria, on the 4th of February 2005.

Anyway, if you can read them, you have a pretty good picture of the current weather in the area.

They’re freely available to everyone, publicly hosted by the NOAA. As dotwaffle suggested, it’d be nice to have a Tweet feed of METAR…

So here we are: Metar On Twitter!

This is a single Python Script that does the work for you: collecting the appropriate METAR file(s), comparing it to the latest report posted on Twitter, and if it changed, update the Twitter account status (and saving this latest on disk for later comparison).

You’ll have to configure it first - the config.py file is a simple Python script with your accounts like this

ACCOUNTS = [('AIRP', 'twitter_account', 'twitter_password'),
    ('AIR2', 'tw2', 'twp2')]

If this file does not exists in the current directory, it’ll be created (and you’ll be prompted Airport Code, twitter account name and password).

The source code is available via a simple mercurial clone command:

hg clone http://bitbucket.org/brunobord/metar-on-twitter/

There are already two Twitter accounts publishing METARs using this python script: LFBZ (Biarritz, France) and John Fitzgerald Kennedy, NY. The only thing you’ll have to do is to use a cron-like scheduler to run the script every hour, for example.

Warning! this script uses the pyCurl module, which must be installed on your machine.

Please, add yours!