Skip to content

Commit

Permalink
fix(rfi): fix edge case where bounds are empty slice.
Browse files Browse the repository at this point in the history
There is an edge case where slice(None) is passed to mad_cut_rolling
which would end up comparing slice.start (None) to a value, raising an
error. This commit tweaks the implementation to get the same behaviour
without the risk of this error.
  • Loading branch information
ljgray committed Aug 19, 2022
1 parent d4c4b30 commit 21a1974
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ch_util/rfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def number_deviations(
arr = auto_vis[:, ind].allgather() if parallel else auto_vis[:, ind]
# Use NaNs to ignore previously flagged data when computing the MAD
arr = np.where(flg, arr.real, np.nan)
local_bounds = auto_vis.local_bounds if parallel else Ellipsis
local_bounds = auto_vis.local_bounds if parallel else slice(None)
# Apply RFI flagger
if rolling:
# Limit bounds to the local portion of the array
Expand Down Expand Up @@ -568,7 +568,7 @@ def mad_cut_rolling(
threshold=5.0,
freq_flat=True,
mask=True,
limit_range: slice = Ellipsis,
limit_range: slice = slice(None),
):
"""Mask out RFI by placing a cut on the absolute deviation.
Compared to `mad_cut_2d`, this function calculates
Expand Down Expand Up @@ -622,7 +622,7 @@ def mad_cut_rolling(
exp_data = np.full(eshp, np.nan, dtype=data.dtype)
exp_data[foff : foff + nfreq, toff : toff + ntime] = data

if limit_range is not Ellipsis:
if limit_range != slice(None):
# Get only desired slice
expsl = slice(
max(limit_range.start, 0),
Expand Down

0 comments on commit 21a1974

Please sign in to comment.