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 | Static Private Attributes | List of all members
lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask Class Reference
Inheritance diagram for lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask:

Public Member Functions

def __init__
 
def run
 
def createTempExp
 

Static Public Attributes

 ConfigClass = MakeCoaddTempExpConfig
 

Static Private Attributes

string _DefaultName = "makeCoaddTempExp"
 

Detailed Description

Task to produce <coaddName>Coadd_tempExp images

Definition at line 61 of file makeCoaddTempExp.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.__init__ (   self,
  args,
  kwargs 
)

Definition at line 67 of file makeCoaddTempExp.py.

67 
68  def __init__(self, *args, **kwargs):
69  CoaddBaseTask.__init__(self, *args, **kwargs)
70  self.makeSubtask("warpAndPsfMatch")

Member Function Documentation

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.createTempExp (   self,
  calexpRefList,
  skyInfo,
  visitId = 0 
)
Create a tempExp from inputs

We iterate over the multiple calexps in a single exposure to construct
the warp ("tempExp") of that exposure to the supplied tract/patch.

Pixels that receive no pixels are set to NAN; this is not correct
(violates LSST algorithms group policy), but will be fixed up by
interpolating after the coaddition.

@param calexpRefList: List of data references for calexps that (may)
    overlap the patch of interest
@param skyInfo: Struct from CoaddBaseTask.getSkyInfo() with geometric
    information about the patch
@param visitId: integer identifier for visit, for the table that will
    produce the CoaddPsf
@return warped exposure, or None if no pixels overlap

Definition at line 128 of file makeCoaddTempExp.py.

129  def createTempExp(self, calexpRefList, skyInfo, visitId=0):
130  """Create a tempExp from inputs
131 
132  We iterate over the multiple calexps in a single exposure to construct
133  the warp ("tempExp") of that exposure to the supplied tract/patch.
134 
135  Pixels that receive no pixels are set to NAN; this is not correct
136  (violates LSST algorithms group policy), but will be fixed up by
137  interpolating after the coaddition.
138 
139  @param calexpRefList: List of data references for calexps that (may)
140  overlap the patch of interest
141  @param skyInfo: Struct from CoaddBaseTask.getSkyInfo() with geometric
142  information about the patch
143  @param visitId: integer identifier for visit, for the table that will
144  produce the CoaddPsf
145  @return warped exposure, or None if no pixels overlap
146  """
147  inputRecorder = self.inputRecorder.makeCoaddTempExpRecorder(visitId)
148  coaddTempExp = afwImage.ExposureF(skyInfo.bbox, skyInfo.wcs)
149  coaddTempExp.getMaskedImage().set(numpy.nan, afwImage.MaskU.getPlaneBitMask("NO_DATA"), numpy.inf)
150  totGoodPix = 0
151  didSetMetadata = False
152  modelPsf = self.config.modelPsf.apply() if self.config.doPsfMatch else None
153  for calExpInd, calExpRef in enumerate(calexpRefList):
154  self.log.info("Processing calexp %d of %d for this tempExp: id=%s" %
155  (calExpInd+1, len(calexpRefList), calExpRef.dataId))
156  try:
157  ccdId = calExpRef.get("ccdExposureId", immediate=True)
158  except Exception:
159  ccdId = calExpInd
160  numGoodPix = 0
161  try:
162  # We augment the dataRef here with the tract, which is harmless for loading things
163  # like calexps that don't need the tract, and necessary for meas_mosaic outputs,
164  # which do.
165  calExpRef = calExpRef.butlerSubset.butler.dataRef("calexp", dataId=calExpRef.dataId,
166  tract=skyInfo.tractInfo.getId())
167  calExp = self.getCalExp(calExpRef, bgSubtracted=self.config.bgSubtracted)
168  exposure = self.warpAndPsfMatch.run(calExp, modelPsf=modelPsf, wcs=skyInfo.wcs,
169  maxBBox=skyInfo.bbox).exposure
170  if didSetMetadata:
171  mimg = exposure.getMaskedImage()
172  mimg *= (coaddTempExp.getCalib().getFluxMag0()[0] / exposure.getCalib().getFluxMag0()[0])
173  del mimg
174  numGoodPix = coaddUtils.copyGoodPixels(
175  coaddTempExp.getMaskedImage(), exposure.getMaskedImage(), self.getBadPixelMask())
176  totGoodPix += numGoodPix
177  self.log.logdebug("Calexp %s has %d good pixels in this patch (%.1f%%)" %
178  (calExpRef.dataId, numGoodPix, 100.0*numGoodPix/skyInfo.bbox.getArea()))
179  if numGoodPix > 0 and not didSetMetadata:
180  coaddTempExp.setCalib(exposure.getCalib())
181  coaddTempExp.setFilter(exposure.getFilter())
182  didSetMetadata = True
183  except Exception, e:
184  self.log.warn("Error processing calexp %s; skipping it: %s" % (calExpRef.dataId, e))
185  continue
186  inputRecorder.addCalExp(calExp, ccdId, numGoodPix)
187 
188  inputRecorder.finish(coaddTempExp, totGoodPix)
189  if totGoodPix > 0 and didSetMetadata:
190  coaddTempExp.setPsf(modelPsf if self.config.doPsfMatch else
191  CoaddPsf(inputRecorder.coaddInputs.ccds, skyInfo.wcs))
192 
193  self.log.info("coaddTempExp has %d good pixels (%.1f%%)" %
194  (totGoodPix, 100.0*totGoodPix/skyInfo.bbox.getArea()))
195  return coaddTempExp if totGoodPix > 0 and didSetMetadata else None
CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
Definition: CoaddPsf.h:45
int copyGoodPixels(lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > &destImage, lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const &srcImage, lsst::afw::image::MaskPixel const badPixelMask)
copy good pixels from one masked image to another
def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.run (   self,
  patchRef,
  selectDataList = [] 
)
Produce <coaddName>Coadd_tempExp images

<coaddName>Coadd_tempExp are produced by PSF-matching (optional) and warping.

@param[in] patchRef: data reference for sky map patch. Must include keys "tract", "patch",
    plus the camera-specific filter key (e.g. "filter" or "band")
@return: dataRefList: a list of data references for the new <coaddName>Coadd_tempExp

@warning: this task assumes that all exposures in a coaddTempExp have the same filter.

@warning: this task sets the Calib of the coaddTempExp to the Calib of the first calexp
with any good pixels in the patch. For a mosaic camera the resulting Calib should be ignored
(assembleCoadd should determine zeropoint scaling without referring to it).

Definition at line 72 of file makeCoaddTempExp.py.

72 
73  def run(self, patchRef, selectDataList=[]):
74  """Produce <coaddName>Coadd_tempExp images
75 
76  <coaddName>Coadd_tempExp are produced by PSF-matching (optional) and warping.
77 
78  @param[in] patchRef: data reference for sky map patch. Must include keys "tract", "patch",
79  plus the camera-specific filter key (e.g. "filter" or "band")
80  @return: dataRefList: a list of data references for the new <coaddName>Coadd_tempExp
81 
82  @warning: this task assumes that all exposures in a coaddTempExp have the same filter.
83 
84  @warning: this task sets the Calib of the coaddTempExp to the Calib of the first calexp
85  with any good pixels in the patch. For a mosaic camera the resulting Calib should be ignored
86  (assembleCoadd should determine zeropoint scaling without referring to it).
87  """
88  skyInfo = self.getSkyInfo(patchRef)
89 
90  calExpRefList = self.selectExposures(patchRef, skyInfo, selectDataList=selectDataList)
91  if len(calExpRefList) == 0:
92  self.log.warn("No exposures to coadd for patch %s" % patchRef.dataId)
93  return None
94  self.log.info("Selected %d calexps for patch %s" % (len(calExpRefList), patchRef.dataId))
95  calExpRefList = [calExpRef for calExpRef in calExpRefList if calExpRef.datasetExists("calexp")]
96  self.log.info("Processing %d existing calexps for patch %s" % (len(calExpRefList), patchRef.dataId))
97 
98  groupData = groupPatchExposures(patchRef, calExpRefList, self.getCoaddDatasetName(),
99  self.getTempExpDatasetName())
100  self.log.info("Processing %d tempExps for patch %s" % (len(groupData.groups), patchRef.dataId))
101 
102  dataRefList = []
103  for i, (tempExpTuple, calexpRefList) in enumerate(groupData.groups.iteritems()):
104  tempExpRef = getGroupDataRef(patchRef.getButler(), self.getTempExpDatasetName(),
105  tempExpTuple, groupData.keys)
106  if not self.config.doOverwrite and tempExpRef.datasetExists(datasetType=self.getTempExpDatasetName()):
107  self.log.info("tempCoaddExp %s exists; skipping" % (tempExpRef.dataId,))
108  dataRefList.append(tempExpRef)
109  continue
110  self.log.info("Processing tempExp %d/%d: id=%s" % (i, len(groupData.groups), tempExpRef.dataId))
111 
112  # TODO: mappers should define a way to go from the "grouping keys" to a numeric ID (#2776).
113  # For now, we try to get a long integer "visit" key, and if we can't, we just use the index
114  # of the visit in the list.
115  try:
116  visitId = long(tempExpRef.dataId["visit"])
117  except (KeyError, ValueError):
118  visitId = i
119 
120  exp = self.createTempExp(calexpRefList, skyInfo, visitId)
121  if exp is not None:
122  dataRefList.append(tempExpRef)
123  if self.config.doWrite:
124  self.writeCoaddOutput(tempExpRef, exp, "tempExp")
125  else:
126  self.log.warn("tempExp %s could not be created" % (tempExpRef.dataId,))
127  return dataRefList

Member Data Documentation

string lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask._DefaultName = "makeCoaddTempExp"
staticprivate

Definition at line 65 of file makeCoaddTempExp.py.

lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.ConfigClass = MakeCoaddTempExpConfig
static

Definition at line 64 of file makeCoaddTempExp.py.


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