Skip to content

DM-51111: Fix to ITL saturation sag masking and add log #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions python/lsst/ip/isr/isrFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def _applyMaskITLEdgeBleed(ccdExposure, xCore,
sliceMask[y, lowerRange:upperRange] |= saturatedBit


def maskITLSatSag(ccdExposure, fpCore, saturatedMaskName="SAT"):
def maskITLSatSag(ccdExposure, fpCore, saturatedMaskName="SAT", log=None):
"""Mask columns presenting saturation sag in saturated footprints in
ITL detectors.

Expand All @@ -529,20 +529,25 @@ def maskITLSatSag(ccdExposure, fpCore, saturatedMaskName="SAT"):
Footprint of saturated core.
saturatedMaskName : `str`, optional
Mask name for saturation.
log : `logging.Logger`, optional
Logger to handle messages.
"""
log = log if log else logging.getLogger(__name__)

# TODO DM-49736: add a flux level check to apply masking

maskedImage = ccdExposure.maskedImage
saturatedBit = maskedImage.mask.getPlaneBitMask(saturatedMaskName)

cc = numpy.sum(fpCore.getSpans().asArray(), axis=0)
# Mask full columns that have 20 percent of the height of the footprint
# Mask full columns that have 30 percent of the height of the footprint
# saturated
columnsToMaskFP = numpy.where(cc > fpCore.getSpans().asArray().shape[0]/5.)
columnsToMaskFP = numpy.where(cc > fpCore.getSpans().asArray().shape[0]*0.3)

columnsToMask = [x + int(fpCore.getBBox().getMinX()) for x in columnsToMaskFP]
maskedImage.mask.array[:, columnsToMask] |= saturatedBit

log.info("Masking %d columns for saturation sag masking.", len(columnsToMask[0]))
maskedImage.mask.array[:, columnsToMask[0]] |= saturatedBit


def maskITLDip(exposure, detectorConfig, maskPlaneNames=["SUSPECT", "ITL_DIP"], log=None):
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ip/isr/isrTaskLSST.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def maskITLSatEdgesAndColumns(self, exposure, badAmpDict):
)
if self.config.doITLSatSagMask:
isrFunctions.maskITLSatSag(ccdExposure=exposure, fpCore=fpCore,
saturatedMaskName=self.config.saturatedMaskName)
saturatedMaskName=self.config.saturatedMaskName, log=self.log)

def overscanCorrection(self, mode, detectorConfig, detector, badAmpDict, ccdExposure):
"""Apply serial overscan correction in place to all amps.
Expand Down