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 | Static Private Attributes | List of all members
lsst.meas.base.applyApCorr.ApplyApCorrTask Class Reference

Apply aperture corrections. More...

Inheritance diagram for lsst.meas.base.applyApCorr.ApplyApCorrTask:

Public Member Functions

def __init__
 
def run
 

Public Attributes

 apCorrInfoDict
 

Static Public Attributes

 ConfigClass = ApplyApCorrConfig
 

Static Private Attributes

string _DefaultName = "applyApCorr"
 

Detailed Description

Apply aperture corrections.

Definition at line 106 of file applyApCorr.py.

Constructor & Destructor Documentation

def lsst.meas.base.applyApCorr.ApplyApCorrTask.__init__ (   self,
  schema,
  kwds 
)
Construct an instance of this task

Definition at line 112 of file applyApCorr.py.

113  def __init__(self, schema, **kwds):
114  """Construct an instance of this task
115  """
116  lsst.pipe.base.Task.__init__(self, **kwds)
118  self.apCorrInfoDict = dict()
119  apCorrNameSet = getApCorrNameSet()
120  ignoreSet = set(self.config.ignoreList)
121  missingNameSet = ignoreSet - set(apCorrNameSet)
122  if missingNameSet:
123  self.log.warn("Fields in ignoreList that are not in fluxCorrectList: %s" %
124  (sorted(list(missingNameSet)),))
125  for name in apCorrNameSet - ignoreSet:
126  if name + "_flux" in schema:
127  self.apCorrInfoDict[name] = ApCorrInfo(schema=schema, name=name)
128  else:
129  # if a field in the registry is missing from the schema, silently ignore it.
130  pass
def getApCorrNameSet
Return a copy of the set of field name prefixes for fluxes that should be aperture corrected...
Catalog field names and keys needed to aperture correct a particular flux.
Definition: applyApCorr.py:41

Member Function Documentation

def lsst.meas.base.applyApCorr.ApplyApCorrTask.run (   self,
  catalog,
  apCorrMap 
)
Apply aperture corrections to a catalog of sources

@param[in,out] catalog  catalog of sources
@param[in] apCorrMap  aperture correction map (an lsst.afw.image.ApCorrMap)

If you show debug-level log messages then you will see statistics for the effects of
aperture correction.

Definition at line 131 of file applyApCorr.py.

132  def run(self, catalog, apCorrMap):
133  """Apply aperture corrections to a catalog of sources
134 
135  @param[in,out] catalog catalog of sources
136  @param[in] apCorrMap aperture correction map (an lsst.afw.image.ApCorrMap)
137 
138  If you show debug-level log messages then you will see statistics for the effects of
139  aperture correction.
140  """
141  self.log.info("Applying aperture corrections to %d flux fields" % (len(self.apCorrInfoDict),))
142  if UseNaiveFluxSigma:
143  self.log.info("Use naive flux sigma computation")
144  else:
145  self.log.info("Use complex flux sigma computation that double-counts photon noise "
146  " and thus over-estimates flux uncertainty")
147  for apCorrInfo in self.apCorrInfoDict.itervalues():
148  apCorrModel = apCorrMap.get(apCorrInfo.fluxName)
149  apCorrSigmaModel = apCorrMap.get(apCorrInfo.fluxSigmaName)
150  if None in (apCorrModel, apCorrSigmaModel):
151  missingNames = [(apCorrInfo.fluxName, apCorrInfo.fluxSigmaName)[i]
152  for i, model in enumerate((apCorrModel, apCorrSigmaModel)) if model is None]
153  self.log.warn("Could not find %s in apCorrMap" % (" or ".join(missingNames),))
154  for source in catalog:
155  source.set(apCorrInfo.apCorrFlagKey, True)
156  continue
157 
158  for source in catalog:
159  center = source.getCentroid()
160  # say we've failed when we start; we'll unset these flags when we succeed
161  source.set(apCorrInfo.apCorrFlagKey, True)
162  oldFluxFlagState = False
163  if self.config.doFlagApCorrFailures:
164  oldFluxFlagState = source.get(apCorrInfo.fluxFlagKey)
165  source.set(apCorrInfo.fluxFlagKey, True)
166 
167  apCorr = 1.0
168  apCorrSigma = 0.0
169  try:
170  apCorr = apCorrModel.evaluate(center)
171  if not UseNaiveFluxSigma:
172  apCorrSigma = apCorrSigmaModel.evaluate(center)
173  except lsst.pex.exceptions.DomainError:
174  continue
175 
176  source.set(apCorrInfo.apCorrKey, apCorr)
177  source.set(apCorrInfo.apCorrSigmaKey, apCorrSigma)
178  if apCorr <= 0.0 or apCorrSigma < 0.0:
179  continue
180 
181  flux = source.get(apCorrInfo.fluxKey)
182  fluxSigma = source.get(apCorrInfo.fluxSigmaKey)
183  source.set(apCorrInfo.fluxKey, flux*apCorr)
184  if UseNaiveFluxSigma:
185  source.set(apCorrInfo.fluxSigmaKey, fluxSigma*apCorr)
186  else:
187  a = fluxSigma/flux
188  b = apCorrSigma/apCorr
189  source.set(apCorrInfo.fluxSigmaKey, abs(flux*apCorr)*math.sqrt(a*a + b*b))
190  source.set(apCorrInfo.apCorrFlagKey, False)
191  if self.config.doFlagApCorrFailures:
192  source.set(apCorrInfo.fluxFlagKey, oldFluxFlagState)
193 
194  if self.log.getThreshold() <= self.log.DEBUG:
195  # log statistics on the effects of aperture correction
196  apCorrArr = numpy.array([s.get(apCorrInfo.apCorrKey) for s in catalog])
197  apCorrSigmaArr = numpy.array([s.get(apCorrInfo.apCorrSigmaKey) for s in catalog])
198  self.log.logdebug("For flux field %r: mean apCorr=%s, stdDev apCorr=%s,"
199  " mean apCorrSigma=%s, stdDev apCorrSigma=%s for %s sources" %
200  (apCorrInfo.name, apCorrArr.mean(), apCorrArr.std(),
201  apCorrSigmaArr.mean(), apCorrSigmaArr.std(), len(catalog)))
202 
203 

Member Data Documentation

string lsst.meas.base.applyApCorr.ApplyApCorrTask._DefaultName = "applyApCorr"
staticprivate

Definition at line 110 of file applyApCorr.py.

lsst.meas.base.applyApCorr.ApplyApCorrTask.apCorrInfoDict

Definition at line 117 of file applyApCorr.py.

lsst.meas.base.applyApCorr.ApplyApCorrTask.ConfigClass = ApplyApCorrConfig
static

Definition at line 109 of file applyApCorr.py.


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