Skip to content

Commit

Permalink
Fix only find the maximum jump
Browse files Browse the repository at this point in the history
Add missing while loop, that iteratively find jumps.
  • Loading branch information
Bai-Chiang committed Oct 11, 2024
1 parent 517f00b commit 85d0cb0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/toast/ops/simple_jumpcorrect.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,25 @@ def _find_peaks(self, toi, flag, flag_out, lim=3.0, tol=1e4, sigma_in=None):
amplitude = mytoi[imax]
significance = np.abs(amplitude) / sigma

# Mask the peak for taking mean and finding additional peaks
# mask out the vicinity not to have false detections near the peak
istart = max(0, imax - tol)
istop = min(len(mytoi), imax + tol)
# mask out the vicinity not to have false detections near the peak
mytoi[istart:istop] = np.ma.masked
flag_out[istart:istop] = True
if sigma_in is None:
sigma = self._get_sigma(mytoi, flag_out, tol)
break

# Excessive flagging is a sign of false detection
if significance > 5 or (
float(np.sum(flag[istart:istop])) / (istop - istart) < 0.5
float(np.sum(flag_out[istart:istop])) / (istop - istart) < 0.5
):
peaks.append((imax, significance, amplitude))

npeak = np.sum(np.abs(mytoi) > sigma * lim)
# Find additional peaks
if sigma_in is None:
sigma = self._get_sigma(mytoi, flag_out, tol)
if np.isnan(sigma) or sigma == 0:
npeak = 0
else:
npeak = np.ma.sum(np.abs(mytoi) > sigma * lim)

return peaks

def _get_sigma(self, toi, flag, tol):
Expand Down

0 comments on commit 85d0cb0

Please sign in to comment.