Skip to content
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

DM-26037: Add option to ignore nPixels from edge in PTC task #84

Merged
merged 2 commits into from
Apr 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 26 additions & 1 deletion python/lsst/cp/pipe/ptc/cpExtractPtcTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .astierCovPtcFit import makeCovArray

from lsst.ip.isr import PhotonTransferCurveDataset

from lsst.ip.isr import IsrTask

__all__ = ['PhotonTransferCurveExtractConfig', 'PhotonTransferCurveExtractTask']

Expand Down Expand Up @@ -137,6 +137,20 @@ class PhotonTransferCurveExtractConfig(pipeBase.PipelineTaskConfig,
"FULL": "Full image."
}
)
numEdgeSuspect = pexConfig.Field(
dtype=int,
doc="Number of edge pixels to be flagged as untrustworthy.",
default=0,
)
edgeMaskLevel = pexConfig.ChoiceField(
dtype=str,
doc="Mask edge pixels in which coordinate frame: DETECTOR or AMP?",
default="DETECTOR",
allowed={
'DETECTOR': 'Mask only the edges of the full detector.',
'AMP': 'Mask edges of each amplifier.',
},
)


class PhotonTransferCurveExtractTask(pipeBase.PipelineTask,
Expand Down Expand Up @@ -248,6 +262,11 @@ def run(self, inputExp, inputDims):
for i in range(len(inputDims)):
partialPtcDatasetList.append(dummyPtcDataset)

if self.config.numEdgeSuspect > 0:
isrTask = IsrTask()
self.log.info(f"Masking {self.config.numEdgeSuspect} pixels from the edges "
"of all exposures as SUSPECT.")

for expTime in inputExp:
exposures = inputExp[expTime]
if len(exposures) == 1:
Expand All @@ -261,6 +280,12 @@ def run(self, inputExp, inputDims):
self.log.warn(f"Already found 2 exposures at expTime {expTime}. "
"Ignoring exposures: "
f"{i.getInfo().getVisitInfo().getExposureId() for i in exposures[2:]}")
# Mask pixels at the edge of the detector or of each amp
if self.config.numEdgeSuspect > 0:
isrTask.maskEdges(exp1, numEdgePixels=self.config.numEdgeSuspect,
maskPlane="SUSPECT", level=self.config.edgeMaskLevel)
isrTask.maskEdges(exp2, numEdgePixels=self.config.numEdgeSuspect,
maskPlane="SUSPECT", level=self.config.edgeMaskLevel)
expId1 = exp1.getInfo().getVisitInfo().getExposureId()
expId2 = exp2.getInfo().getVisitInfo().getExposureId()
nAmpsNan = 0
Expand Down