LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.base.applyApCorr.ApplyApCorrTask Class Reference
Inheritance diagram for lsst.meas.base.applyApCorr.ApplyApCorrTask:

Public Member Functions

def __init__ (self, schema, **kwds)
 
def run (self, catalog, apCorrMap)
 

Public Attributes

 apCorrInfoDict
 

Static Public Attributes

 ConfigClass = ApplyApCorrConfig
 

Detailed Description

Apply aperture corrections.

Parameters
----------
schema : `lsst.afw.table.Schema`

Definition at line 188 of file applyApCorr.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.applyApCorr.ApplyApCorrTask.__init__ (   self,
  schema,
**  kwds 
)

Definition at line 198 of file applyApCorr.py.

198  def __init__(self, schema, **kwds):
199  lsst.pipe.base.Task.__init__(self, **kwds)
200 
201  self.apCorrInfoDict = dict()
202  apCorrNameSet = getApCorrNameSet()
203  ignoreSet = set(self.config.ignoreList)
204  missingNameSet = ignoreSet - set(apCorrNameSet)
205  if missingNameSet:
206  self.log.warning("Fields in ignoreList that are not in fluxCorrectList: %s",
207  sorted(missingNameSet))
208  for name in sorted(apCorrNameSet - ignoreSet):
209  if name + "_instFlux" not in schema:
210  # if a field in the registry is missing from the schema, silently ignore it.
211  continue
212  self.apCorrInfoDict[name] = ApCorrInfo(schema=schema, model=name)
213 
214  for name, model in self.config.proxies.items():
215  if name in apCorrNameSet:
216  # Already done or ignored
217  continue
218  if name + "_instFlux" not in schema:
219  # Silently ignore
220  continue
221  self.apCorrInfoDict[name] = ApCorrInfo(schema=schema, model=model, name=name)
222 
daf::base::PropertySet * set
Definition: fits.cc:912

Member Function Documentation

◆ run()

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

Parameters
----------
catalog : `lsst.afw.table.SourceCatalog`
    Catalog of sources. Will be updated in place.
apCorrMap : `lsst.afw.image.ApCorrMap`
    Aperture correction map

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

Definition at line 223 of file applyApCorr.py.

223  def run(self, catalog, apCorrMap):
224  """Apply aperture corrections to a catalog of sources.
225 
226  Parameters
227  ----------
228  catalog : `lsst.afw.table.SourceCatalog`
229  Catalog of sources. Will be updated in place.
230  apCorrMap : `lsst.afw.image.ApCorrMap`
231  Aperture correction map
232 
233  Notes
234  -----
235  If you show debug-level log messages then you will see statistics for
236  the effects of aperture correction.
237  """
238  self.log.info("Applying aperture corrections to %d instFlux fields", len(self.apCorrInfoDict))
239  if UseNaiveFluxErr:
240  self.log.debug("Use naive instFlux sigma computation")
241  else:
242  self.log.debug("Use complex instFlux sigma computation that double-counts photon noise "
243  "and thus over-estimates instFlux uncertainty")
244  for apCorrInfo in self.apCorrInfoDict.values():
245  apCorrModel = apCorrMap.get(apCorrInfo.modelName)
246  apCorrErrModel = apCorrMap.get(apCorrInfo.modelSigmaName)
247  if None in (apCorrModel, apCorrErrModel):
248  missingNames = [(apCorrInfo.modelName, apCorrInfo.modelSigmaName)[i]
249  for i, model in enumerate((apCorrModel, apCorrErrModel)) if model is None]
250  self.log.warning("Cannot aperture correct %s because could not find %s in apCorrMap",
251  apCorrInfo.name, " or ".join(missingNames))
252  for source in catalog:
253  source.set(apCorrInfo.apCorrFlagKey, True)
254  continue
255 
256  for source in catalog:
257  center = source.getCentroid()
258  # say we've failed when we start; we'll unset these flags when we succeed
259  source.set(apCorrInfo.apCorrFlagKey, True)
260  oldFluxFlagState = False
261  if self.config.doFlagApCorrFailures:
262  oldFluxFlagState = source.get(apCorrInfo.fluxFlagKey)
263  source.set(apCorrInfo.fluxFlagKey, True)
264 
265  apCorr = 1.0
266  apCorrErr = 0.0
267  try:
268  apCorr = apCorrModel.evaluate(center)
269  if not UseNaiveFluxErr:
270  apCorrErr = apCorrErrModel.evaluate(center)
272  continue
273 
274  if apCorrInfo.doApCorrColumn:
275  source.set(apCorrInfo.apCorrKey, apCorr)
276  source.set(apCorrInfo.apCorrErrKey, apCorrErr)
277 
278  if apCorr <= 0.0 or apCorrErr < 0.0:
279  continue
280 
281  instFlux = source.get(apCorrInfo.instFluxKey)
282  instFluxErr = source.get(apCorrInfo.instFluxErrKey)
283  source.set(apCorrInfo.instFluxKey, instFlux*apCorr)
284  if UseNaiveFluxErr:
285  source.set(apCorrInfo.instFluxErrKey, instFluxErr*apCorr)
286  else:
287  a = instFluxErr/instFlux
288  b = apCorrErr/apCorr
289  source.set(apCorrInfo.instFluxErrKey, abs(instFlux*apCorr)*math.sqrt(a*a + b*b))
290  source.set(apCorrInfo.apCorrFlagKey, False)
291  if self.config.doFlagApCorrFailures:
292  source.set(apCorrInfo.fluxFlagKey, oldFluxFlagState)
293 
294  if self.log.isEnabledFor(self.log.DEBUG):
295  # log statistics on the effects of aperture correction
296  apCorrArr = np.array([s.get(apCorrInfo.apCorrKey) for s in catalog])
297  apCorrErrArr = np.array([s.get(apCorrInfo.apCorrErrKey) for s in catalog])
298  self.log.debug("For instFlux field %r: mean apCorr=%s, stdDev apCorr=%s, "
299  "mean apCorrErr=%s, stdDev apCorrErr=%s for %s sources",
300  apCorrInfo.name, apCorrArr.mean(), apCorrArr.std(),
301  apCorrErrArr.mean(), apCorrErrArr.std(), len(catalog))
Reports arguments outside the domain of an operation.
Definition: Runtime.h:57
def run(self, coaddExposures, bbox, wcs)
Definition: getTemplate.py:603
def isEnabledFor(loggername, level)
Angle abs(Angle const &a)
Definition: Angle.h:106

Member Data Documentation

◆ apCorrInfoDict

lsst.meas.base.applyApCorr.ApplyApCorrTask.apCorrInfoDict

Definition at line 201 of file applyApCorr.py.

◆ ConfigClass

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

Definition at line 195 of file applyApCorr.py.


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