Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle NEXRAD message 18 missing VCP info #3415

Merged
merged 1 commit into from
Feb 28, 2024
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
17 changes: 11 additions & 6 deletions src/metpy/io/nexrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,17 @@ def _decode_msg18(self, msg_hdr):
attr = f'VCPAT{num}'
dat = self.rda[attr]
vcp_hdr = self.vcp_fmt.unpack_from(dat, 0)
off = self.vcp_fmt.size
els = []
for _ in range(vcp_hdr.num_el_cuts):
els.append(self.vcp_el_fmt.unpack_from(dat, off))
off += self.vcp_el_fmt.size
self.rda[attr] = vcp_hdr._replace(els=els)
# At some point these got changed to spares, so only try to parse the rest if
# it looks like the right data.
if vcp_hdr.num == num and 0 < 2 * vcp_hdr.size_hw <= len(dat):
off = self.vcp_fmt.size
els = []
for _ in range(vcp_hdr.num_el_cuts):
els.append(self.vcp_el_fmt.unpack_from(dat, off))
off += self.vcp_el_fmt.size
self.rda[attr] = vcp_hdr._replace(els=els)
else: # Otherwise this is just spare and we should dump
self.rda.pop(attr)

msg31_data_hdr_fmt = NamedStruct([('stid', '4s'), ('time_ms', 'L'),
('date', 'H'), ('az_num', 'H'),
Expand Down
1 change: 1 addition & 0 deletions src/metpy/static-data-manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GFS_global.nc feae73f72340ee9e8b04fca92f182638a99316ad7262152809b7ccb9b6691e10
GFS_test.nc b69ae13179428667f6bc14dada1d5f9af4d3737b2b76a79a6001664e1525df3c
HI-REGIONAL_4km_3.9_20160616_1715.gini 30896dda51c9f933027d8086f0a86543efce12ea90a52981eccbce2e0ce1529e
KICX_20170712_1458 94bd4f795832f056f7489a5562acf76de9a9cab1694549562cc3154abb22527c
KJKL_20240227_102059 9344358cb53f2f9449b5a984d40a7dee8048fe6ecbb7fe219ab2420f8ee18776
KLTX20050329_100015.gz cad6ad8df707ad63c9ddb7306de869186241dd821517daf21ae0a80f4ce0a58d
KTLX19990503_235621.gz 7a097251bb7a15dbcdec75812812e41a86c5eb9850f55c3d91d120c2c61e046e
KTLX20130520_201643_V06.gz 772e01b154a5c966982a6d0aa2fc78bc64f08a9b77165b74dc02d7aa5aa69275
Expand Down
Binary file added staticdata/KJKL_20240227_102059
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/io/test_nexrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def test_msg15():
assert f.clutter_filter_map['datetime'] == datetime(2013, 5, 19, 5, 15, 0, 0)


def test_msg18_novcps():
"""Check handling of message type 18 with VCP info now spares does not crash."""
f = Level2File(get_test_data('KJKL_20240227_102059', as_file_obj=False))
Dismissed Show dismissed Hide dismissed
assert 'VCPAT11' not in f.rda


def test_single_chunk(caplog):
"""Check that Level2File copes with reading a file containing a single chunk."""
# Need to override the test level set above
Expand Down