Skip to main content

PyMETAR - a module to fetch and parse METAR reports

NOTE: If you're looking for information regarding Python 2 and PyMETAR, see the end of this document.

The National Oceanic and Atmospheric Administration (NOAA, http://www.noaa.gov/) provides easy access to the weather reports generated by a large number of weather stations (mostly at airports) worldwide. Those reports are called METAR reports and are delivered as plain text files that look like this:

Duesseldorf, Germany (EDDL) 51-18N 006-46E 41M
Jul 26, 2002 - 03:50 AM EST / 2002.07.26 0850 UTC
Wind: from the SW (220 degrees) at 9 MPH (8 KT):0
Visibility: 3 mile(s):0
Sky conditions: mostly cloudy
Weather: mist
Temperature: 60 F (16 C)
Dew Point: 57 F (14 C)
Relative Humidity: 87%
Pressure (altimeter): 30.00 in. Hg (1016 hPa)
ob: EDDL 260850Z 22008KT 5000 BR SCT006 BKN012 16/14 Q1016 BECMG BKN015
cycle: 9

While this is convenient if you just want to quickly look up the data, there's some effort involved in parsing all of this into a format that is digestible by a program. Plus, you have to remember the base URL of the reports and fetch the file.

This is what this library does. All you have to do is find the station you're interested in at http://www.aviationweather.gov/metar and feed the 4-letter station code to the MetarReport class.

On the user end, the library provides a large number of methods to fetch the parsed information in a plethora of formats. Those functions are described in the file librarydoc.txt which was in turn generated using PyDoc.

PyMETAR uses urllib2 (and its successors), which in turn makes it easy to honor the environment variable http_proxy. This simplifies use of a proxy tremendously. Thanks go to Davide Di Blasi for both suggesting and implementing this. The environment variable is easy to use: just set it to:

http://username:password@proxy.yourdomain.com:port 

You can also specify a proxy (with the same syntax) as an argument to the fetching function. This is sometimes easier when using PyMETAR in a web application environment (such as ZopeWeatherApplet by Jerome Alet). See librarydoc.txt for details on how to accomplish that.

You can also use IPs instead of hostnames, of course. When in doubt, ask your proxy admin.

Due to some peculiarities in the METAR format, I can not rule out the possibility that the library barfs on some less common types of reports. If you encounter such a report, please save it and the error messages you get as completely as possible and send them to me at klausman-pymetar@schwarzvogel.de --- Thanks a lot!

Of course you may send all the other bugs you encounter to me, too. As this is a Python library, chances are that you are Python programmer and can provide a patch. If you do so, please, by all means use spaces for indentation, four per level, that makes merging the patch a lot easier.

Python 2, 3, PyPy, PyPy3 and so on

This version of PyMETAR supports Python 3.x and PyPy3 only. The last version to have Python2 as its main target was v0.21.

Compatibility with PyPy (2.x), Jython and other interpreters not mentioned above is unknown.

I maintain a branch (called Python2) on git which is the state of Pymetar as it was for the last version supporting Python 2. That branch is in maintenance mode, i.e. it will only receive fixes for security issues or bugs that can be fixed without too much fuss. That branch will go away in 2020.

[0] http://python-future.org/

Release files for pymetar 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymetar 1.4
File Size Uploaded
pymetar-1.4.tar.gz 3.2 MB Details

Release files / pymetar-1.4.tar.gz

Download URL pymetar-1.4.tar.gz
Size 3.2 MB
Tags Source
SHA-256 checksum
How to use checksums
48dbe6c4929961021cb61e49bb9e0605b54c4b61b9fb9ade51076705a08ecd54
BLAKE2b-256 checksum
How to use checksums
7ef37fc74060ef2aff179b1afdd5869a304ba1e53f419370cfe0b996ecb5732a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.4 This release

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

2 release files

0.21

1 release file

0.20

1 release file

0.19

0.17

0.16

0.14

0.13

0.12

0.11

0.10

0.9

0.7

0.5

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page