Skip to content

Commit

Permalink
Added flagging of sources near the INJECTED mask plane
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSanchez committed Jan 16, 2024
1 parent 2b38363 commit 3724b0a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
18 changes: 10 additions & 8 deletions python/lsst/ip/diffim/detectAndMeasure.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ def setDefaults(self):
self.detection.excludeMaskPlanes = ["EDGE"]

# Add filtered flux measurement, the correct measurement for pre-convolved images.
self.measurement.algorithms.names.add('base_PeakLikelihoodFlux')
self.measurement.plugins.names |= ['ext_trailedSources_Naive',
'base_LocalPhotoCalib',
'base_LocalWcs',
'ext_shapeHSM_HsmSourceMoments',
'ext_shapeHSM_HsmPsfMoments',
self.measurement.algorithms.names.add("base_PeakLikelihoodFlux")
self.measurement.plugins.names |= ["ext_trailedSources_Naive",
"base_LocalPhotoCalib",
"base_LocalWcs",
"ext_shapeHSM_HsmSourceMoments",
"ext_shapeHSM_HsmPsfMoments",
]
self.measurement.slots.psfShape = "ext_shapeHSM_HsmPsfMoments"
self.measurement.slots.shape = "ext_shapeHSM_HsmSourceMoments"
Expand All @@ -174,8 +174,10 @@ def setDefaults(self):
self.forcedMeasurement.slots.shape = None

# Keep track of which footprints contain streaks
self.measurement.plugins['base_PixelFlags'].masksFpAnywhere = ['STREAK']
self.measurement.plugins['base_PixelFlags'].masksFpCenter = ['STREAK']
self.measurement.plugins["base_PixelFlags"].masksFpAnywhere = [
"STREAK", "INJECTED", "INJECTED_TEMPLATE"]
self.measurement.plugins["base_PixelFlags"].masksFpCenter = [
"STREAK", "INJECTED", "INJECTED_TEMPLATE"]


class DetectAndMeasureTask(lsst.pipe.base.PipelineTask):
Expand Down
9 changes: 4 additions & 5 deletions python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,16 +628,15 @@ def updateMasks(self, template, science, difference):
mask = difference.mask
mask &= ~(mask.getPlaneBitMask("DETECTED") | mask.getPlaneBitMask("DETECTED_NEGATIVE"))

self.log.info("Adding injected mask planes")
mask.addMaskPlane("INJECTED")
mask.addMaskPlane("INJECTED_TEMPLATE")

if "FAKE" in science.mask.getMaskPlaneDict().keys():
# propagate the mask plane related to Fake source injection
# NOTE: the fake source injection sets FAKE plane, but it should be INJECTED
# NOTE: This can be removed in DM-40796

self.log.info("Adding injected mask planes")
mask.addMaskPlane("INJECTED")
diffInjectedBitMask = mask.getPlaneBitMask("INJECTED")

mask.addMaskPlane("INJECTED_TEMPLATE")
diffInjTmpltBitMask = mask.getPlaneBitMask("INJECTED_TEMPLATE")

scienceFakeBitMask = science.mask.getPlaneBitMask('FAKE')
Expand Down
3 changes: 3 additions & 0 deletions python/lsst/ip/diffim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,9 @@ def detectTestSources(exposure):
doSmooth=True
)
exposure.mask.addMaskPlane("STREAK") # add empty streak mask plane in lieu of maskStreaksTask
exposure.mask.addMaskPlane("INJECTED") # add empty injected mask plane
exposure.mask.addMaskPlane("INJECTED_TEMPLATE") # add empty injected template mask plane

selectSources = detRet.sources
selectMeasurement.run(measCat=selectSources, exposure=exposure)

Expand Down

0 comments on commit 3724b0a

Please sign in to comment.