Skip to content

Commit

Permalink
Merge pull request #296 from lsst/tickets/DM-41876
Browse files Browse the repository at this point in the history
DM-41876: Reject sources flagged with *CenterAll
  • Loading branch information
isullivan authored Feb 17, 2024
2 parents 88964a4 + 1adbd3d commit 5d89126
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions python/lsst/ip/diffim/detectAndMeasure.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ class DetectAndMeasureConfig(pipeBase.PipelineTaskConfig,
dtype=str,
doc="Sources with any of these flags set are removed before writing the output catalog.",
default=("base_PixelFlags_flag_offimage",
"base_PixelFlags_flag_interpolatedCenterAll",
"base_PixelFlags_flag_badCenterAll",
"base_PixelFlags_flag_edgeCenterAll",
),
)
idGenerator = DetectorVisitIdGeneratorConfig.make_field()
Expand Down Expand Up @@ -178,6 +181,7 @@ def setDefaults(self):
"STREAK", "INJECTED", "INJECTED_TEMPLATE"]
self.measurement.plugins["base_PixelFlags"].masksFpCenter = [
"STREAK", "INJECTED", "INJECTED_TEMPLATE"]
self.skySources.avoidMask = ["DETECTED", "DETECTED_NEGATIVE", "BAD", "NO_DATA", "EDGE"]


class DetectAndMeasureTask(lsst.pipe.base.PipelineTask):
Expand Down Expand Up @@ -394,6 +398,7 @@ def addSkySources(self, diaSources, mask, seed):
Seed value to initialize the random number generator.
"""
skySourceFootprints = self.skySources.run(mask=mask, seed=seed)
self.metadata.add("nSkySources", len(skySourceFootprints))
if skySourceFootprints:
for foot in skySourceFootprints:
s = diaSources.addNew()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_detectAndMeasure.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,9 @@ def test_sky_sources(self):

# Run detection and check the results
output = detectionTask.run(science, matchedTemplate, difference, score)
nSkySourcesGenerated = detectionTask.metadata["nSkySources"]
skySources = output.diaSources[output.diaSources["sky_source"]]
self.assertEqual(len(skySources), detectionTask.config.skySources.nSources)
self.assertEqual(len(skySources), nSkySourcesGenerated)
for skySource in skySources:
# The sky sources should not be close to any other source
with self.assertRaises(AssertionError):
Expand Down

0 comments on commit 5d89126

Please sign in to comment.