diff --git a/tests/io/test_text.py b/tests/io/test_text.py index 501a8a2450..a29e7b37d3 100644 --- a/tests/io/test_text.py +++ b/tests/io/test_text.py @@ -6,6 +6,8 @@ import numpy as np +from io import StringIO + from metpy.cbook import get_test_data from metpy.io import parse_wpc_surface_bulletin from metpy.io.text import _decode_coords @@ -64,22 +66,36 @@ def test_parse_wpc_surface_bulletin(): assert all(df.valid == datetime(2021, 6, 28, 18, 0, 0)) -def test_negative_lat_highres(): +def test_negative_lat_highres(): """Test decoding of high res coordinates with negative latitude.""" - coord = '-4920344' - lon, lat = _decode_coords(coord) - assert lon == -34.4 - assert lat == -49.2 + + from io import BytesIO + import shapely.geometry as sgeom + + sample = BytesIO(b''' +178 +ASUS02 KWBC 281800 +CODSUS + +CODED SURFACE FRONTAL POSITIONS +NWS WEATHER PREDICTION CENTER COLLEGE PARK MD +342 PM EDT MON JUN 28 2021 + +VALID 062818Z +HIGHS 1022 -3961069 1020 -3851069 1026 3750773 1022 4430845 1019 5520728 1018 +''') + df = parse_wpc_surface_bulletin(sample) + assert df.geometry[0] == sgeom.Point([-106.9, -39.6]) def test_negative_lat(): """Test decoding of coordinates with negative latitude.""" - coord_4_digit = '-2378' - lon, lat = _decode_coords(coord_4_digit) - assert lon == -78 - assert lat == -23 - - coord_5_digit = '-65134' - lon, lat = _decode_coords(coord_5_digit) - assert lon == -134 - assert lat == -65 + + from io import BytesIO + import shapely.geometry as sgeom + + sample = BytesIO(b'''12HR PROG VALID xxxxxxZ +HIGHS -351 -3985 -4046 -38117 -7510 + ''') + df = parse_wpc_surface_bulletin(sample) + assert df.geometry[0] == sgeom.Point([-51, -3])