Skip to content

Commit

Permalink
Merge pull request #547 from lsst/tickets/DM-30959
Browse files Browse the repository at this point in the history
DM-30959: Prevent maskStreaks failure due to unmasked nans or infs
  • Loading branch information
cmsaunders committed Jul 1, 2021
2 parents c411b24 + 66c4f91 commit 77f2033
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/lsst/pipe/tasks/maskStreaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ def line_search(c, dx):
chi2, b, A = self._lineChi2(line)
if chi2 == 0:
break
if not np.isfinite(A).all():
# TODO: DM-30797 Add warning here.
fitFailure = True
break
dChi2 = oldChi2 - chi2
cholesky = scipy.linalg.cho_factor(A)
dx = scipy.linalg.cho_solve(cholesky, b)
Expand Down Expand Up @@ -708,6 +712,8 @@ def _fitProfile(self, lines, maskedImage):
"""
data = maskedImage.image.array
weights = maskedImage.variance.array**-1
# Mask out any pixels with non-finite weights
weights[~np.isfinite(weights) | ~np.isfinite(data)] = 0

lineFits = LineCollection([], [])
finalLineMasks = [np.zeros(data.shape, dtype=bool)]
Expand Down

0 comments on commit 77f2033

Please sign in to comment.