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 Attributes | List of all members
lsst.coadd.utils.coadd.Coadd Class Reference
Inheritance diagram for lsst.coadd.utils.coadd.Coadd:

Public Member Functions

def __init__
 
def fromConfig
 
def addExposure
 
def getCoadd
 
def getFilters
 
def getBadPixelMask
 
def getBBox
 
def getWcs
 
def getWeightMap
 

Static Public Attributes

 ConfigClass = CoaddConfig
 

Private Attributes

 _log
 
 _bbox
 
 _wcs
 
 _badPixelMask
 
 _coadd
 
 _weightMap
 
 _filterDict
 
 _statsControl
 

Detailed Description

Coadd by weighted addition

This class may be subclassed to implement other coadd techniques.
Typically this is done by overriding addExposure.

Definition at line 42 of file coadd.py.

Constructor & Destructor Documentation

def lsst.coadd.utils.coadd.Coadd.__init__ (   self,
  bbox,
  wcs,
  badMaskPlanes,
  logName = "coadd.utils.Coadd" 
)
Create a coadd

@param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I):
    coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin()
@param[in] wcs: WCS of coadd exposure (lsst.afw.math.Wcs)
@param[in] badMaskPlanes: mask planes to pay attention to when rejecting masked pixels.
    Specify as a collection of names.
    badMaskPlanes should always include "NO_DATA".
@param[in] logName: name by which messages are logged

Definition at line 50 of file coadd.py.

50 
51  def __init__(self, bbox, wcs, badMaskPlanes, logName="coadd.utils.Coadd"):
52  """Create a coadd
53 
54  @param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I):
55  coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin()
56  @param[in] wcs: WCS of coadd exposure (lsst.afw.math.Wcs)
57  @param[in] badMaskPlanes: mask planes to pay attention to when rejecting masked pixels.
58  Specify as a collection of names.
59  badMaskPlanes should always include "NO_DATA".
60  @param[in] logName: name by which messages are logged
61  """
62  self._log = Log(Log.getDefaultLog(), logName)
63  self._bbox = bbox
64  self._wcs = wcs
65  self._badPixelMask = afwImage.MaskU.getPlaneBitMask(badMaskPlanes)
66  self._coadd = afwImage.ExposureF(bbox, wcs)
67  self._weightMap = afwImage.ImageF(bbox)
68  self._filterDict = dict() # dict of filter name: filter object for all filters seen so far
69 
71  self._statsControl.setNumSigmaClip(3.0)
72  self._statsControl.setNumIter(2)
73  self._statsControl.setAndMask(self._badPixelMask)
a place to record messages and descriptions of the state of processing.
Definition: Log.h:154
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
Definition: Statistics.h:92

Member Function Documentation

def lsst.coadd.utils.coadd.Coadd.addExposure (   self,
  exposure,
  weightFactor = 1.0 
)
Add an Exposure to the coadd

@param[in] exposure: Exposure to add to coadd; this should be:
    - background-subtracted or background-matched to the other images being coadded
    - psf-matched to the desired PSF model (optional)
    - warped to match the coadd
    - photometrically scaled to the desired flux magnitude
@param[in] weightFactor: extra weight factor for this exposure

@return
- overlapBBox: region of overlap between exposure and coadd in parent coordinates (afwGeom.Box2I)
- weight: weight with which exposure was added to coadd; weight = weightFactor / clipped mean variance

Subclasses may override to preprocess the exposure or change the way it is added to the coadd.

Definition at line 91 of file coadd.py.

91 
92  def addExposure(self, exposure, weightFactor=1.0):
93  """Add an Exposure to the coadd
94 
95  @param[in] exposure: Exposure to add to coadd; this should be:
96  - background-subtracted or background-matched to the other images being coadded
97  - psf-matched to the desired PSF model (optional)
98  - warped to match the coadd
99  - photometrically scaled to the desired flux magnitude
100  @param[in] weightFactor: extra weight factor for this exposure
101 
102  @return
103  - overlapBBox: region of overlap between exposure and coadd in parent coordinates (afwGeom.Box2I)
104  - weight: weight with which exposure was added to coadd; weight = weightFactor / clipped mean variance
105 
106  Subclasses may override to preprocess the exposure or change the way it is added to the coadd.
107  """
108  maskedImage = exposure.getMaskedImage()
109 
110  # compute the weight
111  statObj = afwMath.makeStatistics(maskedImage.getVariance(), maskedImage.getMask(),
112  afwMath.MEANCLIP, self._statsControl)
113  meanVar = statObj.getResult(afwMath.MEANCLIP)[0]
114  weight = weightFactor / float(meanVar)
115  if math.isnan(weight):
116  raise RuntimeError("Weight is NaN (weightFactor=%s; mean variance=%s)" % (weightFactor, meanVar))
117 
118  # save filter info
119  filter = exposure.getFilter()
120  self._filterDict.setdefault(filter.getName(), filter)
121 
122  self._log.log(Log.INFO, "Add exposure to coadd with weight=%0.3g" % (weight,))
123 
124  overlapBBox = addToCoadd(self._coadd.getMaskedImage(), self._weightMap,
125  maskedImage, self._badPixelMask, weight)
126 
127  return overlapBBox, weight
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082
lsst::afw::geom::Box2I addToCoadd(lsst::afw::image::Image< CoaddPixelT > &coadd, lsst::afw::image::Image< WeightPixelT > &weightMap, lsst::afw::image::Image< CoaddPixelT > const &image, WeightPixelT weight)
add good pixels from an image to a coadd and associated weight map
Definition: addToCoadd.cc:126
def lsst.coadd.utils.coadd.Coadd.fromConfig (   cls,
  bbox,
  wcs,
  config,
  logName = "coadd.utils.Coadd" 
)
Create a coadd

@param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I):
    coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin()
@param[in] wcs: WCS of coadd exposure (lsst.afw.math.Wcs)
@param[in] config: coadd config; an instance of CoaddConfig
@param[in] logName: name by which messages are logged

Definition at line 75 of file coadd.py.

75 
76  def fromConfig(cls, bbox, wcs, config, logName="coadd.utils.Coadd"):
77  """Create a coadd
78 
79  @param[in] bbox: bounding box of coadd Exposure with respect to parent (lsst.afw.geom.Box2I):
80  coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin()
81  @param[in] wcs: WCS of coadd exposure (lsst.afw.math.Wcs)
82  @param[in] config: coadd config; an instance of CoaddConfig
83  @param[in] logName: name by which messages are logged
84  """
85  return cls(
86  bbox = bbox,
87  wcs = wcs,
88  badMaskPlanes = config.badMaskPlanes,
89  logName = logName,
90  )
def lsst.coadd.utils.coadd.Coadd.getBadPixelMask (   self)
Return the bad pixel mask

Definition at line 156 of file coadd.py.

157  def getBadPixelMask(self):
158  """Return the bad pixel mask
159  """
160  return self._badPixelMask
def lsst.coadd.utils.coadd.Coadd.getBBox (   self)
Return the bounding box of the coadd

Definition at line 161 of file coadd.py.

162  def getBBox(self):
163  """Return the bounding box of the coadd
164  """
165  return self._bbox
def lsst.coadd.utils.coadd.Coadd.getCoadd (   self)
Get the coadd exposure for all exposures you have coadded so far

If all exposures in this coadd have the same-named filter then that filter is set in the coadd.
Otherwise the coadd will have the default unknown filter.

@warning: the Calib is not be set.

Definition at line 128 of file coadd.py.

129  def getCoadd(self):
130  """Get the coadd exposure for all exposures you have coadded so far
131 
132  If all exposures in this coadd have the same-named filter then that filter is set in the coadd.
133  Otherwise the coadd will have the default unknown filter.
134 
135  @warning: the Calib is not be set.
136  """
137  # make a deep copy so I can scale it
138  coaddMaskedImage = self._coadd.getMaskedImage()
139  scaledMaskedImage = coaddMaskedImage.Factory(coaddMaskedImage, True)
140 
141  # set the edge pixels
142  setCoaddEdgeBits(scaledMaskedImage.getMask(), self._weightMap)
143 
144  # scale non-edge pixels by weight map
145  scaledMaskedImage /= self._weightMap
146 
147  scaledExposure = afwImage.makeExposure(scaledMaskedImage, self._wcs)
148  if len(self._filterDict) == 1:
149  scaledExposure.setFilter(self._filterDict.values()[0])
150  return scaledExposure
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
Exposure< ImagePixelT, MaskPixelT, VariancePixelT >::Ptr makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, boost::shared_ptr< Wcs const > wcs=boost::shared_ptr< Wcs const >())
Definition: Exposure.h:308
def lsst.coadd.utils.coadd.Coadd.getFilters (   self)
Return a collection of all the filters seen so far in in addExposure

Definition at line 151 of file coadd.py.

152  def getFilters(self):
153  """Return a collection of all the filters seen so far in in addExposure
154  """
155  return self._filterDict.values()
def lsst.coadd.utils.coadd.Coadd.getWcs (   self)
Return the wcs of the coadd

Definition at line 166 of file coadd.py.

167  def getWcs(self):
168  """Return the wcs of the coadd
169  """
170  return self._wcs
def lsst.coadd.utils.coadd.Coadd.getWeightMap (   self)
Return the weight map for all exposures you have coadded so far

The weight map is a float Image of the same dimensions as the coadd; the value of each pixel
is the sum of the weights of all exposures that contributed to that pixel.

Definition at line 171 of file coadd.py.

172  def getWeightMap(self):
173  """Return the weight map for all exposures you have coadded so far
174 
175  The weight map is a float Image of the same dimensions as the coadd; the value of each pixel
176  is the sum of the weights of all exposures that contributed to that pixel.
177  """
178  return self._weightMap

Member Data Documentation

lsst.coadd.utils.coadd.Coadd._badPixelMask
private

Definition at line 64 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._bbox
private

Definition at line 62 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._coadd
private

Definition at line 65 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._filterDict
private

Definition at line 67 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._log
private

Definition at line 61 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._statsControl
private

Definition at line 69 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._wcs
private

Definition at line 63 of file coadd.py.

lsst.coadd.utils.coadd.Coadd._weightMap
private

Definition at line 66 of file coadd.py.

lsst.coadd.utils.coadd.Coadd.ConfigClass = CoaddConfig
static

Definition at line 48 of file coadd.py.


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