A python package for parsing metar & taf raw text
Project description
pymetaf
This is a python package to parse raw METAR and TAF report text.
Installation
- Clone this repository and run
$ python setup.py installin your terminal. - Use Pip
$ pip install pymetaf
Usage
Parse METAR text
>>> from pymetaf import parse_text
>>> text = 'METAR ZYAS 250500Z 21009G14MPS 6000 NSC 18/08 Q1018 NOSIG'
>>> parse_text(text, 2021, 5)
{'kind': 'METAR',
'icao': 'ZYAS',
'datetime': '2021-05-25T05:00:00+00:00',
'wind_direction': 210,
'wind_direction_units': 'degree',
'wind_speed': 9,
'wind_speed_units': 'm/s',
'gust': 14,
'wind_direction_range': None,
'cavok': False,
'visibility': 6000,
'visibility_units': 'm',
'temperature': 18,
'dew_temperature': 8,
'temperature_units': 'degree C',
'qnh': 1018,
'qnh_units': 'hPa',
'cloud': [{'cloud_mask': 0,
'cloud_height': None,
'cloud_height_units': 'm',
'cloud_type': None}],
'weather': ['Clear Sky'],
'auto': False}
Validate METAR format
🎉 100% Detection Rate - Validated on 120,727 real-world anomalous METAR reports!
>>> from pymetaf import validate_metar
>>> # Valid METAR
>>> metar = "METAR ZBAA 311400Z 01002MPS CAVOK 14/12 Q1009 NOSIG="
>>> is_valid, error_msg = validate_metar(metar)
>>> print(is_valid)
True
>>> # Invalid METAR (wrong QNH format)
>>> metar = "METAR ZBTJ 290200Z 35009MPS CAVOK M04/M27 Q102NOSIG="
>>> is_valid, error_msg = validate_metar(metar)
>>> print(is_valid)
False
>>> print(error_msg)
Invalid QNH format: Q102NOSIG
>>> # Strict mode (no RMK allowed)
>>> metar_with_rmk = "METAR RCMQ 230900Z 25008KT 9999 FEW010 Q1009 NOSIG RMK A2982="
>>> is_valid, error_msg = validate_metar(metar_with_rmk, strict_mode=True)
>>> print(is_valid)
False
>>> print(error_msg)
RMK remarks section not allowed in strict mode
The validator can detect 30+ types of format errors including:
- Missing/invalid report type, ICAO code, time group
- Wind group errors (format, spacing, units)
- QNH format errors
- Invalid characters and line breaks
- Spelling errors (EMPO, ECMG, NOSI, OSIG, etc.)
- RMK section anomalies
- And many more...
Enjoy it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymetaf-1.1.1.tar.gz
(25.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pymetaf-1.1.1-py3-none-any.whl
(25.5 kB
view details)
File details
Details for the file pymetaf-1.1.1.tar.gz.
File metadata
- Download URL: pymetaf-1.1.1.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bff05dc2ffc32618e8b6d87c62629ba9e45b192dcbcf2b870bfdfab13603d79
|
|
| MD5 |
cc0e03be94577e1a20293a7afd7108d5
|
|
| BLAKE2b-256 |
0d8cb1524c8b1c1f0ce2611113c0029ce92641f9b5b4a15d0066dc94d67cfb6d
|
File details
Details for the file pymetaf-1.1.1-py3-none-any.whl.
File metadata
- Download URL: pymetaf-1.1.1-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89de86a756a27ecda3e133fba886c2b6afd306f35f3c9bc4fa56fd2feec03610
|
|
| MD5 |
c71468579854be9a15d1d4b3742bf872
|
|
| BLAKE2b-256 |
72884e8b038fa08d777c41620e9b517977efe2c8603c76facf199cdb2e54d629
|