Skip to content

Commit

Permalink
FIX: Sort elevations and fix rogue radial issue (#1170)
Browse files Browse the repository at this point in the history
* sort elevations and fix rogue radial issue

* pin pydata sphinx theme version

* add spaces back in

* add last three spaces
  • Loading branch information
mgrover1 authored Jun 10, 2022
1 parent acf7331 commit 586442a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion doc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies:
- s3fs
- pip
- pip:
- pydata-sphinx-theme
- pydata-sphinx-theme<0.9.0
- sphinx_gallery
- sphinx-copybutton
- myst_nb
Expand Down
4 changes: 2 additions & 2 deletions pyart/core/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def antenna_to_cartesian(ranges, azimuths, elevations):
Edition, 1993, p. 21.
"""
theta_e = elevations * np.pi / 180.0 # elevation angle in radians.
theta_a = azimuths * np.pi / 180.0 # azimuth angle in radians.
theta_e = np.deg2rad(elevations) # elevation angle in radians.
theta_a = np.deg2rad(azimuths) # azimuth angle in radians.
R = 6371.0 * 1000.0 * 4.0 / 3.0 # effective radius of earth in meters.
r = ranges * 1000.0 # distances to gates in meters.

Expand Down
6 changes: 3 additions & 3 deletions pyart/graph/radardisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def plot_rhi(
# check for negative values
sweep_slice = self._radar.get_slice(sweep)
az_mean = np.abs(np.mean(self._radar.azimuth['data'][sweep_slice]))
if 89.5 <= az_mean <= 90.0:
if (89.5 <= az_mean <= 90.0) or (269.5 <= az_mean <= 270.):
R = np.sqrt(x ** 2 + y ** 2) * np.sign(x)
else:
R = np.sqrt(x ** 2 + y ** 2) * np.sign(y)
Expand Down Expand Up @@ -1466,7 +1466,7 @@ def _get_data(self, field, sweep, mask_tuple, filter_transitions,
# filter out antenna transitions
if filter_transitions and self.antenna_transition is not None:
in_trans = self.antenna_transition[sweep_slice]
data = data[in_trans == 0]
data = data[in_trans != 1]

return data

Expand All @@ -1489,7 +1489,7 @@ def _get_vpt_data(self, field, mask_tuple, filter_transitions,
# filter out antenna transitions
if filter_transitions and self.antenna_transition is not None:
in_trans = self.antenna_transition
data = data[in_trans == 0]
data = data[in_trans != 1]

return data.T

Expand Down
27 changes: 20 additions & 7 deletions pyart/util/xsect.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,22 @@ def cross_section_ppi(radar, target_azimuths, az_tol=None):
"""
# determine which rays from the ppi radar make up the pseudo RHI
prhi_rays = []
valid_azimuths = []
for target_azimuth in target_azimuths:

prhi_rays = np.zeros((len(target_azimuths), radar.nsweeps))
valid_azimuths = np.zeros((len(target_azimuths), radar.nsweeps))
valid_elevations = np.zeros((len(target_azimuths), radar.nsweeps))
i = 0
for target_azimuth in sorted(target_azimuths):
j = 0
for sweep_slice in radar.iter_slice():
sweep_azimuths = radar.azimuth['data'][sweep_slice]
sweep_elevations = radar.azimuth["data"][sweep_slice]
d_az = np.abs(sweep_azimuths - target_azimuth)
if az_tol is None:
ray_number = np.argmin(d_az)
prhi_rays.append(ray_number + sweep_slice.start)
valid_azimuths.append(target_azimuth)
prhi_rays[i, j] = ray_number + sweep_slice.start
valid_azimuths[i, j] = target_azimuth
valid_elevations[i, j] = sweep_elevations[ray_number]
else:
d_az_min = np.min(d_az)
if d_az_min > az_tol:
Expand All @@ -56,13 +62,20 @@ def cross_section_ppi(radar, target_azimuths, az_tol=None):
ray_number = np.argmin(d_az)
prhi_rays.append(ray_number + sweep_slice.start)
valid_azimuths.append(target_azimuth)
valid_elevations.append(sweep_elevations[ray_number])

j+=1
i+=1

rhi_nsweeps = len(valid_azimuths)
rhi_nsweeps = len(np.unique(valid_azimuths))
if rhi_nsweeps == 0:
raise ValueError('No azimuth found within tolerance')

sorted_index = np.argsort(valid_azimuths, axis=1)
sorted_prhi_rays = list(np.ravel(np.take_along_axis(prhi_rays, sorted_index, axis=1)).astype(int))

radar_rhi = _construct_xsect_radar(
radar, 'rhi', prhi_rays, rhi_nsweeps, valid_azimuths)
radar, 'rhi', sorted_prhi_rays, rhi_nsweeps, list(np.unique(np.ravel(valid_azimuths)).astype(int)))

return radar_rhi

Expand Down

0 comments on commit 586442a

Please sign in to comment.