LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Static Public Attributes | List of all members
lsst.obs.decam.crosstalk.DecamCrosstalkTask Class Reference
Inheritance diagram for lsst.obs.decam.crosstalk.DecamCrosstalkTask:
lsst.ip.isr.crosstalk.CrosstalkTask

Public Member Functions

def prepCrosstalk (self, dataRef, crosstalk=None)
 
def run (self, exposure, crosstalk=None, crosstalkSources=None, isTrimmed=False, camera=None)
 

Static Public Attributes

 ConfigClass = DecamCrosstalkConfig
 

Detailed Description

Remove crosstalk from a raw DECam image.

This must be done after the overscan is corrected but before it is trimmed.
This version of crosstalk removal assumes you want to do it as part of a
regular stack-ISR workflow.

Definition at line 101 of file crosstalk.py.

Member Function Documentation

◆ prepCrosstalk()

def lsst.obs.decam.crosstalk.DecamCrosstalkTask.prepCrosstalk (   self,
  dataRef,
  crosstalk = None 
)
Retrieve source image data and coefficients to prepare for crosstalk correction.

This is called by readIsrData. The crosstalkSources land in isrData.

Parameters
----------
dataRef : `lsst.daf.persistence.butlerSubset.ButlerDataRef`
    DataRef of exposure to correct which must include a dataId with
    at least one visit and a ccdnum corresponding to the detector id.
crosstalk : `lsst.ip.isr.CrosstalkCalib`
    Crosstalk calibration that will be used.

Returns
-------
crosstalkSources : `defaultdict`
    Contains image data and corresponding crosstalk coefficients for
    each crosstalk source of the given dataRef victim.

Reimplemented from lsst.ip.isr.crosstalk.CrosstalkTask.

Definition at line 111 of file crosstalk.py.

111  def prepCrosstalk(self, dataRef, crosstalk=None):
112  """Retrieve source image data and coefficients to prepare for crosstalk correction.
113 
114  This is called by readIsrData. The crosstalkSources land in isrData.
115 
116  Parameters
117  ----------
118  dataRef : `lsst.daf.persistence.butlerSubset.ButlerDataRef`
119  DataRef of exposure to correct which must include a dataId with
120  at least one visit and a ccdnum corresponding to the detector id.
121  crosstalk : `lsst.ip.isr.CrosstalkCalib`
122  Crosstalk calibration that will be used.
123 
124  Returns
125  -------
126  crosstalkSources : `defaultdict`
127  Contains image data and corresponding crosstalk coefficients for
128  each crosstalk source of the given dataRef victim.
129  """
130  # Define a butler to prepare for accessing crosstalk 'source' image data
131  try:
132  butler = dataRef.getButler()
133  except RuntimeError:
134  self.log.fatal('Cannot get a Butler from the dataRef provided')
135 
136  # If there is no interChip CT, then we're done.
137  if crosstalk.interChip is None or len(crosstalk.interChip) == 0:
138  return None
139 
140  # Retrieve visit and ccdnum from 'victim' so we can look up 'sources'
141  visit = dataRef.dataId['visit']
142  crosstalkSources = defaultdict(list)
143 
144  decamisr = IsrTask() # needed for source_exposure overscan correction
145  for sourceDet in crosstalk.interChip:
146  try:
147  source_exposure = butler.get('raw', dataId={'visit': visit, 'ccd': sourceDet})
148  except RuntimeError:
149  self.log.warning("Cannot access source %s, SKIPPING IT", sourceDet)
150  else:
151  self.log.info("Correcting victim %s from crosstalk source %s.",
152  crosstalk._detectorName, sourceDet)
153 
154  for amp in source_exposure.getDetector():
155  decamisr.overscanCorrection(source_exposure, amp)
156 
157  # Do not assemble here, as DECam CT is corrected before assembly.
158  crosstalkSources[sourceDet] = source_exposure
159  return crosstalkSources
160 
161 

◆ run()

def lsst.ip.isr.crosstalk.CrosstalkTask.run (   self,
  exposure,
  crosstalk = None,
  crosstalkSources = None,
  isTrimmed = False,
  camera = None 
)
inherited
Apply intra-detector crosstalk correction

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure for which to remove crosstalk.
crosstalkCalib : `lsst.ip.isr.CrosstalkCalib`, optional
    External crosstalk calibration to apply.  Constructed from
    detector if not found.
crosstalkSources : `defaultdict`, optional
    Image data for other detectors that are sources of
    crosstalk in exposure.  The keys are expected to be names
    of the other detectors, with the values containing
    `lsst.afw.image.Exposure` at the same level of processing
    as ``exposure``.
    The default for intra-detector crosstalk here is None.
isTrimmed : `bool`, optional
    The image is already trimmed.
    This should no longer be needed once DM-15409 is resolved.
camera : `lsst.afw.cameraGeom.Camera`, optional
    Camera associated with this exposure.  Only used for
    inter-chip matching.

Raises
------
RuntimeError
    Raised if called for a detector that does not have a
    crosstalk correction.  Also raised if the crosstalkSource
    is not an expected type.

Definition at line 680 of file crosstalk.py.

681  crosstalkSources=None, isTrimmed=False, camera=None):
682  """Apply intra-detector crosstalk correction
683 
684  Parameters
685  ----------
686  exposure : `lsst.afw.image.Exposure`
687  Exposure for which to remove crosstalk.
688  crosstalkCalib : `lsst.ip.isr.CrosstalkCalib`, optional
689  External crosstalk calibration to apply. Constructed from
690  detector if not found.
691  crosstalkSources : `defaultdict`, optional
692  Image data for other detectors that are sources of
693  crosstalk in exposure. The keys are expected to be names
694  of the other detectors, with the values containing
695  `lsst.afw.image.Exposure` at the same level of processing
696  as ``exposure``.
697  The default for intra-detector crosstalk here is None.
698  isTrimmed : `bool`, optional
699  The image is already trimmed.
700  This should no longer be needed once DM-15409 is resolved.
701  camera : `lsst.afw.cameraGeom.Camera`, optional
702  Camera associated with this exposure. Only used for
703  inter-chip matching.
704 
705  Raises
706  ------
707  RuntimeError
708  Raised if called for a detector that does not have a
709  crosstalk correction. Also raised if the crosstalkSource
710  is not an expected type.
711  """
712  if not crosstalk:
713  crosstalk = CrosstalkCalib(log=self.log)
714  crosstalk = crosstalk.fromDetector(exposure.getDetector(),
715  coeffVector=self.config.crosstalkValues)
716  if not crosstalk.log:
717  crosstalk.log = self.log
718  if not crosstalk.hasCrosstalk:
719  raise RuntimeError("Attempted to correct crosstalk without crosstalk coefficients.")
720 
721  else:
722  self.log.info("Applying crosstalk correction.")
723  crosstalk.subtractCrosstalk(exposure, crosstalkCoeffs=crosstalk.coeffs,
724  minPixelToMask=self.config.minPixelToMask,
725  crosstalkStr=self.config.crosstalkMaskPlane, isTrimmed=isTrimmed,
726  backgroundMethod=self.config.crosstalkBackgroundMethod)
727 
728  if crosstalk.interChip:
729  if crosstalkSources:
730  # Parse crosstalkSources: Identify which detectors we have available
731  if isinstance(crosstalkSources[0], lsst.afw.image.Exposure):
732  # Received afwImage.Exposure
733  sourceNames = [exp.getDetector().getName() for exp in crosstalkSources]
734  elif isinstance(crosstalkSources[0], lsst.daf.butler.DeferredDatasetHandle):
735  # Received dafButler.DeferredDatasetHandle
736  detectorList = [source.dataId['detector'] for source in crosstalkSources]
737  sourceNames = [camera[detector].getName() for detector in detectorList]
738  else:
739  raise RuntimeError("Unknown object passed as crosstalk sources.",
740  type(crosstalkSources[0]))
741 
742  for detName in crosstalk.interChip:
743  if detName not in sourceNames:
744  self.log.warning("Crosstalk lists %s, not found in sources: %s",
745  detName, sourceNames)
746  continue
747  # Get the coefficients.
748  interChipCoeffs = crosstalk.interChip[detName]
749 
750  sourceExposure = crosstalkSources[sourceNames.index(detName)]
751  if isinstance(sourceExposure, lsst.daf.butler.DeferredDatasetHandle):
752  # Dereference the dafButler.DeferredDatasetHandle.
753  sourceExposure = sourceExposure.get()
754  if not isinstance(sourceExposure, lsst.afw.image.Exposure):
755  raise RuntimeError("Unknown object passed as crosstalk sources.",
756  type(sourceExposure))
757 
758  self.log.info("Correcting detector %s with ctSource %s",
759  exposure.getDetector().getName(),
760  sourceExposure.getDetector().getName())
761  crosstalk.subtractCrosstalk(exposure, sourceExposure=sourceExposure,
762  crosstalkCoeffs=interChipCoeffs,
763  minPixelToMask=self.config.minPixelToMask,
764  crosstalkStr=self.config.crosstalkMaskPlane,
765  isTrimmed=isTrimmed,
766  backgroundMethod=self.config.crosstalkBackgroundMethod)
767  else:
768  self.log.warning("Crosstalk contains interChip coefficients, but no sources found!")
769 
770 
table::Key< int > type
Definition: Detector.cc:163
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
std::string const & getName() const noexcept
Return a filter's name.
Definition: Filter.h:78

Member Data Documentation

◆ ConfigClass

lsst.obs.decam.crosstalk.DecamCrosstalkTask.ConfigClass = DecamCrosstalkConfig
static

Definition at line 108 of file crosstalk.py.


The documentation for this class was generated from the following file: