LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask Class Reference
Inheritance diagram for lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask:

Public Member Functions

def __init__
 
def run
 
def getTempExpRefList
 
def getBackgroundReferenceScaler
 
def prepareInputs
 
def backgroundMatching
 
def assemble
 
def assembleMetadata
 
def assembleSubregion
 
def addBackgroundMatchingMetadata
 

Static Public Attributes

 ConfigClass = AssembleCoaddConfig
 

Private Member Functions

def _makeArgumentParser
 

Static Private Attributes

string _DefaultName = "assembleCoadd"
 

Detailed Description

Assemble a coadd from a set of coaddTempExp

Definition at line 122 of file assembleCoadd.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.__init__ (   self,
  args,
  kwargs 
)

Definition at line 128 of file assembleCoadd.py.

129  def __init__(self, *args, **kwargs):
130  CoaddBaseTask.__init__(self, *args, **kwargs)
131  self.makeSubtask("interpImage")
132  self.makeSubtask("matchBackgrounds")
133  self.makeSubtask("scaleZeroPoint")

Member Function Documentation

def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask._makeArgumentParser (   cls)
private
Create an argument parser

Definition at line 520 of file assembleCoadd.py.

521  def _makeArgumentParser(cls):
522  """Create an argument parser
523  """
524  parser = pipeBase.ArgumentParser(name=cls._DefaultName)
525  parser.add_id_argument("--id", cls.ConfigClass().coaddName + "Coadd_tempExp",
526  help="data ID, e.g. --id tract=12345 patch=1,2",
527  ContainerClass=AssembleCoaddDataIdContainer)
528  parser.add_id_argument("--selectId", "calexp", help="data ID, e.g. --selectId visit=6789 ccd=0..9",
529  ContainerClass=SelectDataIdContainer)
530  return parser
531 
532 
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.addBackgroundMatchingMetadata (   self,
  coaddExposure,
  tempExpRefList,
  backgroundInfoList 
)
Add metadata from the background matching to the coadd

@param coaddExposure: Coadd
@param backgroundInfoList: List of background info, results from background matching

Definition at line 499 of file assembleCoadd.py.

500  def addBackgroundMatchingMetadata(self, coaddExposure, tempExpRefList, backgroundInfoList):
501  """Add metadata from the background matching to the coadd
502 
503  @param coaddExposure: Coadd
504  @param backgroundInfoList: List of background info, results from background matching
505  """
506  self.log.info("Adding exposure information to metadata")
507  metadata = coaddExposure.getMetadata()
508  metadata.addString("CTExp_SDQA1_DESCRIPTION",
509  "Background matching: Ratio of matchedMSE / diffImVar")
510  for ind, (tempExpRef, backgroundInfo) in enumerate(zip(tempExpRefList, backgroundInfoList)):
511  tempExpStr = '&'.join('%s=%s' % (k,v) for k,v in tempExpRef.dataId.items())
512  if backgroundInfo.isReference:
513  metadata.addString("ReferenceExp_ID", tempExpStr)
514  else:
515  metadata.addString("CTExp_ID_%d" % (ind), tempExpStr)
516  metadata.addDouble("CTExp_SDQA1_%d" % (ind),
517  backgroundInfo.matchedMSE/backgroundInfo.diffImVar)
518  metadata.addDouble("CTExp_SDQA2_%d" % (ind),
backgroundInfo.fitRMS)
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.assemble (   self,
  skyInfo,
  tempExpRefList,
  imageScalerList,
  weightList,
  bgInfoList = None 
)
Assemble a coadd from input warps

The assembly is performed over small areas on the image at a time, to
conserve memory usage.

@param skyInfo: Patch geometry information, from getSkyInfo
@param tempExpRefList: List of data references to tempExp
@param imageScalerList: List of image scalers
@param weightList: List of weights
@param bgInfoList: List of background data from background matching
@return coadded exposure

Definition at line 372 of file assembleCoadd.py.

373  def assemble(self, skyInfo, tempExpRefList, imageScalerList, weightList, bgInfoList=None):
374  """Assemble a coadd from input warps
375 
376  The assembly is performed over small areas on the image at a time, to
377  conserve memory usage.
378 
379  @param skyInfo: Patch geometry information, from getSkyInfo
380  @param tempExpRefList: List of data references to tempExp
381  @param imageScalerList: List of image scalers
382  @param weightList: List of weights
383  @param bgInfoList: List of background data from background matching
384  @return coadded exposure
385  """
386  tempExpName = self.getTempExpDatasetName()
387  self.log.info("Assembling %s %s" % (len(tempExpRefList), tempExpName))
388 
389  statsCtrl = afwMath.StatisticsControl()
390  statsCtrl.setNumSigmaClip(self.config.sigmaClip)
391  statsCtrl.setNumIter(self.config.clipIter)
392  statsCtrl.setAndMask(self.getBadPixelMask())
393  statsCtrl.setNanSafe(True)
394  statsCtrl.setWeighted(True)
395  statsCtrl.setCalcErrorFromInputVariance(True)
396  for plane, threshold in self.config.maskPropagationThresholds.items():
397  bit = afwImage.MaskU.getMaskPlane(plane)
398  statsCtrl.setMaskPropagationThreshold(bit, threshold)
399 
400  if self.config.doSigmaClip:
401  statsFlags = afwMath.MEANCLIP
402  else:
403  statsFlags = afwMath.MEAN
404 
405  if bgInfoList is None:
406  bgInfoList = [None]*len(tempExpRefList)
407 
408  coaddExposure = afwImage.ExposureF(skyInfo.bbox, skyInfo.wcs)
409  coaddExposure.setCalib(self.scaleZeroPoint.getCalib())
410  coaddExposure.getInfo().setCoaddInputs(self.inputRecorder.makeCoaddInputs())
411  self.assembleMetadata(coaddExposure, tempExpRefList, weightList)
412  coaddMaskedImage = coaddExposure.getMaskedImage()
413  subregionSizeArr = self.config.subregionSize
414  subregionSize = afwGeom.Extent2I(subregionSizeArr[0], subregionSizeArr[1])
415  for subBBox in _subBBoxIter(skyInfo.bbox, subregionSize):
416  try:
417  self.assembleSubregion(coaddExposure, subBBox, tempExpRefList, imageScalerList,
418  weightList, bgInfoList, statsFlags, statsCtrl)
419  except Exception, e:
420  self.log.fatal("Cannot compute coadd %s: %s" % (subBBox, e,))
421 
422  coaddUtils.setCoaddEdgeBits(coaddMaskedImage.getMask(), coaddMaskedImage.getVariance())
423 
424  return coaddExposure
void setCoaddEdgeBits(lsst::afw::image::Mask< lsst::afw::image::MaskPixel > &coaddMask, lsst::afw::image::Image< WeightPixelT > const &weightMap)
set edge bits of coadd mask based on weight map
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
Definition: Statistics.h:92
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.assembleMetadata (   self,
  coaddExposure,
  tempExpRefList,
  weightList 
)
Set the metadata for the coadd

This basic implementation simply sets the filter from the
first input.

@param coaddExposure: The target image for the coadd
@param tempExpRefList: List of data references to tempExp
@param weightList: List of weights

Definition at line 425 of file assembleCoadd.py.

426  def assembleMetadata(self, coaddExposure, tempExpRefList, weightList):
427  """Set the metadata for the coadd
428 
429  This basic implementation simply sets the filter from the
430  first input.
431 
432  @param coaddExposure: The target image for the coadd
433  @param tempExpRefList: List of data references to tempExp
434  @param weightList: List of weights
435  """
436  tempExpName = self.getTempExpDatasetName()
437  # We load a single pixel of each coaddTempExp, because we just want to get at the metadata
438  # (and we need more than just the PropertySet that contains the header). See #2777.
440  first = True
441  coaddInputs = coaddExposure.getInfo().getCoaddInputs()
442  for tempExpRef, weight in zip(tempExpRefList, weightList):
443  tempExp = tempExpRef.get(tempExpName + "_sub", bbox=bbox, imageOrigin="LOCAL", immediate=True)
444  if first:
445  coaddExposure.setFilter(tempExp.getFilter())
446  first = False
447  self.inputRecorder.addVisitToCoadd(coaddInputs, tempExp, weight)
448  coaddInputs.visits.sort()
449  if self.config.doPsfMatch:
450  psf = self.config.modelPsf.apply()
451  else:
452  psf = measAlg.CoaddPsf(coaddInputs.ccds, coaddExposure.getWcs())
453  coaddExposure.setPsf(psf)
454  apCorrMap = measAlg.makeCoaddApCorrMap(coaddInputs.ccds, coaddExposure.getBBox(afwImage.PARENT),
455  coaddExposure.getWcs())
456  coaddExposure.getInfo().setApCorrMap(apCorrMap)
An integer coordinate rectangle.
Definition: Box.h:53
CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
Definition: CoaddPsf.h:45
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.assembleSubregion (   self,
  coaddExposure,
  bbox,
  tempExpRefList,
  imageScalerList,
  weightList,
  bgInfoList,
  statsFlags,
  statsCtrl 
)
Assemble the coadd for a sub-region

@param coaddExposure: The target image for the coadd
@param bbox: Sub-region to coadd
@param tempExpRefList: List of data reference to tempExp
@param imageScalerList: List of image scalers
@param weightList: List of weights
@param bgInfoList: List of background data from background matching
@param statsFlags: Statistic for coadd
@param statsCtrl: Statistics control object for coadd

Definition at line 458 of file assembleCoadd.py.

459  bgInfoList, statsFlags, statsCtrl):
460  """Assemble the coadd for a sub-region
461 
462  @param coaddExposure: The target image for the coadd
463  @param bbox: Sub-region to coadd
464  @param tempExpRefList: List of data reference to tempExp
465  @param imageScalerList: List of image scalers
466  @param weightList: List of weights
467  @param bgInfoList: List of background data from background matching
468  @param statsFlags: Statistic for coadd
469  @param statsCtrl: Statistics control object for coadd
470  """
471  self.log.logdebug("Computing coadd over %s" % bbox)
472  tempExpName = self.getTempExpDatasetName()
473  coaddMaskedImage = coaddExposure.getMaskedImage()
474  coaddView = afwImage.MaskedImageF(coaddMaskedImage, bbox, afwImage.PARENT, False)
475  maskedImageList = afwImage.vectorMaskedImageF() # [] is rejected by afwMath.statisticsStack
476  for tempExpRef, imageScaler, bgInfo in zip(tempExpRefList, imageScalerList, bgInfoList):
477  exposure = tempExpRef.get(tempExpName + "_sub", bbox=bbox)
478  maskedImage = exposure.getMaskedImage()
479  imageScaler.scaleMaskedImage(maskedImage)
480 
481  if self.config.doMatchBackgrounds and not bgInfo.isReference:
482  backgroundModel = bgInfo.backgroundModel
483  backgroundImage = backgroundModel.getImage() if \
484  self.matchBackgrounds.config.usePolynomial else \
485  backgroundModel.getImageF()
486  backgroundImage.setXY0(coaddMaskedImage.getXY0())
487  maskedImage += backgroundImage.Factory(backgroundImage, bbox, afwImage.PARENT, False)
488  var = maskedImage.getVariance()
489  var += (bgInfo.fitRMS)**2
490 
491  maskedImageList.append(maskedImage)
492 
493  with self.timer("stack"):
494  coaddSubregion = afwMath.statisticsStack(
495  maskedImageList, statsFlags, statsCtrl, weightList)
496 
497  coaddView <<= coaddSubregion
498 
lsst::afw::image::MaskedImage< PixelT >::Ptr statisticsStack(lsst::afw::image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
A function to compute statistics on the rows or columns of an image.
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.backgroundMatching (   self,
  inputData,
  refExpDataRef = None,
  refImageScaler = None 
)
Perform background matching on the prepared inputs

If no reference is provided, the background matcher will select one.

This method returns a new inputData Struct that can replace the original.

@param inputData: Struct from prepareInputs() with tempExpRefList, weightList, imageScalerList
@param refExpDataRef: Data reference for background reference tempExp, or None
@param refImageScaler: Image scaler for background reference tempExp, or None
@return Struct:
- tempExprefList: List of data references to tempExp
- weightList: List of weightings
- imageScalerList: List of image scalers
- backgroundInfoList: result from background matching

Definition at line 302 of file assembleCoadd.py.

303  def backgroundMatching(self, inputData, refExpDataRef=None, refImageScaler=None):
304  """Perform background matching on the prepared inputs
305 
306  If no reference is provided, the background matcher will select one.
307 
308  This method returns a new inputData Struct that can replace the original.
309 
310  @param inputData: Struct from prepareInputs() with tempExpRefList, weightList, imageScalerList
311  @param refExpDataRef: Data reference for background reference tempExp, or None
312  @param refImageScaler: Image scaler for background reference tempExp, or None
313  @return Struct:
314  - tempExprefList: List of data references to tempExp
315  - weightList: List of weightings
316  - imageScalerList: List of image scalers
317  - backgroundInfoList: result from background matching
318  """
319  try:
320  backgroundInfoList = self.matchBackgrounds.run(
321  expRefList = inputData.tempExpRefList,
322  imageScalerList = inputData.imageScalerList,
323  refExpDataRef = refExpDataRef if not self.config.autoReference else None,
324  refImageScaler = refImageScaler,
325  expDatasetType = self.getTempExpDatasetName(),
326  ).backgroundInfoList
327  except Exception, e:
328  self.log.fatal("Cannot match backgrounds: %s" % (e))
329  raise pipeBase.TaskError("Background matching failed.")
330 
331  newWeightList = []
332  newTempExpRefList = []
333  newBackgroundStructList = []
334  newScaleList = []
335  # the number of good backgrounds may be < than len(tempExpList)
336  # sync these up and correct the weights
337  for tempExpRef, bgInfo, scaler, weight in zip(inputData.tempExpRefList, backgroundInfoList,
338  inputData.imageScalerList, inputData.weightList):
339  if not bgInfo.isReference:
340  # skip exposure if it has no backgroundModel
341  # or if fit was bad
342  if (bgInfo.backgroundModel is None):
343  self.log.info("No background offset model available for %s: skipping"%(
344  tempExpRef.dataId))
345  continue
346  try:
347  varianceRatio = bgInfo.matchedMSE / bgInfo.diffImVar
348  except Exception, e:
349  self.log.info("MSE/Var ratio not calculable (%s) for %s: skipping" %
350  (e, tempExpRef.dataId,))
351  continue
352  if not numpy.isfinite(varianceRatio):
353  self.log.info("MSE/Var ratio not finite (%.2f / %.2f) for %s: skipping" %
354  (bgInfo.matchedMSE, bgInfo.diffImVar,
355  tempExpRef.dataId,))
356  continue
357  elif (varianceRatio > self.config.maxMatchResidualRatio):
358  self.log.info("Bad fit. MSE/Var ratio %.2f > %.2f for %s: skipping" % (
359  varianceRatio, self.config.maxMatchResidualRatio, tempExpRef.dataId,))
360  continue
361  elif ( bgInfo.fitRMS > self.config.maxMatchResidualRMS):
362  self.log.info("Bad fit. RMS %.2f > %.2f for %s: skipping" % (
363  bgInfo.fitRMS, self.config.maxMatchResidualRMS, tempExpRef.dataId,))
364  continue
365  newWeightList.append(1 / (1 / weight + bgInfo.fitRMS**2))
366  newTempExpRefList.append(tempExpRef)
367  newBackgroundStructList.append(bgInfo)
368  newScaleList.append(scaler)
369 
370  return pipeBase.Struct(tempExpRefList=newTempExpRefList, weightList=newWeightList,
371  imageScalerList=newScaleList, backgroundInfoList=newBackgroundStructList)
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.getBackgroundReferenceScaler (   self,
  dataRef 
)
Construct an image scaler for the background reference frame

If there is no reference frame ('autoReference'), then this is a no-op
and None is returned

@param dataRef: Data reference for the background reference frame, or None
@return image scaler, or None

Definition at line 216 of file assembleCoadd.py.

217  def getBackgroundReferenceScaler(self, dataRef):
218  """Construct an image scaler for the background reference frame
219 
220  If there is no reference frame ('autoReference'), then this is a no-op
221  and None is returned
222 
223  @param dataRef: Data reference for the background reference frame, or None
224  @return image scaler, or None
225  """
226  if self.config.autoReference:
227  return None
228 
229  # We've been given the data reference
230  dataset = self.getTempExpDatasetName()
231  if not dataRef.datasetExists(dataset):
232  raise RuntimeError("Could not find reference exposure %s %s." % (dataset, dataRef.dataId))
233 
234  refExposure = dataRef.get(self.getTempExpDatasetName(), immediate=True)
235  refImageScaler = self.scaleZeroPoint.computeImageScaler(
236  exposure = refExposure,
237  dataRef = dataRef,
238  )
239  return refImageScaler
240 
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.getTempExpRefList (   self,
  patchRef,
  calExpRefList 
)
Generate list of coaddTempExp data references

@param patchRef: Data reference for patch
@param calExpRefList: List of data references for input calexps
@return List of coaddTempExp data references

Definition at line 202 of file assembleCoadd.py.

203  def getTempExpRefList(self, patchRef, calExpRefList):
204  """Generate list of coaddTempExp data references
205 
206  @param patchRef: Data reference for patch
207  @param calExpRefList: List of data references for input calexps
208  @return List of coaddTempExp data references
209  """
210  butler = patchRef.getButler()
211  groupData = groupPatchExposures(patchRef, calExpRefList, self.getCoaddDatasetName(),
212  self.getTempExpDatasetName())
213  tempExpRefList = [getGroupDataRef(butler, self.getTempExpDatasetName(), g, groupData.keys) for
214  g in groupData.groups.keys()]
215  return tempExpRefList
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.prepareInputs (   self,
  refList 
)
Prepare the input warps for coaddition

This involves measuring weights and constructing image scalers
for each of the inputs.

@param refList: List of data references to tempExp
@return Struct:
- tempExprefList: List of data references to tempExp
- weightList: List of weightings
- imageScalerList: List of image scalers

Definition at line 241 of file assembleCoadd.py.

242  def prepareInputs(self, refList):
243  """Prepare the input warps for coaddition
244 
245  This involves measuring weights and constructing image scalers
246  for each of the inputs.
247 
248  @param refList: List of data references to tempExp
249  @return Struct:
250  - tempExprefList: List of data references to tempExp
251  - weightList: List of weightings
252  - imageScalerList: List of image scalers
253  """
254  statsCtrl = afwMath.StatisticsControl()
255  statsCtrl.setNumSigmaClip(self.config.sigmaClip)
256  statsCtrl.setNumIter(self.config.clipIter)
257  statsCtrl.setAndMask(self.getBadPixelMask())
258  statsCtrl.setNanSafe(True)
259 
260  # compute tempExpRefList: a list of tempExpRef that actually exist
261  # and weightList: a list of the weight of the associated coadd tempExp
262  # and imageScalerList: a list of scale factors for the associated coadd tempExp
263  tempExpRefList = []
264  weightList = []
265  imageScalerList = []
266  tempExpName = self.getTempExpDatasetName()
267  for tempExpRef in refList:
268  if not tempExpRef.datasetExists(tempExpName):
269  self.log.warn("Could not find %s %s; skipping it" % (tempExpName, tempExpRef.dataId))
270  continue
271 
272  tempExp = tempExpRef.get(tempExpName, immediate=True)
273  maskedImage = tempExp.getMaskedImage()
274  imageScaler = self.scaleZeroPoint.computeImageScaler(
275  exposure = tempExp,
276  dataRef = tempExpRef,
277  )
278  try:
279  imageScaler.scaleMaskedImage(maskedImage)
280  except Exception, e:
281  self.log.warn("Scaling failed for %s (skipping it): %s" % (tempExpRef.dataId, e))
282  continue
283  statObj = afwMath.makeStatistics(maskedImage.getVariance(), maskedImage.getMask(),
284  afwMath.MEANCLIP, statsCtrl)
285  meanVar, meanVarErr = statObj.getResult(afwMath.MEANCLIP);
286  weight = 1.0 / float(meanVar)
287  if not numpy.isfinite(weight):
288  self.log.warn("Non-finite weight for %s: skipping" % (tempExpRef.dataId,))
289  continue
290  self.log.info("Weight of %s %s = %0.3f" % (tempExpName, tempExpRef.dataId, weight))
291 
292  del maskedImage
293  del tempExp
294 
295  tempExpRefList.append(tempExpRef)
296  weightList.append(weight)
297  imageScalerList.append(imageScaler)
298 
299  return pipeBase.Struct(tempExpRefList=tempExpRefList, weightList=weightList,
300  imageScalerList=imageScalerList)
301 
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
Definition: Statistics.h:92
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082
def lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.run (   self,
  dataRef,
  selectDataList = [] 
)
Assemble a coadd from a set of coaddTempExp

The coadd is computed as a mean with optional outlier rejection.

AssumeCoaddTask performs coaddition of "coadd temporary exposures" ("coaddTempExps").  Each
coaddTempExp is the size of a patch and contains data for one run, visit or (for a non-mosaic camera)
exposure. The coaddTempExps to coadd are selected from the provided selectDataList based on their
overlap with the patch specified by dataRef.

By default, coaddTempExps contain backgrounds and hence require config.doMatchBackgrounds=True.
Background-subtracted coaddTempExps can be coadded by setting config.doMatchBackgrounds=False.

When background matching is enabled, the task may be configured to automatically select a reference
exposure (config.autoReference=True). If this is not done, then we require that the input dataRef
provides access to a coaddTempExp (dataset type coaddName + 'Coadd_tempExp') which is used as the
reference exposure.

@param dataRef: Data reference defining the patch for coaddition and the reference coaddTempExp
        (if config.autoReference=False). Used to access the following data products:
        - [in] self.config.coaddName + "Coadd_skyMap"
        - [in] self.config.coaddName + "Coadd_tempExp" (optionally)
        - [out] self.config.coaddName + "Coadd"
@param selectDataList[in]: List of data references to coaddTempExp. Data to be coadded will be
                   selected from this list based on overlap with the patch defined by dataRef.

@return: a pipeBase.Struct with fields:
 - coaddExposure: coadded exposure

Definition at line 135 of file assembleCoadd.py.

136  def run(self, dataRef, selectDataList=[]):
137  """Assemble a coadd from a set of coaddTempExp
138 
139  The coadd is computed as a mean with optional outlier rejection.
140 
141  AssumeCoaddTask performs coaddition of "coadd temporary exposures" ("coaddTempExps"). Each
142  coaddTempExp is the size of a patch and contains data for one run, visit or (for a non-mosaic camera)
143  exposure. The coaddTempExps to coadd are selected from the provided selectDataList based on their
144  overlap with the patch specified by dataRef.
145 
146  By default, coaddTempExps contain backgrounds and hence require config.doMatchBackgrounds=True.
147  Background-subtracted coaddTempExps can be coadded by setting config.doMatchBackgrounds=False.
148 
149  When background matching is enabled, the task may be configured to automatically select a reference
150  exposure (config.autoReference=True). If this is not done, then we require that the input dataRef
151  provides access to a coaddTempExp (dataset type coaddName + 'Coadd_tempExp') which is used as the
152  reference exposure.
153 
154  @param dataRef: Data reference defining the patch for coaddition and the reference coaddTempExp
155  (if config.autoReference=False). Used to access the following data products:
156  - [in] self.config.coaddName + "Coadd_skyMap"
157  - [in] self.config.coaddName + "Coadd_tempExp" (optionally)
158  - [out] self.config.coaddName + "Coadd"
159  @param selectDataList[in]: List of data references to coaddTempExp. Data to be coadded will be
160  selected from this list based on overlap with the patch defined by dataRef.
161 
162  @return: a pipeBase.Struct with fields:
163  - coaddExposure: coadded exposure
164  """
165  skyInfo = self.getSkyInfo(dataRef)
166  calExpRefList = self.selectExposures(dataRef, skyInfo, selectDataList=selectDataList)
167  if len(calExpRefList) == 0:
168  self.log.warn("No exposures to coadd")
169  return
170  self.log.info("Coadding %d exposures" % len(calExpRefList))
171 
172  tempExpRefList = self.getTempExpRefList(dataRef, calExpRefList)
173  inputData = self.prepareInputs(tempExpRefList)
174  self.log.info("Found %d %s" % (len(inputData.tempExpRefList), self.getTempExpDatasetName()))
175  if len(inputData.tempExpRefList) == 0:
176  self.log.warn("No coadd temporary exposures found")
177  return
178  if self.config.doMatchBackgrounds:
179  refImageScaler = self.getBackgroundReferenceScaler(dataRef)
180  inputData = self.backgroundMatching(inputData, dataRef, refImageScaler)
181  if len(inputData.tempExpRefList) == 0:
182  self.log.warn("No valid background models")
183  return
184 
185  coaddExp = self.assemble(skyInfo, inputData.tempExpRefList, inputData.imageScalerList,
186  inputData.weightList,
187  inputData.backgroundInfoList if self.config.doMatchBackgrounds else None)
188  if self.config.doMatchBackgrounds:
189  self.addBackgroundMatchingMetadata(coaddExp, inputData.tempExpRefList,
190  inputData.backgroundInfoList)
191 
192  if self.config.doInterp:
193  self.interpImage.interpolateOnePlane(maskedImage=coaddExp.getMaskedImage(), planeName="NO_DATA")
194  # The variance must be positive; work around for DM-3201.
195  varArray = coaddExp.getMaskedImage().getVariance().getArray()
196  varArray[:] = numpy.where(varArray > 0, varArray, numpy.inf)
197 
198  if self.config.doWrite:
199  self.writeCoaddOutput(dataRef, coaddExp)
200 
201  return pipeBase.Struct(coaddExposure=coaddExp)

Member Data Documentation

string lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask._DefaultName = "assembleCoadd"
staticprivate

Definition at line 126 of file assembleCoadd.py.

lsst.pipe.tasks.assembleCoadd.AssembleCoaddTask.ConfigClass = AssembleCoaddConfig
static

Definition at line 125 of file assembleCoadd.py.


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