LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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: