openradar / xradar

A tool to work in weather radar data in xarray
https://docs.openradarscience.org/projects/xradar
MIT License
85 stars 17 forks source link

BUG: Expand Sweep Fixed Mode Variables in NEXRAD Reader #161

Closed mgrover1 closed 3 months ago

mgrover1 commented 3 months ago

Description

As of now, the elevation angle, variable thresholds, etc. are condensed into an ordered dictionary in the sweep_fixed_mode data variable in the individual sweep dataset.

For example,

import xradar as xd
from open_radar_data import DATASETS

filename = "../../../../Downloads/KDMX20200810_154746_V06"
ds = xr.open_dataset(filename, group="sweep_0", engine="nexradlevel2")
print(ds.sweep_fixed_angle.values)
array(OrderedDict([('elevation_angle', 0.4833984375), ('channel_config', 2),
('waveform_type', 1), ('super_resolution', 11), ('prf_number', 1), ('prf_pulse_count', 15),
('azimuth_rate', 15400), ('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)]), dtype=object)

What we should do

We should expand this dictionary, and add these as additional variables in the xr.Variable fields in the given xr.Dataset.

What are your thoughts here @kmuehlbauer ? I think this would make it easier to then aggregate given an elevation angle, instead of opening an ordered dictionary in numpy array

kmuehlbauer commented 3 months ago

To fix this, we just need to subset with elevation_angle here: https://github.com/openradar/xradar/blob/main/xradar/io/backends/nexrad_level2.py#L1362

The OrderedDict we see here, is taken verbatim from the message 5 (vcp) for the wanted elevation.

mgrover1 commented 3 months ago

Great! I have a PR drafted up :)

mgrover1 commented 3 months ago

Should we include some of the other variables included there? (ex. prf info, etc.) or include those in the attributes? Basically pop the elevation angle out, and unpack those other parts into the attributes...

kmuehlbauer commented 3 months ago

For adding additional variables: Yes, we could add those which are defined by the standard. :+1: