ARM-DOE / pyart

The Python-ARM Radar Toolkit. A data model driven interactive toolkit for working with weather radar data.
https://arm-doe.github.io/pyart/
Other
516 stars 268 forks source link

Scan mode issue when reading cfradial #1481

Closed swnesbitt closed 1 year ago

swnesbitt commented 1 year ago

Description

Tried to open a cfradial 360 sweep file produced from RadxConvert (originally a DOW produced DORADE)

What I Did

Tried to produce a radar display, but it says can't deal with scan_mode of "other" in the radar object.

Looked at the cfradial file, and the sweep_mode is azimuth_surveillance which is legal according to cfradial conventions.

However, pyart.io.read is reading in sweep_mode from the cfradial as a masked array rather than a string.

 radar = pyart.io.read('/Users/snesbitt/data/DOW7-231005-cfrad/20231005/cfrad.20231005_153454.950_to_20231005_153512.742_DOW7high_SUR.nc')
radar.sweep_mode
{'long_name': 'scan_mode_for_sweep',
 'options': 'sector, coplane, rhi, vertical_pointing, idle, azimuth_surveillance, elevation_surveillance, sunscan, pointing, calibration, manual_ppi, manual_rhi, sunscan_rhi, doppler_beam_swinging, complex_trajectory, electronic_steering',
 'data': masked_array(data=[[b'a', b'z', b'i', b'm', b'u', b't', b'h', b'_', b's',
                     b'u', b'r', b'v', b'e', b'i', b'l', b'l', b'a', b'n',
                     b'c', b'e', --, --, --, --, --, --, --, --, --, --,
                     --, --]],
              mask=[[False, False, False, False, False, False, False,
                     False, False, False, False, False, False, False,
                     False, False, False, False, False, False,  True,
                      True,  True,  True,  True,  True,  True,  True,
                      True,  True,  True,  True]],
        fill_value=b'',
             dtype='|S1')}

This causes plotting routines to crash as it compares sweep_mode to a number of known strings, and upon failure of matching, sets scan_type (used in plotting routines) to "other".

swnesbitt commented 1 year ago

Manually setting radar.scan_type='ppi' as appropriate is a workaround.

mgrover1 commented 1 year ago

@swnesbitt - can you share a sample file here? I can take a look at debugging here.

mgrover1 commented 1 year ago

@swnesbitt - I think I found the culprit here. The byte-encoded string is being converted to a list... we should add a check on the dimensionality of the sweep mode array before grabbing the first element https://github.com/ARM-DOE/pyart/blob/main/pyart/io/cfradial.py#L200