Skip to content

Commit

Permalink
Rework measureCrosstalk to have useful debug information. Fix readout…
Browse files Browse the repository at this point in the history
… bug in isrMock.
  • Loading branch information
czwa committed May 28, 2019
1 parent 8056d37 commit b4234a6
Show file tree
Hide file tree
Showing 6 changed files with 386 additions and 152 deletions.
7 changes: 5 additions & 2 deletions python/lsst/ip/isr/crosstalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class CrosstalkConfig(Config):
)
crosstalkValues = ListField(
dtype=float,
doc="Amplifier-indexed crosstalk coefficients to use.",
doc=("Amplifier-indexed crosstalk coefficients to use. This should be arranged as a 1 x nAmp**2 "
"list of coefficients, such that when reshaped by crosstalkShape, the result is nAmp x nAmp. "
"This matrix should be structured so CT * [amp0 amp1 amp2 ...]^T returns the column "
"vector [corr0 corr1 corr2 ...]^T."),
default=[0.0],
)
crosstalkShape = ListField(
Expand All @@ -73,7 +76,7 @@ class CrosstalkConfig(Config):
)

def getCrosstalk(self, detector=None):
"""Return a 2-D numpy array of crosstalk coefficients of the proper shape.
"""Return a 2-D numpy array of crosstalk coefficients in the proper shape.
Parameters
----------
Expand Down
25 changes: 18 additions & 7 deletions python/lsst/ip/isr/isrMock.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import tempfile

import lsst.geom
import lsst.afw.image as afwImage
import lsst.afw.geom as afwGeom
import lsst.afw.image as afwImage
import lsst.afw.math as afwMath
import lsst.afw.table as afwTable
import lsst.afw.cameraGeom.utils as afwUtils
import lsst.afw.cameraGeom.testUtils as afwTestUtils
from lsst.meas.algorithms import Defects
Expand Down Expand Up @@ -251,6 +253,11 @@ class IsrMock(pipeBase.Task):
ConfigClass = IsrMockConfig
_DefaultName = "isrMock"

XFLIP = {afwTable.LL: False, afwTable.LR: True,
afwTable.UL: False, afwTable.UR: True}
YFLIP = {afwTable.LL: False, afwTable.LR: False,
afwTable.UL: True, afwTable.UR: True}

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.rng = np.random.RandomState(self.config.rngSeed)
Expand Down Expand Up @@ -443,14 +450,18 @@ def makeImage(self):
self.config.darkTime / self.config.gain))

if self.config.doAddCrosstalk is True:

for idxS, ampS in enumerate(exposure.getDetector()):
for idxT, ampT in enumerate(exposure.getDetector()):
if self.config.isTrimmed is True:
ampDataS = exposure.image[ampS.getBBox()]
ampDataT = exposure.image[ampT.getBBox()]
else:
ampDataS = exposure.image[ampS.getRawDataBBox()]
ampDataT = exposure.image[ampT.getRawDataBBox()]
ampDataS = exposure.image[ampS.getBBox() if self.config.isTrimmed
else ampS.getRawDataBBox()]
ampDataT = exposure.image[ampT.getBBox() if self.config.isTrimmed
else ampT.getRawDataBBox()]
ampDataS = afwMath.flipImage(ampDataS,
(self.XFLIP[ampS.getReadoutCorner()] ^
self.XFLIP[ampT.getReadoutCorner()]),
(self.YFLIP[ampS.getReadoutCorner()] ^
self.YFLIP[ampT.getReadoutCorner()]))
self.amplifierAddCT(ampDataS, ampDataT, self.crosstalkCoeffs[idxT][idxS])

for amp in exposure.getDetector():
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/ip/isr/isrTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from .straylight import StrayLightTask
from .vignette import VignetteTask


__all__ = ["IsrTask", "IsrTaskConfig", "RunIsrTask", "RunIsrConfig"]


Expand Down Expand Up @@ -414,7 +415,7 @@ class IsrTaskConfig(pexConfig.Config):
doCrosstalkBeforeAssemble = pexConfig.Field(
dtype=bool,
doc="Apply crosstalk correction before CCD assembly, and before trimming?",
default=True,
default=False,
)
crosstalk = pexConfig.ConfigurableField(
target=CrosstalkTask,
Expand Down

0 comments on commit b4234a6

Please sign in to comment.