Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions python/lsst/ip/diffim/detectAndMeasure.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ class DetectAndMeasureConfig(pipeBase.PipelineTaskConfig,
target=SourceDetectionTask,
doc="Separate source detection used only for streak masking",
)
doDeblend = pexConfig.Field(
dtype=bool,
default=False,
doc="Deblend DIASources after detection?"
)
deblend = pexConfig.ConfigurableField(
target=lsst.meas.deblender.SourceDeblendTask,
doc="Task to split blended sources into their components."
Expand Down Expand Up @@ -215,10 +220,7 @@ def setDefaults(self):
self.detection.reEstimateBackground = False
self.detection.thresholdType = "pixel_stdev"
self.detection.excludeMaskPlanes = ["EDGE",
"SAT",
"BAD",
"INTRP",
"NO_DATA",
Comment on lines -218 to -221
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point, but please move the excludeMaskPlanes changes to their own commit

]

# Copy configs for binned streak detection from the base detection task
Expand Down Expand Up @@ -282,7 +284,8 @@ def __init__(self, **kwargs):

self.algMetadata = dafBase.PropertyList()
self.makeSubtask("detection", schema=self.schema)
self.makeSubtask("deblend", schema=self.schema)
if self.config.doDeblend:
self.makeSubtask("deblend", schema=self.schema)
self.makeSubtask("setPrimaryFlags", schema=self.schema, isSingleFrame=True)
self.makeSubtask("measurement", schema=self.schema,
algMetadata=self.algMetadata)
Expand Down Expand Up @@ -389,13 +392,21 @@ def run(self, science, matchedTemplate, difference,
doSmooth=True,
)

sources, positives, negatives = self._deblend(difference,
results.positive,
results.negative)
if self.config.doDeblend:
sources, positives, negatives = self._deblend(difference,
results.positive,
results.negative)

return self.processResults(science, matchedTemplate, difference, sources, idFactory,
positiveFootprints=positives,
negativeFootprints=negatives)
return self.processResults(science, matchedTemplate, difference,
sources, idFactory,
positiveFootprints=positives,
negativeFootprints=negatives)

else:
return self.processResults(science, matchedTemplate, difference,
results.sources, idFactory,
positiveFootprints=results.positive,
negativeFootprints=results.negative)

def _prepareInputs(self, difference):
"""Ensure that we start with an empty detection and deblended mask.
Expand Down Expand Up @@ -859,9 +870,18 @@ def run(self, science, matchedTemplate, difference, scoreExposure,
# Copy the detection mask from the Score image to the difference image
difference.mask.assign(scoreExposure.mask, scoreExposure.getBBox())

sources, positives, negatives = self._deblend(difference,
results.positive,
results.negative)
if self.config.doDeblend:
sources, positives, negatives = self._deblend(difference,
results.positive,
results.negative)

return self.processResults(science, matchedTemplate, difference,
sources, idFactory,
positiveFootprints=positives,
negativeFootprints=negatives)

return self.processResults(science, matchedTemplate, difference, sources, idFactory,
positiveFootprints=positives, negativeFootprints=negatives)
else:
return self.processResults(science, matchedTemplate, difference,
results.sources, idFactory,
positiveFootprints=results.positive,
negativeFootprints=results.negative)