Skip to content

Commit 8c964b9

Browse files
committed
BUG: Fix value mapper for DPR product
One of the threshold blocks had a value of 65535, which got interpreted as -1--thus breaking our construction of the lookup table.
1 parent b9e854a commit 8c964b9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/metpy/io/nexrad.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,11 @@ class GenericDigitalMapper(DataMapper):
915915

916916
def __init__(self, prod):
917917
"""Initialize the mapper by pulling out all the information from the product."""
918+
# Need to treat this value as unsigned, so we can use the full 16-bit range. This
919+
# is necessary at least for the DPR product, otherwise it has a value of -1.
920+
max_data_val = prod.thresholds[5] & 0xFFFF
921+
918922
# Values will be [0, max] inclusive, so need to add 1 to max value to get proper size.
919-
max_data_val = prod.thresholds[5]
920923
super().__init__(max_data_val + 1)
921924

922925
scale = float32(prod.thresholds[0], prod.thresholds[1])

tests/io/test_nexrad.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@ def test_level3_files(fname):
138138
if hasattr(f, 'sym_block'):
139139
block = f.sym_block[0][0]
140140
if 'data' in block:
141-
f.map_data(block['data'])
141+
data = block['data']
142+
# Looks for radials in the XDR generic products
143+
elif 'components' in block and hasattr(block['components'], 'radials'):
144+
data = np.array([rad.data for rad in block['components'].radials])
145+
else:
146+
data = []
147+
f.map_data(data)
142148

143149
assert f.filename == fname
144150

0 commit comments

Comments
 (0)