From 22c6b1fcab75e35d08ecd8a97d25f3db790af89d Mon Sep 17 00:00:00 2001 From: Ian Sullivan Date: Wed, 20 Aug 2025 12:50:21 -0700 Subject: [PATCH 1/3] Exclude sky sources from glint detection --- python/lsst/ip/diffim/detectAndMeasure.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/lsst/ip/diffim/detectAndMeasure.py b/python/lsst/ip/diffim/detectAndMeasure.py index 713573afb..a80c2c585 100644 --- a/python/lsst/ip/diffim/detectAndMeasure.py +++ b/python/lsst/ip/diffim/detectAndMeasure.py @@ -899,7 +899,12 @@ def _find_glint_trails(self, diaSources): trail_parameters : `dict` Parameters of all the trails that were found. """ - trailed_glints = self.findGlints.run(diaSources) + if self.config.doSkySources: + # Do not include sky sources in glint detection + candidateDiaSources = diaSources[~diaSources["sky_source"]].copy(deep=True) + else: + candidateDiaSources = diaSources + trailed_glints = self.findGlints.run(candidateDiaSources) glint_mask = [True if id in trailed_glints.trailed_ids else False for id in diaSources['id']] diaSources['glint_trail'] = np.array(glint_mask) From ae850a2c10946e1a84d061e66bdcd6a85b3b1a20 Mon Sep 17 00:00:00 2001 From: Ian Sullivan Date: Wed, 20 Aug 2025 12:50:48 -0700 Subject: [PATCH 2/3] Run glint detection after filtering bad diaSources --- python/lsst/ip/diffim/detectAndMeasure.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/lsst/ip/diffim/detectAndMeasure.py b/python/lsst/ip/diffim/detectAndMeasure.py index a80c2c585..9f7323972 100644 --- a/python/lsst/ip/diffim/detectAndMeasure.py +++ b/python/lsst/ip/diffim/detectAndMeasure.py @@ -750,17 +750,17 @@ def processResults(self, science, matchedTemplate, difference, sources, idFactor self.measureDiaSources(initialDiaSources, science, difference, matchedTemplate) - # Add a column for glint trail diaSources, but do not remove them - initialDiaSources, trail_parameters = self._find_glint_trails(initialDiaSources) - if self.config.writeGlintInfo: - measurementResults.mergeItems(trail_parameters, 'glintTrailInfo') - # Remove unphysical diaSources per config.badSourceFlags diaSources = self._removeBadSources(initialDiaSources) if self.config.run_sattle: diaSources = self.filterSatellites(diaSources, science) + # Flag diaSources in glint trails, but do not remove them + diaSources, trail_parameters = self._find_glint_trails(diaSources) + if self.config.writeGlintInfo: + measurementResults.mergeItems(trail_parameters, 'glintTrailInfo') + if self.config.doForcedMeasurement: self.measureForcedSources(diaSources, science, difference.getWcs()) From 8fc09b03260957baae061486c6b3ecbaffba352b Mon Sep 17 00:00:00 2001 From: Ian Sullivan Date: Wed, 20 Aug 2025 13:03:00 -0700 Subject: [PATCH 3/3] Only set `'glint_trail'` column if there are any flagged sources. This is really meant to catch cases where diaSources is an empty catalog, and attempting to set the column even to an empty array will raise a `TypeError` --- python/lsst/ip/diffim/detectAndMeasure.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/lsst/ip/diffim/detectAndMeasure.py b/python/lsst/ip/diffim/detectAndMeasure.py index 9f7323972..cc9d7a22a 100644 --- a/python/lsst/ip/diffim/detectAndMeasure.py +++ b/python/lsst/ip/diffim/detectAndMeasure.py @@ -906,7 +906,8 @@ def _find_glint_trails(self, diaSources): candidateDiaSources = diaSources trailed_glints = self.findGlints.run(candidateDiaSources) glint_mask = [True if id in trailed_glints.trailed_ids else False for id in diaSources['id']] - diaSources['glint_trail'] = np.array(glint_mask) + if np.any(glint_mask): + diaSources['glint_trail'] = np.array(glint_mask) slopes = np.array([trail.slope for trail in trailed_glints.parameters]) intercepts = np.array([trail.intercept for trail in trailed_glints.parameters])