From c45265319ba2f458c59d21a1a119857e5bfefead Mon Sep 17 00:00:00 2001 From: Ian Sullivan Date: Mon, 9 Feb 2026 14:39:44 -0800 Subject: [PATCH] Drop streak line models that are off the image --- python/lsst/meas/algorithms/maskStreaks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/lsst/meas/algorithms/maskStreaks.py b/python/lsst/meas/algorithms/maskStreaks.py index 6e69fb88..5beaaec6 100644 --- a/python/lsst/meas/algorithms/maskStreaks.py +++ b/python/lsst/meas/algorithms/maskStreaks.py @@ -147,6 +147,7 @@ def __init__(self, data, weights, line=None, detectionMask=None): self.mask = (weights != 0) self._initLine = line + self.modelFailure = False self.setLineMask(line, maxStreakWidth=0, nSigmaMask=10, detectionMask=detectionMask) def getLineXY(self, line): @@ -227,6 +228,11 @@ def setLineMask(self, line, maxStreakWidth, nSigmaMask, logger=None, detectionMa # happens when, for example, the streak ends in the middle of # the image. lineEnds = self.getLineXY(line) + if lineEnds.size == 0: + if logger is not None: + logger.debug("Calculated line not contained in image bounding box") + self.modelFailure = True + return xA = lineEnds[0, 0] - self._xmax / 2. yA = lineEnds[0, 1] - self._ymax / 2. @@ -895,7 +901,7 @@ def _fitProfile(self, lines, maskedImage, detectionMask=None): line.sigma = self.config.invSigma**-1 lineModel = LineProfile(data, weights, line=line, detectionMask=detectionMask) # Skip any lines that do not cover any data (sometimes happens because of chip gaps) - if lineModel.lineMask.sum() == 0: + if lineModel.modelFailure or lineModel.lineMask.sum() == 0: continue fit, fitFailure = lineModel.fit(dChi2Tol=self.config.dChi2Tolerance, log=self.log,