Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/
*.csv
*.csv

.DS_Store
2 changes: 2 additions & 0 deletions pymetaf/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = "0.1.4"

from .parser import *
12 changes: 9 additions & 3 deletions pymetaf/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ def parse_text(text, year, month):
wd = int(wd_str)

ws = int(wdws[3:5]) # wind speed

# If wind speed is 0 and wind direction is 000, this is calm wind (静风)
# In this case, wind direction should be None
if ws == 0 and wd_str == "000":
wd = None

if wdws[5] == "G":
# Example with gust: METAR ZBXH 250700Z 25008G13MPS 9999 FEW040 13/M18 Q1015 NOSIG
gust = int(wdws[6:8]) # gust
Expand Down Expand Up @@ -292,9 +298,9 @@ def parse_text(text, year, month):
visstr = get_field_text("vis", no_trend_text)
if visstr:
if visstr == "9999":
dataset[
"visibility"
] = 99999 # Represent visibility greater than 10000 as 99999
dataset["visibility"] = (
99999 # Represent visibility greater than 10000 as 99999
)
elif visstr == "0000":
dataset["visibility"] = 50
elif visstr.endswith("SM"):
Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@
with open(requirements_path) as f:
required = f.read().splitlines()

# 从 pymetaf/__init__.py 读取版本号
version = {}
with open(os.path.join(FILE_PATH, "pymetaf", "__init__.py")) as f:
for line in f:
if line.startswith("__version__"):
exec(line, version)
break

setuptools.setup(
name="pymetaf",
version="1.0.3",
version=version["__version__"],
author="Wentao Li",
author_email="wentao.li@moji.com",
author_email="clarmyleewt@outlook.com",
description="A python package for parsing metar & taf raw text",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
29 changes: 29 additions & 0 deletions tests/case/metar/parse_text_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,33 @@
"auto": False,
},
},
{
"kwargs": {
"text": "METAR ZBAA 301630Z 00000MPS CAVOK 16/16 Q1009 NOSIG=",
"year": 2025,
"month": 10,
},
"result": {
"kind": "METAR",
"icao": "ZBAA",
"auto": False,
"datetime": "2025-10-30T16:30:00+00:00",
"wind_direction": None,
"wind_direction_units": "degree",
"wind_speed": 0,
"wind_speed_units": "m/s",
"gust": None,
"wind_direction_range": None,
"cavok": True,
"visibility": 99999,
"visibility_units": "m",
"temperature": 16,
"dew_temperature": 16,
"temperature_units": "degree C",
"qnh": 1009,
"qnh_units": "hPa",
"cloud": None,
"weather": ["Clear Sky"],
},
},
]