METAR TAF Parser (mivek)
raw JSON → 1.11.0 verified Fri May 01 auth: no python
A Python library for parsing METAR and TAF aviation weather messages. Version 1.11.0 supports runway visual range units and operates on Python >=3.9. The library parses raw METAR/TAF strings into structured model objects with weather phenomena, clouds, wind, visibility, etc. Released on PyPI as metar-taf-parser-mivek, with a development cadence of approximately 2-3 releases per year.
pip install metar-taf-parser-mivek Common errors
error AttributeError: 'NoneType' object has no attribute 'speed' ↓
cause Accessing wind attributes when wind is None (e.g., on TAF without wind or when parsing fails).
fix
Check if metar.wind is not None before accessing .speed or .direction.
error metar_taf_parser.model.metar.Metar object has no attribute 'wind_speed' ↓
cause Using old attribute names from earlier versions; model attributes changed to nested objects.
fix
Use metar.wind.speed, metar.wind.direction instead of flat attributes.
error ImportError: cannot import name 'TafParser' from 'metar_taf_parser' ↓
cause TafParser is not in the top-level module; must import from parser submodule.
fix
from metar_taf_parser.parser.taf import TafParser
error ValueError: No METAR found ↓
cause Parser expects strict METAR format; extra whitespace or invalid prefix causes failure.
fix
Ensure raw string starts with a valid ICAO code and does not have leading/trailing garbage. Trim whitespace and validate format.
Warnings
gotcha The parser raises ValueError or ParseException on malformed input; always wrap in try/except. ↓
fix Wrap parser.parse() in try/except Exception.
gotcha Wind direction is 0 when variable or calm; do not assume 0 means north. ↓
fix Check metar.wind.direction is not None or use metar.wind.unit. For variable wind, direction returns 0 with variable flag.
gotcha Cloud height is in feet; visibility may be in meters or statute miles, check unit field. ↓
fix Always confirm unit property (e.g., metar.visibility.unit) before interpreting values.
deprecated In v1.8.0, the top-level __init__.py exports were reduced; importing from 'metar_taf_parser' directly may break in future versions. ↓
fix Use explicit submodule imports (e.g., from metar_taf_parser.parser.metar import MetarParser).
Imports
- MetarParser
from metar_taf_parser.parser.metar import MetarParser - TafParser wrong
from metar_taf_parser import TafParsercorrectfrom metar_taf_parser.parser.taf import TafParser - Metar
from metar_taf_parser.model.metar import Metar - Wind
from metar_taf_parser.model.metar import Wind
Quickstart
from metar_taf_parser.parser.metar import MetarParser
raw = "LFPG 251300Z AUTO 23012KT 9999 -RA SCT025 BKN035 12/10 Q1015 NOSIG"
parser = MetarParser()
try:
metar = parser.parse(raw)
print(metar.wind.speed, metar.wind.direction)
# 12 230
except Exception as e:
print(f"Parse error: {e}")