diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa5c782c..29b2a604 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,7 +114,7 @@ jobs: python -c "import xradar; print(xradar.version.version)" - name: Test with pytest run: | - pytest -n auto --dist loadfile --verbose --durations=15 --cov-report xml:coverage_notebook.xml --cov=xradar --pyargs examples/notebooks + pytest -n auto --dist loadscope --verbose --durations=15 --cov-report xml:coverage_notebook.xml --cov=xradar --pyargs examples/notebooks - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: diff --git a/tests/conftest.py b/tests/conftest.py index e1b1778c..834f3d3e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -93,6 +93,6 @@ def nexradlevel2_bzfile(): return DATASETS.fetch("KLBB20160601_150025_V06") -@pytest.fixture +@pytest.fixture(scope="session") def nexradlevel2_files(request): return request.getfixturevalue(request.param) diff --git a/tests/io/test_datamet.py b/tests/io/test_datamet.py index 5b1838af..52bc6ee4 100644 --- a/tests/io/test_datamet.py +++ b/tests/io/test_datamet.py @@ -6,13 +6,11 @@ from xradar.util import _get_data_file -@pytest.fixture +@pytest.fixture(scope="session") def data(datamet_file): with _get_data_file(datamet_file, "file") as datametfile: - print(datametfile) data = datamet.DataMetFile(datametfile) assert data.filename == datametfile - print(data.scan_metadata) data.get_sweep(0) return data diff --git a/tests/io/test_hpl.py b/tests/io/test_hpl.py index f5925f3a..0857b688 100644 --- a/tests/io/test_hpl.py +++ b/tests/io/test_hpl.py @@ -16,11 +16,11 @@ def test_open_datatree_hpl(): def test_open_dataset_hpl(): - ds = xr.open_dataset( + with xr.open_dataset( DATASETS.fetch("User1_184_20240601_013257.hpl"), engine="hpl", backend_kwargs=dict(latitude=41.24276244459537, longitude=-70.1070364814594), - ) + ) as ds: - assert ds["mean_doppler_velocity"].dims == ("azimuth", "range") - assert ds["mean_doppler_velocity"].max() == 19.5306 + assert ds["mean_doppler_velocity"].dims == ("azimuth", "range") + assert ds["mean_doppler_velocity"].max() == 19.5306 diff --git a/tests/io/test_io.py b/tests/io/test_io.py index 37a6234a..400b69d2 100644 --- a/tests/io/test_io.py +++ b/tests/io/test_io.py @@ -87,19 +87,19 @@ def test_open_cfradial1_datatree(cfradial1_file): def test_open_cfradial1_dataset(cfradial1_file): # open first sweep group - ds = xr.open_dataset(cfradial1_file, group="sweep_0", engine="cfradial1") - assert list(ds.dims) == ["azimuth", "range"] - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"DBZ", "VR"} - assert ds.sweep_number == 0 - # open last sweep group - ds = xr.open_dataset(cfradial1_file, group="sweep_8", engine="cfradial1") - assert list(ds.dims) == ["azimuth", "range"] - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"DBZ", "VR"} - assert ds.sweep_number == 8 + with xr.open_dataset(cfradial1_file, group="sweep_0", engine="cfradial1") as ds: + assert list(ds.dims) == ["azimuth", "range"] + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"DBZ", "VR"} + assert ds.sweep_number == 0 + # open last sweep group + with xr.open_dataset(cfradial1_file, group="sweep_8", engine="cfradial1") as ds: + assert list(ds.dims) == ["azimuth", "range"] + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"DBZ", "VR"} + assert ds.sweep_number == 8 @pytest.mark.parametrize("sweep", ["sweep_0", 0, [0, 1], ["sweep_0", "sweep_1"]]) @@ -191,33 +191,33 @@ def test_open_odim_datatree(odim_file): @pytest.mark.parametrize("fix_second_angle", [False, True]) def test_open_odim_dataset(odim_file, first_dim, fix_second_angle): # open first sweep group - ds = xr.open_dataset( + with xr.open_dataset( odim_file, group="sweep_0", engine="odim", first_dim=first_dim, fix_second_angle=fix_second_angle, - ) - dim0 = "time" if first_dim == "time" else "azimuth" - assert dict(ds.sizes) == {dim0: 360, "range": 1200} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"WRADH", "VRADH", "PHIDP", "DBZH", "RHOHV", "KDP", "TH", "ZDR"} - assert ds.sweep_number == 0 + ) as ds: + dim0 = "time" if first_dim == "time" else "azimuth" + assert dict(ds.sizes) == {dim0: 360, "range": 1200} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"WRADH", "VRADH", "PHIDP", "DBZH", "RHOHV", "KDP", "TH", "ZDR"} + assert ds.sweep_number == 0 # open last sweep group - ds = xr.open_dataset( + with xr.open_dataset( odim_file, group="sweep_11", engine="odim", first_dim=first_dim, fix_second_angle=fix_second_angle, - ) - assert dict(ds.sizes) == {dim0: 360, "range": 280} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"VRADH", "KDP", "WRADH", "TH", "RHOHV", "PHIDP", "ZDR", "DBZH"} - assert ds.sweep_number == 11 + ) as ds: + assert dict(ds.sizes) == {dim0: 360, "range": 280} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"VRADH", "KDP", "WRADH", "TH", "RHOHV", "PHIDP", "ZDR", "DBZH"} + assert ds.sweep_number == 11 def test_open_odim_dataset_stream(odim_file): @@ -344,70 +344,72 @@ def test_open_gamic_datatree(gamic_file): @pytest.mark.parametrize("fix_second_angle", [False, True]) def test_open_gamic_dataset(gamic_file, first_dim, fix_second_angle): # open first sweep group - ds = xr.open_dataset( + with xr.open_dataset( gamic_file, group="sweep_0", engine="gamic", first_dim=first_dim, fix_second_angle=fix_second_angle, - ) - dim0 = "time" if first_dim == "time" else "azimuth" - assert dict(ds.sizes) == {dim0: 361, "range": 360} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "WRADH", - "WRADV", - "VRADH", - "VRADV", - "PHIDP", - "DBTH", - "DBTV", - "DBZH", - "DBZV", - "RHOHV", - "KDP", - "ZDR", - } - assert ds.sweep_number == 0 + ) as ds: + dim0 = "time" if first_dim == "time" else "azimuth" + assert dict(ds.sizes) == {dim0: 361, "range": 360} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "WRADH", + "WRADV", + "VRADH", + "VRADV", + "PHIDP", + "DBTH", + "DBTV", + "DBZH", + "DBZV", + "RHOHV", + "KDP", + "ZDR", + } + assert ds.sweep_number == 0 # open last sweep group - ds = xr.open_dataset( + with xr.open_dataset( gamic_file, group="sweep_9", engine="gamic", first_dim=first_dim, fix_second_angle=fix_second_angle, - ) - assert dict(ds.sizes) == {dim0: 360, "range": 1000} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "WRADH", - "WRADV", - "VRADH", - "VRADV", - "PHIDP", - "DBTH", - "DBTV", - "DBZH", - "DBZV", - "RHOHV", - "KDP", - "ZDR", - } - assert ds.sweep_number == 9 + ) as ds: + assert dict(ds.sizes) == {dim0: 360, "range": 1000} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "WRADH", + "WRADV", + "VRADH", + "VRADV", + "PHIDP", + "DBTH", + "DBTV", + "DBZH", + "DBZV", + "RHOHV", + "KDP", + "ZDR", + } + assert ds.sweep_number == 9 def test_open_gamic_dataset_stream(gamic_file): with open(gamic_file, mode="rb") as fhandle: contents = io.BytesIO(fhandle.read()) - xr.open_dataset(contents, group="sweep_9", engine="gamic") + with xr.open_dataset(contents, group="sweep_9", engine="gamic") as ds: + print(ds) def test_open_gamic_dataset_fsspec(gamic_file): with fsspec.open(gamic_file, mode="rb") as fhandle: - xr.open_dataset(fhandle, group="sweep_9", engine="gamic") + with xr.open_dataset(fhandle, group="sweep_9", engine="gamic") as ds: + print(ds) def test_open_gamic_store(gamic_file): @@ -421,65 +423,83 @@ def test_open_gamic_store(gamic_file): def test_open_gamic_dataset_reindex(gamic_file): # open first sweep group reindex_angle = dict(start_angle=0, stop_angle=360, angle_res=1.0, direction=1) - ds = xr.open_dataset( + with xr.open_dataset( gamic_file, group="sweep_0", engine="gamic", reindex_angle=reindex_angle - ) - assert dict(ds.sizes) == {"azimuth": 360, "range": 360} + ) as ds: + assert dict(ds.sizes) == {"azimuth": 360, "range": 360} def test_open_furuno_scn_dataset(furuno_scn_file): # open sweep group - ds = xr.open_dataset(furuno_scn_file, first_dim="time", engine="furuno") - assert dict(ds.sizes) == {"time": 1376, "range": 602} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"KDP", "VRADH", "ZDR", "DBZH", "WRADH", "RHOHV", "PHIDP"} - for key, value in ds.data_vars.items(): - if key in ["RATE", "KDP", "VRADH", "ZDR", "DBZH", "WRADH", "RHOHV", "PHIDP"]: - assert value.encoding["_FillValue"] == 0.0 - elif key in ["azimuth", "elevation"]: - assert value.encoding["_FillValue"] == np.ma.minimum_fill_value( - value.encoding["dtype"] - ) - else: - assert value.encoding.get("_FillValue", None) is None - assert ds.sweep_number == 0 + with xr.open_dataset(furuno_scn_file, first_dim="time", engine="furuno") as ds: + assert dict(ds.sizes) == {"time": 1376, "range": 602} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"KDP", "VRADH", "ZDR", "DBZH", "WRADH", "RHOHV", "PHIDP"} + for key, value in ds.data_vars.items(): + if key in [ + "RATE", + "KDP", + "VRADH", + "ZDR", + "DBZH", + "WRADH", + "RHOHV", + "PHIDP", + ]: + assert value.encoding["_FillValue"] == 0.0 + elif key in ["azimuth", "elevation"]: + assert value.encoding["_FillValue"] == np.ma.minimum_fill_value( + value.encoding["dtype"] + ) + else: + assert value.encoding.get("_FillValue", None) is None + assert ds.sweep_number == 0 # open sweep group, auto - ds = xr.open_dataset( + with xr.open_dataset( furuno_scn_file, engine="furuno", - ) - assert dict(ds.sizes) == {"azimuth": 1376, "range": 602} - assert ds.sweep_number == 0 + ) as ds: + assert dict(ds.sizes) == {"azimuth": 1376, "range": 602} + assert ds.sweep_number == 0 def test_open_furuno_scnx_dataset(furuno_scnx_file): # open sweep group - ds = xr.open_dataset(furuno_scnx_file, first_dim="time", engine="furuno") - assert dict(ds.sizes) == {"time": 722, "range": 936} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"KDP", "VRADH", "ZDR", "DBZH", "WRADH", "RHOHV", "PHIDP"} - - for key, value in ds.data_vars.items(): - if key in ["RATE", "KDP", "VRADH", "ZDR", "DBZH", "WRADH", "RHOHV", "PHIDP"]: - assert value.encoding["_FillValue"] == 0.0 - elif key in ["azimuth", "elevation"]: - assert value.encoding["_FillValue"] == np.ma.minimum_fill_value( - value.encoding["dtype"] - ) - else: - assert value.encoding.get("_FillValue", None) is None - assert ds.sweep_number == 0 + with xr.open_dataset(furuno_scnx_file, first_dim="time", engine="furuno") as ds: + assert dict(ds.sizes) == {"time": 722, "range": 936} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"KDP", "VRADH", "ZDR", "DBZH", "WRADH", "RHOHV", "PHIDP"} + + for key, value in ds.data_vars.items(): + if key in [ + "RATE", + "KDP", + "VRADH", + "ZDR", + "DBZH", + "WRADH", + "RHOHV", + "PHIDP", + ]: + assert value.encoding["_FillValue"] == 0.0 + elif key in ["azimuth", "elevation"]: + assert value.encoding["_FillValue"] == np.ma.minimum_fill_value( + value.encoding["dtype"] + ) + else: + assert value.encoding.get("_FillValue", None) is None + assert ds.sweep_number == 0 # open sweep group, auto - ds = xr.open_dataset( + with xr.open_dataset( furuno_scnx_file, engine="furuno", - ) - assert dict(ds.sizes) == {"azimuth": 722, "range": 936} - assert ds.sweep_number == 0 + ) as ds: + assert dict(ds.sizes) == {"azimuth": 722, "range": 936} + assert ds.sweep_number == 0 def test_open_rainbow_datatree(rainbow_file): @@ -546,34 +566,34 @@ def test_open_rainbow_datatree(rainbow_file): def test_open_rainbow_dataset(rainbow_file): # open first sweep group - ds = xr.open_dataset(rainbow_file, group="sweep_0", engine="rainbow") - assert dict(ds.sizes) == {"azimuth": 361, "range": 400} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "DBZH", - } - assert ds.sweep_number == 0 + with xr.open_dataset(rainbow_file, group="sweep_0", engine="rainbow") as ds: + assert dict(ds.sizes) == {"azimuth": 361, "range": 400} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "DBZH", + } + assert ds.sweep_number == 0 # open last sweep group - ds = xr.open_dataset(rainbow_file, group="sweep_13", engine="rainbow") - assert dict(ds.sizes) == {"azimuth": 361, "range": 400} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "DBZH", - } - assert ds.sweep_number == 13 + with xr.open_dataset(rainbow_file, group="sweep_13", engine="rainbow") as ds: + assert dict(ds.sizes) == {"azimuth": 361, "range": 400} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "DBZH", + } + assert ds.sweep_number == 13 # open last sweep group, auto - ds = xr.open_dataset( + with xr.open_dataset( rainbow_file, group="sweep_13", engine="rainbow", backend_kwargs=dict(first_dim="time"), - ) - assert dict(ds.sizes) == {"time": 361, "range": 400} - assert ds.sweep_number == 13 + ) as ds: + assert dict(ds.sizes) == {"time": 361, "range": 400} + assert ds.sweep_number == 13 def test_open_iris_datatree(iris0_file): @@ -644,73 +664,73 @@ def test_open_iris_datatree(iris0_file): def test_open_iris0_dataset(iris0_file): # open first sweep group - ds = xr.open_dataset(iris0_file, group="sweep_0", engine="iris") - assert dict(ds.sizes) == {"azimuth": 360, "range": 664} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "DBZH", - "VRADH", - "KDP", - "RHOHV", - "PHIDP", - "ZDR", - } - assert ds.sweep_number == 0 + with xr.open_dataset(iris0_file, group="sweep_0", engine="iris") as ds: + assert dict(ds.sizes) == {"azimuth": 360, "range": 664} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "DBZH", + "VRADH", + "KDP", + "RHOHV", + "PHIDP", + "ZDR", + } + assert ds.sweep_number == 0 # open last sweep group - ds = xr.open_dataset(iris0_file, group="sweep_9", engine="iris") - assert dict(ds.sizes) == {"azimuth": 360, "range": 664} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "DBZH", - "VRADH", - "KDP", - "RHOHV", - "PHIDP", - "ZDR", - } - assert ds.sweep_number == 9 + with xr.open_dataset(iris0_file, group="sweep_9", engine="iris") as ds: + assert dict(ds.sizes) == {"azimuth": 360, "range": 664} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "DBZH", + "VRADH", + "KDP", + "RHOHV", + "PHIDP", + "ZDR", + } + assert ds.sweep_number == 9 # open last sweep group, auto - ds = xr.open_dataset( + with xr.open_dataset( iris0_file, group="sweep_9", engine="iris", backend_kwargs=dict(first_dim="time"), - ) - assert dict(ds.sizes) == {"time": 360, "range": 664} - assert ds.sweep_number == 9 + ) as ds: + assert dict(ds.sizes) == {"time": 360, "range": 664} + assert ds.sweep_number == 9 def test_open_iris1_dataset(iris1_file): # open first and only sweep group - ds = xr.open_dataset(iris1_file, group="sweep_0", engine="iris") - assert dict(ds.sizes) == {"azimuth": 359, "range": 833} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == { - "DBZH", - "KDP", - "DBTH", - "PHIDP", - "ZDR", - "RHOHV", - "VRADH", - "WRADH", - } - assert ds.sweep_number == 0 + with xr.open_dataset(iris1_file, group="sweep_0", engine="iris") as ds: + assert dict(ds.sizes) == {"azimuth": 359, "range": 833} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == { + "DBZH", + "KDP", + "DBTH", + "PHIDP", + "ZDR", + "RHOHV", + "VRADH", + "WRADH", + } + assert ds.sweep_number == 0 # open first and only sweep group - ds = xr.open_dataset( + with xr.open_dataset( iris1_file, group="sweep_0", engine="iris", backend_kwargs=dict(first_dim="time"), - ) - assert dict(ds.sizes) == {"time": 359, "range": 833} - assert ds.sweep_number == 0 + ) as ds: + assert dict(ds.sizes) == {"time": 359, "range": 833} + assert ds.sweep_number == 0 @pytest.mark.parametrize( @@ -796,41 +816,41 @@ def test_write_odim_source(rainbow_file2): def test_open_datamet_dataset(datamet_file): # open first sweep group - ds = xr.open_dataset( + with xr.open_dataset( datamet_file, group="sweep_0", engine="datamet", - ) - assert dict(ds.sizes) == {"azimuth": 360, "range": 493} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"DBTH", "DBZH", "KDP", "PHIDP", "RHOHV", "VRADH", "WRADH", "ZDR"} - assert ds.sweep_number == 0 + ) as ds: + assert dict(ds.sizes) == {"azimuth": 360, "range": 493} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"DBTH", "DBZH", "KDP", "PHIDP", "RHOHV", "VRADH", "WRADH", "ZDR"} + assert ds.sweep_number == 0 # open last sweep group - ds = xr.open_dataset( + with xr.open_dataset( datamet_file, group="sweep_10", engine="datamet", - ) - assert dict(ds.sizes) == {"azimuth": 360, "range": 1332} - assert set(ds.data_vars) & ( - sweep_dataset_vars | non_standard_sweep_dataset_vars - ) == {"DBTH", "DBZH", "KDP", "PHIDP", "RHOHV", "VRADH", "WRADH", "ZDR"} - assert ds.sweep_number == 10 + ) as ds: + assert dict(ds.sizes) == {"azimuth": 360, "range": 1332} + assert set(ds.data_vars) & ( + sweep_dataset_vars | non_standard_sweep_dataset_vars + ) == {"DBTH", "DBZH", "KDP", "PHIDP", "RHOHV", "VRADH", "WRADH", "ZDR"} + assert ds.sweep_number == 10 def test_open_datamet_dataset_reindex(datamet_file): # open first sweep group reindex_angle = dict(start_angle=0, stop_angle=360, angle_res=2.0, direction=1) - ds = xr.open_dataset( + with xr.open_dataset( datamet_file, group="sweep_10", engine="datamet", decode_coords=True, reindex_angle=reindex_angle, - ) - assert dict(ds.sizes) == {"azimuth": 180, "range": 1332} + ) as ds: + assert dict(ds.sizes) == {"azimuth": 180, "range": 1332} def test_open_datamet_datatree(datamet_file): diff --git a/tests/io/test_nexrad_level2.py b/tests/io/test_nexrad_level2.py index f46842a7..ec5b9e5f 100644 --- a/tests/io/test_nexrad_level2.py +++ b/tests/io/test_nexrad_level2.py @@ -6,33 +6,15 @@ from collections import OrderedDict -import numpy as np import pytest import xarray from xradar.io.backends.nexrad_level2 import ( NexradLevel2BackendEntrypoint, NEXRADLevel2File, - open_nexradlevel2_datatree, ) -@pytest.mark.parametrize( - "nexradlevel2_files", ["nexradlevel2_gzfile", "nexradlevel2_bzfile"], indirect=True -) -def test_open_nexradlevel2_datatree(nexradlevel2_files): - dtree = open_nexradlevel2_datatree(nexradlevel2_files) - ds = dtree["sweep_0"].ds - assert ds.attrs["instrument_name"] == "KLBB" - assert ds["time"].min() == np.array( - "2016-06-01T15:00:25.232000000", dtype="datetime64[ns]" - ) - assert ds["DBZH"].shape == (720, 1832) - assert ds["DBZH"].dims == ("azimuth", "range") - assert int(ds.sweep_number.values) == 0 - np.testing.assert_almost_equal(ds.sweep_fixed_angle.values, 0.4833984) - - @pytest.mark.parametrize( "nexradlevel2_files", ["nexradlevel2_gzfile", "nexradlevel2_bzfile"], indirect=True ) @@ -42,398 +24,398 @@ def test_open_nexrad_level2_backend(nexradlevel2_files): sweeps = [f"sweep_{i}" for i in range(nsweeps)] assert nsweeps == 11 for i, group in enumerate(sweeps): - ds = xarray.open_dataset( + with xarray.open_dataset( nexradlevel2_files, engine=NexradLevel2BackendEntrypoint, group=group - ) - assert ds.attrs["instrument_name"] == "KLBB" - assert int(ds.sweep_number.values) == i + ) as ds: + assert ds.attrs["instrument_name"] == "KLBB" + assert int(ds.sweep_number.values) == i @pytest.mark.parametrize( "nexradlevel2_files", ["nexradlevel2_gzfile", "nexradlevel2_bzfile"], indirect=True ) def test_open_nexradlevel2_file(nexradlevel2_files): - fh = NEXRADLevel2File(nexradlevel2_files) + with NEXRADLevel2File(nexradlevel2_files) as fh: - # volume header - assert fh.volume_header["tape"] == b"AR2V0006." - assert fh.volume_header["extension"] == b"736" - assert fh.volume_header["date"] == 977403904 - assert fh.volume_header["time"] == 274675715 - assert fh.volume_header["icao"] == b"KLBB" + # volume header + assert fh.volume_header["tape"] == b"AR2V0006." + assert fh.volume_header["extension"] == b"736" + assert fh.volume_header["date"] == 977403904 + assert fh.volume_header["time"] == 274675715 + assert fh.volume_header["icao"] == b"KLBB" - # meta_header 15 - assert len(fh.meta_header["msg_15"]) == 5 - assert fh.meta_header["msg_15"][0]["size"] == 1208 - assert fh.meta_header["msg_15"][0]["channels"] == 8 - assert fh.meta_header["msg_15"][0]["type"] == 15 - assert fh.meta_header["msg_15"][0]["seq_id"] == 5 - assert fh.meta_header["msg_15"][0]["date"] == 16940 - assert fh.meta_header["msg_15"][0]["ms"] == 65175863 - assert fh.meta_header["msg_15"][0]["segments"] == 5 - assert fh.meta_header["msg_15"][0]["seg_num"] == 1 - assert fh.meta_header["msg_15"][0]["record_number"] == 0 - # meta_header 13 - assert len(fh.meta_header["msg_13"]) == 49 - assert fh.meta_header["msg_13"][0]["size"] == 1208 - assert fh.meta_header["msg_13"][0]["channels"] == 8 - assert fh.meta_header["msg_13"][0]["type"] == 13 - assert fh.meta_header["msg_13"][0]["seq_id"] == 15690 - assert fh.meta_header["msg_13"][0]["date"] == 16954 - assert fh.meta_header["msg_13"][0]["ms"] == 54016980 - assert fh.meta_header["msg_13"][0]["segments"] == 49 - assert fh.meta_header["msg_13"][0]["seg_num"] == 1 - assert fh.meta_header["msg_13"][0]["record_number"] == 77 - # meta header 18 - assert len(fh.meta_header["msg_18"]) == 4 - assert fh.meta_header["msg_18"][0]["size"] == 1208 - assert fh.meta_header["msg_18"][0]["channels"] == 8 - assert fh.meta_header["msg_18"][0]["type"] == 18 - assert fh.meta_header["msg_18"][0]["seq_id"] == 6 - assert fh.meta_header["msg_18"][0]["date"] == 16940 - assert fh.meta_header["msg_18"][0]["ms"] == 65175864 - assert fh.meta_header["msg_18"][0]["segments"] == 4 - assert fh.meta_header["msg_18"][0]["seg_num"] == 1 - assert fh.meta_header["msg_18"][0]["record_number"] == 126 - # meta header 3 - assert len(fh.meta_header["msg_3"]) == 1 - assert fh.meta_header["msg_3"][0]["size"] == 488 - assert fh.meta_header["msg_3"][0]["channels"] == 8 - assert fh.meta_header["msg_3"][0]["type"] == 3 - assert fh.meta_header["msg_3"][0]["seq_id"] == 15694 - assert fh.meta_header["msg_3"][0]["date"] == 16954 - assert fh.meta_header["msg_3"][0]["ms"] == 54025336 - assert fh.meta_header["msg_3"][0]["segments"] == 1 - assert fh.meta_header["msg_3"][0]["seg_num"] == 1 - assert fh.meta_header["msg_3"][0]["record_number"] == 131 - # meta header 5 - assert len(fh.meta_header["msg_5"]) == 1 - assert fh.meta_header["msg_5"][0]["size"] == 272 - assert fh.meta_header["msg_5"][0]["channels"] == 8 - assert fh.meta_header["msg_5"][0]["type"] == 5 - assert fh.meta_header["msg_5"][0]["seq_id"] == 15695 - assert fh.meta_header["msg_5"][0]["date"] == 16954 - assert fh.meta_header["msg_5"][0]["ms"] == 54025336 - assert fh.meta_header["msg_5"][0]["segments"] == 1 - assert fh.meta_header["msg_5"][0]["seg_num"] == 1 - assert fh.meta_header["msg_5"][0]["record_number"] == 132 - assert fh.msg_5 == OrderedDict( - [ - ("message_size", 264), - ("pattern_type", 2), - ("pattern_number", 21), - ("number_elevation_cuts", 11), - ("clutter_map_group_number", 1), - ("doppler_velocity_resolution", 2), - ("pulse_width", 2), - ( - "elevation_data", - [ - OrderedDict( - [ - ("elevation_angle", 0.4833984375), - ("channel_config", 0), - ("waveform_type", 1), - ("super_resolution", 11), - ("prf_number", 1), - ("prf_pulse_count", 28), - ("azimuth_rate", 8256), - ("ref_thresh", 16), - ("vel_thresh", 16), - ("sw_thresh", 16), - ("zdr_thres", 16), - ("phi_thres", 16), - ("rho_thres", 16), - ("edge_angle_1", 0), - ("dop_prf_num_1", 0), - ("dop_prf_pulse_count_1", 0), - ("edge_angle_2", 0), - ("dop_prf_num_2", 0), - ("dop_prf_pulse_count_2", 0), - ("edge_angle_3", 0), - ("dop_prf_num_3", 0), - ("dop_prf_pulse_count_3", 0), - ] - ), - OrderedDict( - [ - ("elevation_angle", 0.4833984375), - ("channel_config", 0), - ("waveform_type", 2), - ("super_resolution", 7), - ("prf_number", 0), - ("prf_pulse_count", 0), - ("azimuth_rate", 8272), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 4), - ("dop_prf_pulse_count_1", 75), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 4), - ("dop_prf_pulse_count_2", 75), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 4), - ("dop_prf_pulse_count_3", 75), - ] - ), - OrderedDict( - [ - ("elevation_angle", 1.4501953125), - ("channel_config", 0), - ("waveform_type", 1), - ("super_resolution", 11), - ("prf_number", 1), - ("prf_pulse_count", 28), - ("azimuth_rate", 8256), - ("ref_thresh", 16), - ("vel_thresh", 16), - ("sw_thresh", 16), - ("zdr_thres", 16), - ("phi_thres", 16), - ("rho_thres", 16), - ("edge_angle_1", 0), - ("dop_prf_num_1", 0), - ("dop_prf_pulse_count_1", 0), - ("edge_angle_2", 0), - ("dop_prf_num_2", 0), - ("dop_prf_pulse_count_2", 0), - ("edge_angle_3", 0), - ("dop_prf_num_3", 0), - ("dop_prf_pulse_count_3", 0), - ] - ), - OrderedDict( - [ - ("elevation_angle", 1.4501953125), - ("channel_config", 0), - ("waveform_type", 2), - ("super_resolution", 7), - ("prf_number", 0), - ("prf_pulse_count", 0), - ("azimuth_rate", 8272), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 4), - ("dop_prf_pulse_count_1", 75), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 4), - ("dop_prf_pulse_count_2", 75), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 4), - ("dop_prf_pulse_count_3", 75), - ] - ), - OrderedDict( - [ - ("elevation_angle", 2.4169921875), - ("channel_config", 0), - ("waveform_type", 4), - ("super_resolution", 14), - ("prf_number", 2), - ("prf_pulse_count", 8), - ("azimuth_rate", 8144), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 4), - ("dop_prf_pulse_count_1", 59), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 4), - ("dop_prf_pulse_count_2", 59), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 4), - ("dop_prf_pulse_count_3", 59), - ] - ), - OrderedDict( - [ - ("elevation_angle", 3.3837890625), - ("channel_config", 0), - ("waveform_type", 4), - ("super_resolution", 14), - ("prf_number", 2), - ("prf_pulse_count", 8), - ("azimuth_rate", 8144), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 4), - ("dop_prf_pulse_count_1", 59), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 4), - ("dop_prf_pulse_count_2", 59), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 4), - ("dop_prf_pulse_count_3", 59), - ] - ), - OrderedDict( - [ - ("elevation_angle", 4.306640625), - ("channel_config", 0), - ("waveform_type", 4), - ("super_resolution", 14), - ("prf_number", 2), - ("prf_pulse_count", 8), - ("azimuth_rate", 8144), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 4), - ("dop_prf_pulse_count_1", 59), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 4), - ("dop_prf_pulse_count_2", 59), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 4), - ("dop_prf_pulse_count_3", 59), - ] - ), - OrderedDict( - [ - ("elevation_angle", 6.0205078125), - ("channel_config", 0), - ("waveform_type", 4), - ("super_resolution", 14), - ("prf_number", 3), - ("prf_pulse_count", 12), - ("azimuth_rate", 8144), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 4), - ("dop_prf_pulse_count_1", 59), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 4), - ("dop_prf_pulse_count_2", 59), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 4), - ("dop_prf_pulse_count_3", 59), - ] - ), - OrderedDict( - [ - ("elevation_angle", 9.8876953125), - ("channel_config", 0), - ("waveform_type", 3), - ("super_resolution", 10), - ("prf_number", 0), - ("prf_pulse_count", 0), - ("azimuth_rate", 10384), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 7), - ("dop_prf_pulse_count_1", 82), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 7), - ("dop_prf_pulse_count_2", 82), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 7), - ("dop_prf_pulse_count_3", 82), - ] - ), - OrderedDict( - [ - ("elevation_angle", 14.58984375), - ("channel_config", 0), - ("waveform_type", 3), - ("super_resolution", 10), - ("prf_number", 0), - ("prf_pulse_count", 0), - ("azimuth_rate", 10432), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 7), - ("dop_prf_pulse_count_1", 82), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 7), - ("dop_prf_pulse_count_2", 82), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 7), - ("dop_prf_pulse_count_3", 82), - ] - ), - OrderedDict( - [ - ("elevation_angle", 19.51171875), - ("channel_config", 0), - ("waveform_type", 3), - ("super_resolution", 10), - ("prf_number", 0), - ("prf_pulse_count", 0), - ("azimuth_rate", 10496), - ("ref_thresh", 28), - ("vel_thresh", 28), - ("sw_thresh", 28), - ("zdr_thres", 28), - ("phi_thres", 28), - ("rho_thres", 28), - ("edge_angle_1", 5464), - ("dop_prf_num_1", 7), - ("dop_prf_pulse_count_1", 82), - ("edge_angle_2", 38232), - ("dop_prf_num_2", 7), - ("dop_prf_pulse_count_2", 82), - ("edge_angle_3", 60984), - ("dop_prf_num_3", 7), - ("dop_prf_pulse_count_3", 82), - ] - ), - ], - ), - ] - ) + # meta_header 15 + assert len(fh.meta_header["msg_15"]) == 5 + assert fh.meta_header["msg_15"][0]["size"] == 1208 + assert fh.meta_header["msg_15"][0]["channels"] == 8 + assert fh.meta_header["msg_15"][0]["type"] == 15 + assert fh.meta_header["msg_15"][0]["seq_id"] == 5 + assert fh.meta_header["msg_15"][0]["date"] == 16940 + assert fh.meta_header["msg_15"][0]["ms"] == 65175863 + assert fh.meta_header["msg_15"][0]["segments"] == 5 + assert fh.meta_header["msg_15"][0]["seg_num"] == 1 + assert fh.meta_header["msg_15"][0]["record_number"] == 0 + # meta_header 13 + assert len(fh.meta_header["msg_13"]) == 49 + assert fh.meta_header["msg_13"][0]["size"] == 1208 + assert fh.meta_header["msg_13"][0]["channels"] == 8 + assert fh.meta_header["msg_13"][0]["type"] == 13 + assert fh.meta_header["msg_13"][0]["seq_id"] == 15690 + assert fh.meta_header["msg_13"][0]["date"] == 16954 + assert fh.meta_header["msg_13"][0]["ms"] == 54016980 + assert fh.meta_header["msg_13"][0]["segments"] == 49 + assert fh.meta_header["msg_13"][0]["seg_num"] == 1 + assert fh.meta_header["msg_13"][0]["record_number"] == 77 + # meta header 18 + assert len(fh.meta_header["msg_18"]) == 4 + assert fh.meta_header["msg_18"][0]["size"] == 1208 + assert fh.meta_header["msg_18"][0]["channels"] == 8 + assert fh.meta_header["msg_18"][0]["type"] == 18 + assert fh.meta_header["msg_18"][0]["seq_id"] == 6 + assert fh.meta_header["msg_18"][0]["date"] == 16940 + assert fh.meta_header["msg_18"][0]["ms"] == 65175864 + assert fh.meta_header["msg_18"][0]["segments"] == 4 + assert fh.meta_header["msg_18"][0]["seg_num"] == 1 + assert fh.meta_header["msg_18"][0]["record_number"] == 126 + # meta header 3 + assert len(fh.meta_header["msg_3"]) == 1 + assert fh.meta_header["msg_3"][0]["size"] == 488 + assert fh.meta_header["msg_3"][0]["channels"] == 8 + assert fh.meta_header["msg_3"][0]["type"] == 3 + assert fh.meta_header["msg_3"][0]["seq_id"] == 15694 + assert fh.meta_header["msg_3"][0]["date"] == 16954 + assert fh.meta_header["msg_3"][0]["ms"] == 54025336 + assert fh.meta_header["msg_3"][0]["segments"] == 1 + assert fh.meta_header["msg_3"][0]["seg_num"] == 1 + assert fh.meta_header["msg_3"][0]["record_number"] == 131 + # meta header 5 + assert len(fh.meta_header["msg_5"]) == 1 + assert fh.meta_header["msg_5"][0]["size"] == 272 + assert fh.meta_header["msg_5"][0]["channels"] == 8 + assert fh.meta_header["msg_5"][0]["type"] == 5 + assert fh.meta_header["msg_5"][0]["seq_id"] == 15695 + assert fh.meta_header["msg_5"][0]["date"] == 16954 + assert fh.meta_header["msg_5"][0]["ms"] == 54025336 + assert fh.meta_header["msg_5"][0]["segments"] == 1 + assert fh.meta_header["msg_5"][0]["seg_num"] == 1 + assert fh.meta_header["msg_5"][0]["record_number"] == 132 + assert fh.msg_5 == OrderedDict( + [ + ("message_size", 264), + ("pattern_type", 2), + ("pattern_number", 21), + ("number_elevation_cuts", 11), + ("clutter_map_group_number", 1), + ("doppler_velocity_resolution", 2), + ("pulse_width", 2), + ( + "elevation_data", + [ + OrderedDict( + [ + ("elevation_angle", 0.4833984375), + ("channel_config", 0), + ("waveform_type", 1), + ("super_resolution", 11), + ("prf_number", 1), + ("prf_pulse_count", 28), + ("azimuth_rate", 8256), + ("ref_thresh", 16), + ("vel_thresh", 16), + ("sw_thresh", 16), + ("zdr_thres", 16), + ("phi_thres", 16), + ("rho_thres", 16), + ("edge_angle_1", 0), + ("dop_prf_num_1", 0), + ("dop_prf_pulse_count_1", 0), + ("edge_angle_2", 0), + ("dop_prf_num_2", 0), + ("dop_prf_pulse_count_2", 0), + ("edge_angle_3", 0), + ("dop_prf_num_3", 0), + ("dop_prf_pulse_count_3", 0), + ] + ), + OrderedDict( + [ + ("elevation_angle", 0.4833984375), + ("channel_config", 0), + ("waveform_type", 2), + ("super_resolution", 7), + ("prf_number", 0), + ("prf_pulse_count", 0), + ("azimuth_rate", 8272), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 4), + ("dop_prf_pulse_count_1", 75), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 4), + ("dop_prf_pulse_count_2", 75), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 4), + ("dop_prf_pulse_count_3", 75), + ] + ), + OrderedDict( + [ + ("elevation_angle", 1.4501953125), + ("channel_config", 0), + ("waveform_type", 1), + ("super_resolution", 11), + ("prf_number", 1), + ("prf_pulse_count", 28), + ("azimuth_rate", 8256), + ("ref_thresh", 16), + ("vel_thresh", 16), + ("sw_thresh", 16), + ("zdr_thres", 16), + ("phi_thres", 16), + ("rho_thres", 16), + ("edge_angle_1", 0), + ("dop_prf_num_1", 0), + ("dop_prf_pulse_count_1", 0), + ("edge_angle_2", 0), + ("dop_prf_num_2", 0), + ("dop_prf_pulse_count_2", 0), + ("edge_angle_3", 0), + ("dop_prf_num_3", 0), + ("dop_prf_pulse_count_3", 0), + ] + ), + OrderedDict( + [ + ("elevation_angle", 1.4501953125), + ("channel_config", 0), + ("waveform_type", 2), + ("super_resolution", 7), + ("prf_number", 0), + ("prf_pulse_count", 0), + ("azimuth_rate", 8272), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 4), + ("dop_prf_pulse_count_1", 75), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 4), + ("dop_prf_pulse_count_2", 75), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 4), + ("dop_prf_pulse_count_3", 75), + ] + ), + OrderedDict( + [ + ("elevation_angle", 2.4169921875), + ("channel_config", 0), + ("waveform_type", 4), + ("super_resolution", 14), + ("prf_number", 2), + ("prf_pulse_count", 8), + ("azimuth_rate", 8144), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 4), + ("dop_prf_pulse_count_1", 59), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 4), + ("dop_prf_pulse_count_2", 59), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 4), + ("dop_prf_pulse_count_3", 59), + ] + ), + OrderedDict( + [ + ("elevation_angle", 3.3837890625), + ("channel_config", 0), + ("waveform_type", 4), + ("super_resolution", 14), + ("prf_number", 2), + ("prf_pulse_count", 8), + ("azimuth_rate", 8144), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 4), + ("dop_prf_pulse_count_1", 59), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 4), + ("dop_prf_pulse_count_2", 59), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 4), + ("dop_prf_pulse_count_3", 59), + ] + ), + OrderedDict( + [ + ("elevation_angle", 4.306640625), + ("channel_config", 0), + ("waveform_type", 4), + ("super_resolution", 14), + ("prf_number", 2), + ("prf_pulse_count", 8), + ("azimuth_rate", 8144), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 4), + ("dop_prf_pulse_count_1", 59), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 4), + ("dop_prf_pulse_count_2", 59), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 4), + ("dop_prf_pulse_count_3", 59), + ] + ), + OrderedDict( + [ + ("elevation_angle", 6.0205078125), + ("channel_config", 0), + ("waveform_type", 4), + ("super_resolution", 14), + ("prf_number", 3), + ("prf_pulse_count", 12), + ("azimuth_rate", 8144), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 4), + ("dop_prf_pulse_count_1", 59), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 4), + ("dop_prf_pulse_count_2", 59), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 4), + ("dop_prf_pulse_count_3", 59), + ] + ), + OrderedDict( + [ + ("elevation_angle", 9.8876953125), + ("channel_config", 0), + ("waveform_type", 3), + ("super_resolution", 10), + ("prf_number", 0), + ("prf_pulse_count", 0), + ("azimuth_rate", 10384), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 7), + ("dop_prf_pulse_count_1", 82), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 7), + ("dop_prf_pulse_count_2", 82), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 7), + ("dop_prf_pulse_count_3", 82), + ] + ), + OrderedDict( + [ + ("elevation_angle", 14.58984375), + ("channel_config", 0), + ("waveform_type", 3), + ("super_resolution", 10), + ("prf_number", 0), + ("prf_pulse_count", 0), + ("azimuth_rate", 10432), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 7), + ("dop_prf_pulse_count_1", 82), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 7), + ("dop_prf_pulse_count_2", 82), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 7), + ("dop_prf_pulse_count_3", 82), + ] + ), + OrderedDict( + [ + ("elevation_angle", 19.51171875), + ("channel_config", 0), + ("waveform_type", 3), + ("super_resolution", 10), + ("prf_number", 0), + ("prf_pulse_count", 0), + ("azimuth_rate", 10496), + ("ref_thresh", 28), + ("vel_thresh", 28), + ("sw_thresh", 28), + ("zdr_thres", 28), + ("phi_thres", 28), + ("rho_thres", 28), + ("edge_angle_1", 5464), + ("dop_prf_num_1", 7), + ("dop_prf_pulse_count_1", 82), + ("edge_angle_2", 38232), + ("dop_prf_num_2", 7), + ("dop_prf_pulse_count_2", 82), + ("edge_angle_3", 60984), + ("dop_prf_num_3", 7), + ("dop_prf_pulse_count_3", 82), + ] + ), + ], + ), + ] + ) - # meta header 2 - assert len(fh.meta_header["msg_2"]) == 1 - assert fh.meta_header["msg_2"][0]["size"] == 48 - assert fh.meta_header["msg_2"][0]["channels"] == 8 - assert fh.meta_header["msg_2"][0]["type"] == 2 - assert fh.meta_header["msg_2"][0]["seq_id"] == 15693 - assert fh.meta_header["msg_2"][0]["date"] == 16954 - assert fh.meta_header["msg_2"][0]["ms"] == 54025336 - assert fh.meta_header["msg_2"][0]["segments"] == 1 - assert fh.meta_header["msg_2"][0]["seg_num"] == 1 - assert fh.meta_header["msg_2"][0]["record_number"] == 133 + # meta header 2 + assert len(fh.meta_header["msg_2"]) == 1 + assert fh.meta_header["msg_2"][0]["size"] == 48 + assert fh.meta_header["msg_2"][0]["channels"] == 8 + assert fh.meta_header["msg_2"][0]["type"] == 2 + assert fh.meta_header["msg_2"][0]["seq_id"] == 15693 + assert fh.meta_header["msg_2"][0]["date"] == 16954 + assert fh.meta_header["msg_2"][0]["ms"] == 54025336 + assert fh.meta_header["msg_2"][0]["segments"] == 1 + assert fh.meta_header["msg_2"][0]["seg_num"] == 1 + assert fh.meta_header["msg_2"][0]["record_number"] == 133 - # data header - assert len(fh.data_header) == 5400 - msg_31_header_length = [720, 720, 720, 720, 360, 360, 360, 360, 360, 360, 360] - for i, head in enumerate(fh.msg_31_header): - assert len(head) == msg_31_header_length[i] + # data header + assert len(fh.data_header) == 5400 + msg_31_header_length = [720, 720, 720, 720, 360, 360, 360, 360, 360, 360, 360] + for i, head in enumerate(fh.msg_31_header): + assert len(head) == msg_31_header_length[i] diff --git a/tests/test_model.py b/tests/test_model.py index ceb7613a..d0b10a97 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -121,7 +121,7 @@ def test_get_sweep_dataarray(): assert da.dims == ("time", "range") assert np.unique(da) == [42.0] attrs = da.attrs - attrs["standard_name"] == "radar_equivalent_reflectivity_factor_h" - attrs["long_name"] == "Equivalent reflectivity factor H" - attrs["short_name"] == "DBZH" - attrs["units"] == "dBZ" + assert attrs["standard_name"] == "radar_equivalent_reflectivity_factor_h" + assert attrs["long_name"] == "Equivalent reflectivity factor H" + assert attrs["short_name"] == "DBZH" + assert attrs["units"] == "dBZ"