Skip to content

Commit

Permalink
Add subtractBackground to cutOutDonuts. Needs debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkalmbach committed Jan 20, 2024
1 parent 8b1a359 commit 47ab2ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/lsst/ts/wep/task/cutOutDonutsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ class CutOutDonutsBaseTaskConfig(
dtype=int,
default=6,
)
subtractBackground = pexConfig.ConfigurableField(
target=lsst.meas.algorithms.SubtractBackgroundTask,
doc="Task to perform background subtraction.",
)


class CutOutDonutsBaseTask(pipeBase.PipelineTask):
Expand Down Expand Up @@ -185,6 +189,8 @@ def __init__(self, **kwargs):
# Parameters for mask multiplication (for deblending)
self.multiplyMask = self.config.multiplyMask
self.maskGrowthIter = self.config.maskGrowthIter
# Set up background subtraction task
self.makeSubtask("subtractBackground")

def _checkAndSetOffset(self, dataOffsetValue):
"""Check offset in instParams dictionary and if it
Expand Down
9 changes: 9 additions & 0 deletions python/lsst/ts/wep/task/cutOutDonutsCwfsTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ def run(
) -> pipeBase.Struct:
cameraName = camera.getName()
extraCatalog, intraCatalog = donutCatalogs
defaultMaskPlaneDict = exposures[0].mask.getMaskPlaneDict()
print('-1', defaultMaskPlaneDict)

# Get the donut stamps from extra and intra focal images
donutStampsExtra = DonutStamps([], use_archive=True)
Expand All @@ -171,6 +173,13 @@ def run(
for exposure in exposures:
focusZ = exposure.visitInfo.focusZ
detectorName = exposure.getDetector().getName()
# Subtract background
print('0', exposure.mask.getMaskPlaneDict())
exposure.mask.clearMaskPlaneDict()
exposure.mask.conformMaskPlanes(defaultMaskPlaneDict)
print('1', exposure.mask.getMaskPlaneDict())
print('2', defaultMaskPlaneDict)
background = self.subtractBackground.run(exposure=exposure).background
if detectorName in self.extraFocalNames:
# LSST extrafocal chips are offset -1.5 mm
# when LSST camera defocus is at 0.
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/ts/wep/task/cutOutDonutsScienceSensorTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ def run(
)

# Get the donut stamps from extra and intra focal images
backgroundExtra = self.subtractBackground.run(exposure=exposure[extraExpIdx]).background
donutStampsExtra = self.cutOutStamps(
exposures[extraExpIdx],
donutCatalog[extraExpIdx],
DefocalType.Extra,
cameraName,
)
backgroundIntra = self.subtractBackground.run(exposure=exposure[intraExpIdx]).background
donutStampsIntra = self.cutOutStamps(
exposures[intraExpIdx],
donutCatalog[intraExpIdx],
Expand Down
1 change: 1 addition & 0 deletions tests/task/test_cutOutDonutsCwfsTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def tearDownClass(cls):
runProgram(cleanUpCmd)

def setUp(self):
print('set', lsst.afw.image.Mask().getMaskPlaneDict())
self.config = CutOutDonutsCwfsTaskConfig()
self.task = CutOutDonutsCwfsTask(config=self.config)

Expand Down

0 comments on commit 47ab2ab

Please sign in to comment.