diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index e1dad6f..bbb9b25 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -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 diff --git a/.gitignore b/.gitignore index 58e4756..f847725 100644 --- a/.gitignore +++ b/.gitignore @@ -127,4 +127,6 @@ dmypy.json # Pyre type checker .pyre/ -*.csv \ No newline at end of file +*.csv + +.DS_Store \ No newline at end of file diff --git a/pymetaf/__init__.py b/pymetaf/__init__.py index bd753cc..6e838a7 100644 --- a/pymetaf/__init__.py +++ b/pymetaf/__init__.py @@ -1 +1,3 @@ +__version__ = "0.1.4" + from .parser import * diff --git a/pymetaf/parser.py b/pymetaf/parser.py index 97c000f..012f595 100644 --- a/pymetaf/parser.py +++ b/pymetaf/parser.py @@ -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 @@ -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"): diff --git a/setup.py b/setup.py index ff06190..4186d1e 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/tests/case/metar/parse_text_case.py b/tests/case/metar/parse_text_case.py index 38c6ae1..7dd44f4 100644 --- a/tests/case/metar/parse_text_case.py +++ b/tests/case/metar/parse_text_case.py @@ -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"], + }, + }, ]