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 | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
lsst.pipe.tasks.processCoadd.ProcessCoaddTask Class Reference
Inheritance diagram for lsst.pipe.tasks.processCoadd.ProcessCoaddTask:

Public Member Functions

def __init__
 
def scaleVariance
 
def makeIdFactory
 
def getExposureId
 
def run
 
def setIsPrimaryFlag
 

Public Attributes

 dataPrefix
 
 isPatchInnerKey
 
 isTractInnerKey
 
 isPrimaryKey
 

Static Public Attributes

 ConfigClass = ProcessCoaddConfig
 

Private Member Functions

def _makeArgumentParser
 
def _getConfigName
 
def _getMetadataName
 

Static Private Attributes

string _DefaultName = "processCoadd"
 

Detailed Description

Process a Coadd image

Definition at line 66 of file processCoadd.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.processCoadd.ProcessCoaddTask.__init__ (   self,
  kwargs 
)

Definition at line 72 of file processCoadd.py.

72 
73  def __init__(self, **kwargs):
74  ProcessImageTask.__init__(self, **kwargs)
75  self.dataPrefix = self.config.coaddName + "Coadd_"
76  self.isPatchInnerKey = self.schema.addField(
77  "detect_isPatchInner", type="Flag",
78  doc="true if source is in the inner region of a coadd patch",
79  )
80  self.isTractInnerKey = self.schema.addField(
81  "detect_isTractInner", type="Flag",
82  doc="true if source is in the inner region of a coadd tract",
83  )
84  self.isPrimaryKey = self.schema.addField(
85  "detect_isPrimary", type="Flag",
86  doc="true if source has no children and is in the inner region of a coadd patch " \
87  + "and is in the inner region of a coadd tract",
88  )

Member Function Documentation

def lsst.pipe.tasks.processCoadd.ProcessCoaddTask._getConfigName (   self)
private
Return the name of the config dataset

Definition at line 197 of file processCoadd.py.

198  def _getConfigName(self):
199  """Return the name of the config dataset
200  """
201  return "%s_processCoadd_config" % (self.config.coaddName,)
def lsst.pipe.tasks.processCoadd.ProcessCoaddTask._getMetadataName (   self)
private
Return the name of the metadata dataset

Definition at line 202 of file processCoadd.py.

203  def _getMetadataName(self):
204  """Return the name of the metadata dataset
205  """
206  return "%s_processCoadd_metadata" % (self.config.coaddName,)
def lsst.pipe.tasks.processCoadd.ProcessCoaddTask._makeArgumentParser (   cls)
private

Definition at line 191 of file processCoadd.py.

192  def _makeArgumentParser(cls):
193  parser = pipeBase.ArgumentParser(name=cls._DefaultName)
194  parser.add_id_argument("--id", "deepCoadd", help="data ID, e.g. --id tract=12345 patch=1,2",
195  ContainerClass=CoaddDataIdContainer)
196  return parser
def lsst.pipe.tasks.processCoadd.ProcessCoaddTask.getExposureId (   self,
  dataRef 
)

Definition at line 106 of file processCoadd.py.

107  def getExposureId(self, dataRef):
108  return long(dataRef.get(self.config.coaddName + "CoaddId"))
def lsst.pipe.tasks.processCoadd.ProcessCoaddTask.makeIdFactory (   self,
  dataRef 
)

Definition at line 101 of file processCoadd.py.

102  def makeIdFactory(self, dataRef):
103  expBits = dataRef.get(self.config.coaddName + "CoaddId_bits")
104  expId = long(dataRef.get(self.config.coaddName + "CoaddId"))
105  return afwTable.IdFactory.makeSource(expId, 64 - expBits)
def lsst.pipe.tasks.processCoadd.ProcessCoaddTask.run (   self,
  dataRef 
)
Process a coadd image

@param dataRef: butler data reference corresponding to coadd patch
@return pipe_base Struct containing these fields:
- exposure: calibrated exposure (calexp): as computed if config.doCalibrate,
    else as upersisted and updated if config.doDetection, else None
- calib: object returned by calibration process if config.doCalibrate, else None
- sources: detected source if config.doDetection, else None

Definition at line 110 of file processCoadd.py.

111  def run(self, dataRef):
112  """Process a coadd image
113 
114  @param dataRef: butler data reference corresponding to coadd patch
115  @return pipe_base Struct containing these fields:
116  - exposure: calibrated exposure (calexp): as computed if config.doCalibrate,
117  else as upersisted and updated if config.doDetection, else None
118  - calib: object returned by calibration process if config.doCalibrate, else None
119  - sources: detected source if config.doDetection, else None
120  """
121  self.log.info("Processing %s" % (dataRef.dataId))
122 
123  # initialize outputs
124  coadd = None
125 
126  skyInfo = getSkyInfo(coaddName=self.config.coaddName, patchRef=dataRef)
127 
128  coadd = dataRef.get(self.config.coaddName + "Coadd")
129  if self.config.doScaleVariance:
130  self.scaleVariance(coadd)
131 
132  # delegate most of the work to ProcessImageTask
133  result = self.process(dataRef, coadd, enableWriteSources=False)
134  result.coadd = coadd
135 
136  if result.sources is not None:
137  self.setIsPrimaryFlag(sources=result.sources, skyInfo=skyInfo)
138 
139  # write sources
140  if self.config.doWriteSources:
141  dataRef.put(result.sources, self.dataPrefix + 'src')
142 
143  return result
def getSkyInfo
Return SkyMap, tract and patch.
Definition: coaddBase.py:212
def lsst.pipe.tasks.processCoadd.ProcessCoaddTask.scaleVariance (   self,
  exposure 
)

Definition at line 90 of file processCoadd.py.

90 
91  def scaleVariance(self, exposure):
93  ctrl.setAndMask(~0x0)
94  var = exposure.getMaskedImage().getVariance()
95  mask = exposure.getMaskedImage().getMask()
96  dstats = afwMath.makeStatistics(exposure.getMaskedImage(), afwMath.VARIANCECLIP, ctrl).getValue(afwMath.VARIANCECLIP)
97  vstats = afwMath.makeStatistics(var, mask, afwMath.MEANCLIP, ctrl).getValue(afwMath.MEANCLIP)
98  vrat = dstats / vstats
99  self.log.info("Renormalising variance by %f" % (vrat))
100  var *= vrat
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.processCoadd.ProcessCoaddTask.setIsPrimaryFlag (   self,
  sources,
  skyInfo 
)
Set is-primary and related flags on sources

@param[in,out] sources: a SourceTable
    - reads centroid fields and an nChild field
    - writes is-patch-inner, is-tract-inner and is-primary flags
@param[in] skyInfo: a SkyInfo object as returned by getSkyInfo;
    reads skyMap, patchInfo, and tractInfo fields

@raise RuntimeError if self.config.doDeblend and the nChild key is not found in the table

Definition at line 144 of file processCoadd.py.

145  def setIsPrimaryFlag(self, sources, skyInfo):
146  """Set is-primary and related flags on sources
147 
148  @param[in,out] sources: a SourceTable
149  - reads centroid fields and an nChild field
150  - writes is-patch-inner, is-tract-inner and is-primary flags
151  @param[in] skyInfo: a SkyInfo object as returned by getSkyInfo;
152  reads skyMap, patchInfo, and tractInfo fields
153 
154  @raise RuntimeError if self.config.doDeblend and the nChild key is not found in the table
155  """
156  # Test for the presence of the nchild key instead of checking config.doDeblend because sources
157  # might be unpersisted with deblend info, even if deblending is not run again.
158  nChildKeyName = "deblend_nChild"
159 
160  try:
161  nChildKey = self.schema.find(nChildKeyName).key
162  except Exception:
163  nChildKey = None
164 
165  if self.config.doDeblend and nChildKey is None:
166  # deblending was run but the nChildKey was not found; this suggests a variant deblender
167  # was used that we cannot use the output from, or some obscure error.
168  raise RuntimeError("Ran the deblender but cannot find %r in the source table" % (nChildKeyName,))
169 
170  # set inner flags for each source and set primary flags for sources with no children
171  # (or all sources if deblend info not available)
172  innerFloatBBox = afwGeom.Box2D(skyInfo.patchInfo.getInnerBBox())
173  tractId = skyInfo.tractInfo.getId()
174  for source in sources:
175  if source.getCentroidFlag():
176  # centroid unknown, so leave the inner and primary flags False
177  continue
178 
179  centroidPos = source.getCentroid()
180  isPatchInner = innerFloatBBox.contains(centroidPos)
181  source.setFlag(self.isPatchInnerKey, isPatchInner)
182 
183  skyPos = source.getCoord()
184  sourceInnerTractId = skyInfo.skyMap.findTract(skyPos).getId()
185  isTractInner = sourceInnerTractId == tractId
186  source.setFlag(self.isTractInnerKey, isTractInner)
187 
188  if nChildKey is None or source.get(nChildKey) == 0:
189  source.setFlag(self.isPrimaryKey, isPatchInner and isTractInner)
A floating-point coordinate rectangle geometry.
Definition: Box.h:271

Member Data Documentation

string lsst.pipe.tasks.processCoadd.ProcessCoaddTask._DefaultName = "processCoadd"
staticprivate

Definition at line 70 of file processCoadd.py.

lsst.pipe.tasks.processCoadd.ProcessCoaddTask.ConfigClass = ProcessCoaddConfig
static

Definition at line 69 of file processCoadd.py.

lsst.pipe.tasks.processCoadd.ProcessCoaddTask.dataPrefix

Definition at line 74 of file processCoadd.py.

lsst.pipe.tasks.processCoadd.ProcessCoaddTask.isPatchInnerKey

Definition at line 75 of file processCoadd.py.

lsst.pipe.tasks.processCoadd.ProcessCoaddTask.isPrimaryKey

Definition at line 83 of file processCoadd.py.

lsst.pipe.tasks.processCoadd.ProcessCoaddTask.isTractInnerKey

Definition at line 79 of file processCoadd.py.


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