LSST Applications  21.0.0-131-g8cabc107+528f53ee53,22.0.0+00495a2688,22.0.0+0ef2527977,22.0.0+11a2aa21cd,22.0.0+269b7e55e3,22.0.0+2c6b6677a3,22.0.0+64c1bc5aa5,22.0.0+7b3a3f865e,22.0.0+e1b6d2281c,22.0.0+ff3c34362c,22.0.1-1-g1b65d06+c95cbdf3df,22.0.1-1-g7058be7+1cf78af69b,22.0.1-1-g7dab645+2a65e40b06,22.0.1-1-g8760c09+64c1bc5aa5,22.0.1-1-g949febb+64c1bc5aa5,22.0.1-1-ga324b9c+269b7e55e3,22.0.1-1-gf9d8b05+ff3c34362c,22.0.1-10-g781e53d+9b51d1cd24,22.0.1-10-gba590ab+b9624b875d,22.0.1-13-g76f9b8d+2c6b6677a3,22.0.1-14-g22236948+57af756299,22.0.1-18-g3db9cf4b+9b7092c56c,22.0.1-18-gb17765a+2264247a6b,22.0.1-2-g8ef0a89+2c6b6677a3,22.0.1-2-gcb770ba+c99495d3c6,22.0.1-24-g2e899d296+4206820b0d,22.0.1-3-g7aa11f2+2c6b6677a3,22.0.1-3-g8c1d971+f253ffa91f,22.0.1-3-g997b569+ff3b2f8649,22.0.1-4-g1930a60+6871d0c7f6,22.0.1-4-g5b7b756+6b209d634c,22.0.1-6-ga02864e+6871d0c7f6,22.0.1-7-g3402376+a1a2182ac4,22.0.1-7-g65f59fa+54b92689ce,master-gcc5351303a+e1b6d2281c,w.2021.32
LSST Data Management Base Package
Public Member Functions | Static Public Attributes | List of all members
lsst.cp.pipe.measureCrosstalk.CrosstalkExtractTask Class Reference
Inheritance diagram for lsst.cp.pipe.measureCrosstalk.CrosstalkExtractTask:

Public Member Functions

def run (self, inputExp, sourceExps=[])
 
def debugView (self, stepname, exposure)
 
def debugPixels (self, stepname, pixelsIn, pixelsOut, sourceName, targetName)
 

Static Public Attributes

 ConfigClass = CrosstalkExtractConfig
 

Detailed Description

Task to measure pixel ratios to find crosstalk.

Definition at line 127 of file measureCrosstalk.py.

Member Function Documentation

◆ debugPixels()

def lsst.cp.pipe.measureCrosstalk.CrosstalkExtractTask.debugPixels (   self,
  stepname,
  pixelsIn,
  pixelsOut,
  sourceName,
  targetName 
)
Utility function to examine the CT ratio pixel values.

Parameters
----------
stepname : `str`
    State of processing to view.
pixelsIn : `np.ndarray`
    Pixel values from the potential crosstalk source.
pixelsOut : `np.ndarray`
    Pixel values from the potential crosstalk target.
sourceName : `str`
    Source amplifier name
targetName : `str`
    Target amplifier name

Definition at line 282 of file measureCrosstalk.py.

282  def debugPixels(self, stepname, pixelsIn, pixelsOut, sourceName, targetName):
283  """Utility function to examine the CT ratio pixel values.
284 
285  Parameters
286  ----------
287  stepname : `str`
288  State of processing to view.
289  pixelsIn : `np.ndarray`
290  Pixel values from the potential crosstalk source.
291  pixelsOut : `np.ndarray`
292  Pixel values from the potential crosstalk target.
293  sourceName : `str`
294  Source amplifier name
295  targetName : `str`
296  Target amplifier name
297  """
298  frame = getDebugFrame(self._display, stepname)
299  if frame:
300  import matplotlib.pyplot as plt
301  figure = plt.figure(1)
302  figure.clear()
303 
304  axes = figure.add_axes((0.1, 0.1, 0.8, 0.8))
305  axes.plot(pixelsIn, pixelsOut / pixelsIn, 'k+')
306  plt.xlabel("Source amplifier pixel value")
307  plt.ylabel("Measured pixel ratio")
308  plt.title(f"(Source {sourceName} -> Target {targetName}) median ratio: "
309  f"{(np.median(pixelsOut / pixelsIn))}")
310  figure.show()
311 
312  prompt = "Press Enter to continue: "
313  while True:
314  ans = input(prompt).lower()
315  if ans in ("", "c",):
316  break
317  plt.close()
318 
319 
def getDebugFrame(debugDisplay, name)
Definition: lsstDebug.py:95

◆ debugView()

def lsst.cp.pipe.measureCrosstalk.CrosstalkExtractTask.debugView (   self,
  stepname,
  exposure 
)
Utility function to examine the image being processed.

Parameters
----------
stepname : `str`
    State of processing to view.
exposure : `lsst.afw.image.Exposure`
    Exposure to view.

Definition at line 260 of file measureCrosstalk.py.

260  def debugView(self, stepname, exposure):
261  """Utility function to examine the image being processed.
262 
263  Parameters
264  ----------
265  stepname : `str`
266  State of processing to view.
267  exposure : `lsst.afw.image.Exposure`
268  Exposure to view.
269  """
270  frame = getDebugFrame(self._display, stepname)
271  if frame:
272  display = getDisplay(frame)
273  display.scale('asinh', 'zscale')
274  display.mtv(exposure)
275 
276  prompt = "Press Enter to continue: "
277  while True:
278  ans = input(prompt).lower()
279  if ans in ("", "c",):
280  break
281 

◆ run()

def lsst.cp.pipe.measureCrosstalk.CrosstalkExtractTask.run (   self,
  inputExp,
  sourceExps = [] 
)
Measure pixel ratios between amplifiers in inputExp.

Extract crosstalk ratios between different amplifiers.

For pixels above ``config.threshold``, we calculate the ratio
between each background-subtracted target amp and the source
amp. We return a list of ratios for each pixel for each
target/source combination, as nested dictionary containing the
ratio.

Parameters
----------
inputExp : `lsst.afw.image.Exposure`
    Input exposure to measure pixel ratios on.
sourceExp : `list` [`lsst.afw.image.Exposure`], optional
    List of chips to use as sources to measure inter-chip
    crosstalk.

Returns
-------
results : `lsst.pipe.base.Struct`
    The results struct containing:

    ``outputRatios`` : `dict` [`dict` [`dict` [`dict` [`list`]]]]
         A catalog of ratio lists.  The dictionaries are
         indexed such that:
         outputRatios[targetChip][sourceChip][targetAmp][sourceAmp]
         contains the ratio list for that combination.
    ``outputFluxes`` : `dict` [`dict` [`list`]]
         A catalog of flux lists.  The dictionaries are
         indexed such that:
         outputFluxes[sourceChip][sourceAmp]
         contains the flux list used in the outputRatios.

Notes
-----
The lsstDebug.Info() method can be rewritten for __name__ =
`lsst.cp.pipe.measureCrosstalk`, and supports the parameters:

debug.display['extract'] : `bool`
    Display the exposure under consideration, with the pixels used
    for crosstalk measurement indicated by the DETECTED mask plane.
debug.display['pixels'] : `bool`
    Display a plot of the ratio calculated for each pixel used in this
    exposure, split by amplifier pairs.  The median value is listed
    for reference.

Definition at line 134 of file measureCrosstalk.py.

134  def run(self, inputExp, sourceExps=[]):
135  """Measure pixel ratios between amplifiers in inputExp.
136 
137  Extract crosstalk ratios between different amplifiers.
138 
139  For pixels above ``config.threshold``, we calculate the ratio
140  between each background-subtracted target amp and the source
141  amp. We return a list of ratios for each pixel for each
142  target/source combination, as nested dictionary containing the
143  ratio.
144 
145  Parameters
146  ----------
147  inputExp : `lsst.afw.image.Exposure`
148  Input exposure to measure pixel ratios on.
149  sourceExp : `list` [`lsst.afw.image.Exposure`], optional
150  List of chips to use as sources to measure inter-chip
151  crosstalk.
152 
153  Returns
154  -------
155  results : `lsst.pipe.base.Struct`
156  The results struct containing:
157 
158  ``outputRatios`` : `dict` [`dict` [`dict` [`dict` [`list`]]]]
159  A catalog of ratio lists. The dictionaries are
160  indexed such that:
161  outputRatios[targetChip][sourceChip][targetAmp][sourceAmp]
162  contains the ratio list for that combination.
163  ``outputFluxes`` : `dict` [`dict` [`list`]]
164  A catalog of flux lists. The dictionaries are
165  indexed such that:
166  outputFluxes[sourceChip][sourceAmp]
167  contains the flux list used in the outputRatios.
168 
169  Notes
170  -----
171  The lsstDebug.Info() method can be rewritten for __name__ =
172  `lsst.cp.pipe.measureCrosstalk`, and supports the parameters:
173 
174  debug.display['extract'] : `bool`
175  Display the exposure under consideration, with the pixels used
176  for crosstalk measurement indicated by the DETECTED mask plane.
177  debug.display['pixels'] : `bool`
178  Display a plot of the ratio calculated for each pixel used in this
179  exposure, split by amplifier pairs. The median value is listed
180  for reference.
181  """
182  outputRatios = defaultdict(lambda: defaultdict(dict))
183  outputFluxes = defaultdict(lambda: defaultdict(dict))
184 
185  threshold = self.config.threshold
186  badPixels = list(self.config.badMask)
187 
188  targetDetector = inputExp.getDetector()
189  targetChip = targetDetector.getName()
190 
191  # Always look at the target chip first, then go to any other supplied exposures.
192  sourceExtractExps = [inputExp]
193  sourceExtractExps.extend(sourceExps)
194 
195  self.log.info("Measuring full detector background for target: %s", targetChip)
196  targetIm = inputExp.getMaskedImage()
197  FootprintSet(targetIm, Threshold(threshold), "DETECTED")
198  detected = targetIm.getMask().getPlaneBitMask("DETECTED")
199  bg = CrosstalkCalib.calculateBackground(targetIm, badPixels + ["DETECTED"])
200 
201  self.debugView('extract', inputExp)
202 
203  for sourceExp in sourceExtractExps:
204  sourceDetector = sourceExp.getDetector()
205  sourceChip = sourceDetector.getName()
206  sourceIm = sourceExp.getMaskedImage()
207  bad = sourceIm.getMask().getPlaneBitMask(badPixels)
208  self.log.info("Measuring crosstalk from source: %s", sourceChip)
209 
210  if sourceExp != inputExp:
211  FootprintSet(sourceIm, Threshold(threshold), "DETECTED")
212  detected = sourceIm.getMask().getPlaneBitMask("DETECTED")
213 
214  # The dictionary of amp-to-amp ratios for this pair of source->target detectors.
215  ratioDict = defaultdict(lambda: defaultdict(list))
216  extractedCount = 0
217 
218  for sourceAmp in sourceDetector:
219  sourceAmpName = sourceAmp.getName()
220  sourceAmpBBox = sourceAmp.getBBox() if self.config.isTrimmed else sourceAmp.getRawDataBBox()
221  sourceAmpImage = sourceIm[sourceAmpBBox]
222  sourceMask = sourceAmpImage.mask.array
223  select = ((sourceMask & detected > 0)
224  & (sourceMask & bad == 0)
225  & np.isfinite(sourceAmpImage.image.array))
226  count = np.sum(select)
227  self.log.debug(" Source amplifier: %s", sourceAmpName)
228 
229  outputFluxes[sourceChip][sourceAmpName] = sourceAmpImage.image.array[select].tolist()
230 
231  for targetAmp in targetDetector:
232  # iterate over targetExposure
233  targetAmpName = targetAmp.getName()
234  if sourceAmpName == targetAmpName and sourceChip == targetChip:
235  ratioDict[sourceAmpName][targetAmpName] = []
236  continue
237  self.log.debug(" Target amplifier: %s", targetAmpName)
238 
239  targetAmpImage = CrosstalkCalib.extractAmp(targetIm.image,
240  targetAmp, sourceAmp,
241  isTrimmed=self.config.isTrimmed)
242  ratios = (targetAmpImage.array[select] - bg)/sourceAmpImage.image.array[select]
243  ratioDict[targetAmpName][sourceAmpName] = ratios.tolist()
244  extractedCount += count
245 
246  self.debugPixels('pixels',
247  sourceAmpImage.image.array[select],
248  targetAmpImage.array[select] - bg,
249  sourceAmpName, targetAmpName)
250 
251  self.log.info("Extracted %d pixels from %s -> %s (targetBG: %f)",
252  extractedCount, sourceChip, targetChip, bg)
253  outputRatios[targetChip][sourceChip] = ratioDict
254 
255  return pipeBase.Struct(
256  outputRatios=ddict2dict(outputRatios),
257  outputFluxes=ddict2dict(outputFluxes)
258  )
259 
daf::base::PropertyList * list
Definition: fits.cc:913
def ddict2dict(d)
Definition: utils.py:806
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)

Member Data Documentation

◆ ConfigClass

lsst.cp.pipe.measureCrosstalk.CrosstalkExtractTask.ConfigClass = CrosstalkExtractConfig
static

Definition at line 131 of file measureCrosstalk.py.


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