From ccaf227e337386e108fe3b5a6c30a34c7edf1d8c Mon Sep 17 00:00:00 2001 From: Ryan May Date: Tue, 27 Feb 2024 14:51:02 -0700 Subject: [PATCH] BUG: Handle message 18 missing VCP info (Fixes #3413) At some point the fixed VCP info in message type 18 was converted to a spare field. This still parses fine when filled with 0's, but apparently some sites are now sending out some random bytes in this location, which can break our parser. --- src/metpy/io/nexrad.py | 17 +++++++++++------ src/metpy/static-data-manifest.txt | 1 + staticdata/KJKL_20240227_102059 | Bin 0 -> 3558 bytes tests/io/test_nexrad.py | 6 ++++++ 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 staticdata/KJKL_20240227_102059 diff --git a/src/metpy/io/nexrad.py b/src/metpy/io/nexrad.py index 9efce8f8b21..33ddb6bdbbb 100644 --- a/src/metpy/io/nexrad.py +++ b/src/metpy/io/nexrad.py @@ -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'), diff --git a/src/metpy/static-data-manifest.txt b/src/metpy/static-data-manifest.txt index dafa9ea2bd6..c08f0338959 100644 --- a/src/metpy/static-data-manifest.txt +++ b/src/metpy/static-data-manifest.txt @@ -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 diff --git a/staticdata/KJKL_20240227_102059 b/staticdata/KJKL_20240227_102059 new file mode 100644 index 0000000000000000000000000000000000000000..59dd1cce1fdfe15b6903eb74414689dda0ec356e GIT binary patch literal 3558 zcmV#IEWofN=r-t01e7QT4*^jL0KkKS-xE*1pok0 zfB*mg|NsC0|NsC0|M&0z|NsC0|9}5~|NsC0ec%88|9{{M?%kgt&>8?$DjuHqcRkHC zi`Or6YuaAo^^I_7kS3hY-MD&j- z`lqI##63?>RN7BT?Nij#Lrl~*O-7!kN2D|jH1vjpO+2TOqBLYSiM2MTsPd0cdW0a7 zV?@HAsi&!eY3c?fFq&-|nqmx%Gz|a%4H_C~0002c0MGyifEoY*0000q000025KRQi zo>Na0^zH(kupaz3MpbZ9q0077U000JnGyo4!00*dOG&BtcfQckV zku=pmOo^2JGAP1};qd*2vP!CWZkN^MxG5`QQ zKy5~V0B8UJ01yBG000000imD(000000iX>401W^D0000000000Gynhq2^2&|N$6A3 zc{M#vqehIA$)b8{HkyM?Js@eJrh$>5^)zT12AT$qG6$&8(9=PX0000q0D6Jy2Gj=|5cRpURMjqF^AMJ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