Skip to main content

PyPI version Build Status Coverage Status Codecov Status

Python-Metar

Python-metar is a python package for interpreting METAR and SPECI coded weather reports.

METAR and SPECI are coded aviation weather reports. The official coding schemes are specified in the World Meteorological Organization (WMO) Manual on Codes, vol I.1, Part A (WMO-306 I.i.A). US conventions for METAR/SPECI reports vary in a number of ways from the international standard, and are described in chapter 12 of the Federal Meteorological Handbook No.1. (FMH-1 1995), issued by the National Oceanic and Atmospheric Administration (NOAA). General information about the use and history of the METAR standard can be found here.

This module extracts the data recorded in the main-body groups of reports that follow the WMO spec or the US conventions, except for the runway state and trend groups, which are parsed but ignored. The most useful remark groups defined in the US spec are parsed, as well, such as the cumulative precipitation, min/max temperature, peak wind and sea-level pressure groups. No other regional conventions are formally supported, but a large number of variant formats found in international reports are accepted.

Current METAR reports

Current and historical METAR data can be obtained from various places. The current METAR report for a given airport is available at the URL

https://tgftp.nws.noaa.gov/data/observations/metar/stations/<station>.TXT

where station is the four-letter ICAO airport station code. The accompanying script get_report.py will download and decode the current report for any specified station.

The METAR reports for all stations (worldwide) for any "cycle" (i.e., hour) in the last 24 hours are available in a single file at the URL

https://tgftp.nws.noaa.gov/data/observations/metar/cycles/<cycle>Z.TXT

where cycle is a 2-digit cycle number (00 thru 23).

METAR specifications

The Federal Meteorological Handbook No.1. (FMC-H1-2017) describes the U.S. standards for METAR. The World Meteorological Organization (WMO) Manual on Codes, vol I.1, Part A (WMO-306 I.i.A) is another good reference.

Author

The metar library was orignally authored by Tom Pollard in January 2005, and is now maintained by contributors on Github.

Installation

Install this package in the usual way,

python -m pip install .

# to install test packages
python -m pip install '.[test]'

The test suite can be run by:

pytest

There are a couple of sample scripts, described briefly below.

There's no real documentation to speak of, yet, but feel free to contact me with any questions you might have about how to use this package.

Current sources

You can always obtain the most recent version of this package using git, via

git clone https://github.com/python-metar/python-metar.git

Contents

File Description
README this file
parse_metar.py a simple commandline driver for the METAR parser
get_report.py a script to download and decode the current reports for one or more stations.
sample.py a simple script showing how the decoded data can be accessed. (see metar/.py sources and the test/test_.py scripts for more examples.)
sample.metar a sample METAR report (longer than most). Try feeding this to the parse_metar.py script...
metar/Metar.py the implementation of the Metar class. This class parses and represents a single METAR report.
metar/Datatypes.py a support module that defines classes representing different types of meteorological data, including temperature, pressure, speed, distance, direction and position.
test/test_*.py individual test modules
setup.py installation script

Example

obs.runway retains its four-element records (name, low, high, units). obs.runway_tendencies has one entry for each of those records, in the same order: "U" for increasing, "D" for decreasing, "N" for no distinct tendency, or None when no unambiguous tendency was reported. These describe the reported past tendency; no trend is inferred from the range values. obs.runway_visual_range() includes the tendency when available.

See the sample.py script for an annonated demonstration of the use of this code. Just as an appetizer, here's an interactive example...

>>> from metar import Metar
>>> obs = Metar.Metar('METAR KEWR 111851Z VRB03G19KT 2SM R04R/3000VP6000FT TSRA BR FEW015 BKN040CB BKN065 OVC200 22/22 A2987 RMK AO2 PK WND 29028/1817 WSHFT 1812 TSB05RAB22 SLP114 FRQ LTGICCCCG TS OHD AND NW -N-E MOV NE P0013 T02270215')
>>> print obs.string()
station: KEWR
type: routine report, cycle 19 (automatic report)
time: Tue Jan 11 18:51:00 2005
temperature: 22.7 C
dew point: 21.5 C
wind: variable at 3 knots, gusting to 19 knots
peak wind: WNW at 28 knots
visibility: 2 miles
visual range: runway 04R: 3000 meters to greater than 6000 meters feet
pressure: 1011.5 hPa
weather: thunderstorm with rain; mist
sky: a few clouds at 1500 feet
     broken cumulonimbus at 4000 feet
     broken clouds at 6500 feet
     overcast at 20000 feet
sea-level pressure: 1011.4 hPa
1-hour precipitation: 0.13in
remarks:
- Automated station (type 2)
- peak wind 28kt from 290 degrees at 18:17
- wind shift at 18:12
- frequent lightning (intracloud,cloud-to-cloud,cloud-to-ground)
- thunderstorm overhead and NW
- TSB05RAB22 -N-E MOV NE
METAR: METAR KEWR 111851Z VRB03G19KT 2SM R04R/3000VP6000FT TSRA BR FEW015 BKN040CB BKN065 OVC200 22/22 A2987 RMK AO2 PK WND 29028/1817 WSHFT 1812 TSB05RAB22 SLP114 FRQ LTGICCCCG TS OHD AND NW -N-E MOV NE P0013 T02270215
>>>>

Tests

The library is tested against Python 3.11-3.15.

A tox configuration file is included to easily run tests against each of these environments. To run tests against all environments, install tox and run:

>>> tox

To run against a specific environment, use the -e flag:

>>> tox -e py310

Metadata

Release files for metar 2.0.2

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

Source distribution (sdist)

Source distribution for metar 2.0.2
File Size Uploaded Provenance Actions
metar-2.0.2.tar.gz 2.6 MB With provenance Details for metar-2.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for metar 2.0.2
File Interpreter ABI Platform Actions
metar-2.0.2-py3-none-any.whl Python 3 none any Details for metar-2.0.2-py3-none-any.whl

Total release size: 2.8 MB

Release files / metar-2.0.2.tar.gz

Download URL metar-2.0.2.tar.gz
Size 2.6 MB
Tags Source
SHA-256 checksum
How to use checksums
8cf3b11906ead3103255964faf06905b50ddbd508d7c0d924d2ef8000bf82b80
BLAKE2b-256 checksum
How to use checksums
80c708229ed74c8d11b963968438f8e17cc8e6c26738fbcbc63627ac043829d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / metar-2.0.2-py3-none-any.whl

Download URL metar-2.0.2-py3-none-any.whl
Size 205.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4aeef585333f116eb035b5712985da59a0566924b7a196814e27c60214f8283
BLAKE2b-256 checksum
How to use checksums
3a1749f505ea6bd7b0638e060269b9cef1653bdd7bc0c6428c205d71177431d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for metar 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for metar-2.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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