Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: consistent sweep determination for RHI at 0 degrees azimuth #1541

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pyart/util/radar_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ def to_vpt(radar, single_scan=True):
return


def determine_sweeps(radar, max_offset=0.1, running_win_dt=5.0, deg_rng=(-5.0, 360.0)):
def determine_sweeps(
radar,
max_offset=0.1,
running_win_dt=5.0,
deg_rng=(-5.0, 360.0),
consider_2pi_jump=True,
):
"""
Determine the number of sweeps using elevation data (PPI scans) or azimuth
data (RHI scans) and update the input radar object
Expand All @@ -128,13 +134,19 @@ def determine_sweeps(radar, max_offset=0.1, running_win_dt=5.0, deg_rng=(-5.0, 3
given that there could be ppi scan strategies at negative elevations,
one might consider a negative values (current default), or , for example,
-180 to 180 if the azimuth range goes from -180 to 180.
consider_2pi_jump: bool
if True and radar scan type is 'rhi', overwriting deg_rng to (0., 360.), and
merging the first and last azimuth bins (to have shots just below 360 and
just above 0 to be considered part of the same sweep).

"""
# set fixed and variable coordinates depending on scan type
# ======================
if "rhi" in radar.scan_type.lower():
var_array = radar.elevation["data"]
fix_array = radar.azimuth["data"]
if consider_2pi_jump:
deg_rng = (0.0, 360.0)
else: # ppi or vpt
var_array = radar.azimuth["data"]
fix_array = radar.elevation["data"]
Expand Down Expand Up @@ -164,6 +176,9 @@ def determine_sweeps(radar, max_offset=0.1, running_win_dt=5.0, deg_rng=(-5.0, 3
t += 1
continue
bincounts, _ = np.histogram(fix_win, bins=angle_bins)
if ("rhi" in radar.scan_type.lower()) & consider_2pi_jump:
bincounts[0] += bincounts[-1]
bincounts = bincounts[:-1]
moving_radar = np.sum(bincounts > 0) > 1 # radar transition to a new sweep
if in_sweep:
if t == radar.time["data"].size - win_size:
Expand Down