Skip to content

Commit

Permalink
Add break to outlier rejection iterations if mask is unchanged.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed May 17, 2023
1 parent 161a02f commit 1f8ca46
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/lsst/cp/pipe/ptc/cpSolvePtcTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ def errFunc(p, x, y):
newMask = (mask & (meanVecOriginal <= self.config.maxSignalInitialPtcOutlierFit))

count = 0
lastMask = mask.copy()
while count < maxIterationsPtcOutliers:
res = least_squares(
errFunc,
Expand Down Expand Up @@ -1055,6 +1056,13 @@ def errFunc(p, x, y):
ampName,
)

# If the mask hasn't changed then break out.
if np.all(newMask == lastMask):
self.log.debug("Convergence at iteration %d; breaking loop for %s.", count, ampName)
break

lastMask = newMask.copy()

count += 1

# Set the mask to the new mask
Expand Down

0 comments on commit 1f8ca46

Please sign in to comment.