From 54dffc6d4af30747a4df3483593d70b9fac7b078 Mon Sep 17 00:00:00 2001 From: Meredith Rawls Date: Tue, 7 Oct 2025 22:29:41 -0700 Subject: [PATCH] Don't fall over if no inlier glint trail points are found. --- python/lsst/meas/algorithms/findGlintTrails.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/python/lsst/meas/algorithms/findGlintTrails.py b/python/lsst/meas/algorithms/findGlintTrails.py index e1658856..df75b801 100644 --- a/python/lsst/meas/algorithms/findGlintTrails.py +++ b/python/lsst/meas/algorithms/findGlintTrails.py @@ -288,12 +288,18 @@ def extract(fitter, x, y, prefix=""): y[0] = matches[0].first.getY() y[1:, 0] = [matches[i].second.getY() for i in indexes] - fitter.fit(x, y) - result = extract(fitter, x, y, prefix="preliminary") - # Reject trails that have too many outliers after the first fit. - if (n_inliers := sum(fitter.inlier_mask_)) < self.config.min_points: - self.log.debug("Candidate trail rejected with %d < %d points.", n_inliers, self.config.min_points) + try: + fitter.fit(x, y) + except ValueError: + self.log.info("Glint trail interpolation could not find a valid fit.") return None, None + else: + result = extract(fitter, x, y, prefix="preliminary") + # Reject trails that have too many outliers after the first fit. + if (n_inliers := sum(fitter.inlier_mask_)) < self.config.min_points: + self.log.debug("Candidate trail rejected with %d < %d points.", + n_inliers, self.config.min_points) + return None, None # Find all points that are close to this line and refit with them. x = catalog["slot_Centroid_x"]