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 14, 2024
1 parent 2b38363 commit e0888b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
22 changes: 14 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,14 @@ 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"]
self.measurement.plugins["base_PixelFlags"].masksFpCenter = ["STREAK"]

self.measurement.plugins["base_PixelFlags"].masksFpAnywhere.append("INJECTED")
self.measurement.plugins["base_PixelFlags"].masksFpCenter.append("INJECTED")

self.measurement.plugins["base_PixelFlags"].masksFpAnywhere.append("INJECTED_TEMPLATE")
self.measurement.plugins["base_PixelFlags"].masksFpCenter.append("INJECTED_TEMPLATE")


class DetectAndMeasureTask(lsst.pipe.base.PipelineTask):
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/ip/diffim/subtractImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,18 +628,18 @@ 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")
diffInjectedBitMask = mask.getPlaneBitMask("INJECTED")

mask.addMaskPlane("INJECTED_TEMPLATE")
diffInjTmpltBitMask = mask.getPlaneBitMask("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')
tmpltFakeBitMask = template[bbox].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 e0888b4

Please sign in to comment.