LSST Applications g180d380827+107df2c2fa,g2079a07aa2+86d27d4dc4,g2305ad1205+27ad5d03fa,g2bbee38e9b+c6a8a0fb72,g337abbeb29+c6a8a0fb72,g33d1c0ed96+c6a8a0fb72,g3a166c0a6a+c6a8a0fb72,g3d1719c13e+cc4c7597ef,g487adcacf7+4b0be3ae0a,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+14d443d837,g62aa8f1a4b+588cc723a1,g674612935b+7a21c67e12,g858d7b2824+cc4c7597ef,g991b906543+cc4c7597ef,g99cad8db69+b90e8bab37,g9c22b2923f+e2510deafe,g9ddcbc5298+9a081db1e4,g9fbc5161f1+1dc7c5428e,ga1e77700b3+03d07e1c1f,gb0e22166c9+60f28cb32d,gb23b769143+cc4c7597ef,gba4ed39666+c2a2e4ac27,gbb8dafda3b+52e28152d7,gbd998247f1+585e252eca,gbeadb96d05+a322446fe6,gc120e1dc64+6a70fcc921,gc28159a63d+c6a8a0fb72,gc3e9b769f7+48c1343504,gcf0d15dbbd+7a21c67e12,gdaeeff99f8+f9a426f77a,ge6526c86ff+9349653ccd,ge79ae78c31+c6a8a0fb72,gee10cc3b42+585e252eca,w.2024.18
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Attributes | List of all members
lsst.meas.base.applyApCorr.ApplyApCorrTask Class Reference
Inheritance diagram for lsst.meas.base.applyApCorr.ApplyApCorrTask:

Public Member Functions

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

Public Attributes

 apCorrInfoDict
 

Static Public Attributes

 ConfigClass = ApplyApCorrConfig
 

Static Protected Attributes

str _DefaultName = "applyApCorr"
 

Detailed Description

Apply aperture corrections.

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

Definition at line 187 of file applyApCorr.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 197 of file applyApCorr.py.

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

Member Function Documentation

◆ run()

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 222 of file applyApCorr.py.

222 def run(self, catalog, apCorrMap):
223 """Apply aperture corrections to a catalog of sources.
224
225 Parameters
226 ----------
227 catalog : `lsst.afw.table.SourceCatalog`
228 Catalog of sources. Will be updated in place.
229 apCorrMap : `lsst.afw.image.ApCorrMap`
230 Aperture correction map
231
232 Notes
233 -----
234 If you show debug-level log messages then you will see statistics for
235 the effects of aperture correction.
236 """
237 self.log.info("Applying aperture corrections to %d instFlux fields", len(self.apCorrInfoDict))
238 if UseNaiveFluxErr:
239 self.log.debug("Use naive instFlux sigma computation")
240 else:
241 self.log.debug("Use complex instFlux sigma computation that double-counts photon noise "
242 "and thus over-estimates instFlux uncertainty")
243
244 # Wrap the task logger to a periodic logger.
245 periodicLog = PeriodicLogger(self.log)
246
247 for apCorrIndex, apCorrInfo in enumerate(self.apCorrInfoDict.values()):
248 apCorrModel = apCorrMap.get(apCorrInfo.modelName)
249 apCorrErrModel = apCorrMap.get(apCorrInfo.modelSigmaName)
250 if None in (apCorrModel, apCorrErrModel):
251 missingNames = [(apCorrInfo.modelName, apCorrInfo.modelSigmaName)[i]
252 for i, model in enumerate((apCorrModel, apCorrErrModel)) if model is None]
253 self.log.warning("Cannot aperture correct %s because could not find %s in apCorrMap",
254 apCorrInfo.name, " or ".join(missingNames))
255 for source in catalog:
256 source.set(apCorrInfo.apCorrFlagKey, True)
257 continue
258
259 # Say we've failed before we start; we'll unset these flags on success.
260 catalog[apCorrInfo.apCorrFlagKey] = True
261 oldFluxFlagState = np.zeros(len(catalog), dtype=np.bool_)
262 if self.config.doFlagApCorrFailures:
263 oldFluxFlagState = catalog[apCorrInfo.fluxFlagKey]
264 catalog[apCorrInfo.fluxFlagKey] = True
265
266 apCorr = apCorrModel.evaluate(catalog["slot_Centroid_x"], catalog["slot_Centroid_y"])
267 if not UseNaiveFluxErr:
268 apCorrErr = apCorrErrModel.evaluate(
269 catalog["slot_Centroid_x"],
270 catalog["slot_Centroid_y"],
271 )
272 else:
273 apCorrErr = np.zeros(len(catalog))
274
275 if apCorrInfo.doApCorrColumn:
276 catalog[apCorrInfo.apCorrKey] = apCorr
277 catalog[apCorrInfo.apCorrErrKey] = apCorrErr
278
279 # Check bad values that are not finite (possible for coadds).
280 good = np.isfinite(apCorr) & (apCorr > 0.0) & (apCorrErr >= 0.0)
281
282 if good.sum() == 0:
283 continue
284
285 instFlux = catalog[apCorrInfo.instFluxKey]
286 instFluxErr = catalog[apCorrInfo.instFluxErrKey]
287 catalog[apCorrInfo.instFluxKey][good] = instFlux[good]*apCorr[good]
288 if UseNaiveFluxErr:
289 catalog[apCorrInfo.instFluxErrKey][good] = instFluxErr[good]*apCorr[good]
290 else:
291 a = instFluxErr[good]/instFlux[good]
292 b = apCorrErr[good]/apCorr[good]
293 err = np.abs(instFlux[good]*apCorr[good])*np.sqrt(a*a + b*b)
294 catalog[apCorrInfo.instFluxErrKey][good] = err
295
296 flags = catalog[apCorrInfo.apCorrFlagKey].copy()
297 flags[good] = False
298 catalog[apCorrInfo.apCorrFlagKey] = flags
299 if self.config.doFlagApCorrFailures:
300 fluxFlags = catalog[apCorrInfo.fluxFlagKey].copy()
301 fluxFlags[good] = oldFluxFlagState[good]
302 catalog[apCorrInfo.fluxFlagKey] = fluxFlags
303
304 # Log a message if it has been a while since the last log.
305 periodicLog.log("Aperture corrections applied to %d fields out of %d",
306 apCorrIndex + 1, len(self.apCorrInfoDict))
307
308 if self.log.isEnabledFor(self.log.DEBUG):
309 # log statistics on the effects of aperture correction
310 apCorrArr = np.array([s.get(apCorrInfo.apCorrKey) for s in catalog])
311 apCorrErrArr = np.array([s.get(apCorrInfo.apCorrErrKey) for s in catalog])
312 self.log.debug("For instFlux field %r: mean apCorr=%s, stdDev apCorr=%s, "
313 "mean apCorrErr=%s, stdDev apCorrErr=%s for %s sources",
314 apCorrInfo.name, apCorrArr.mean(), apCorrArr.std(),
315 apCorrErrArr.mean(), apCorrErrArr.std(), len(catalog))

Member Data Documentation

◆ _DefaultName

str lsst.meas.base.applyApCorr.ApplyApCorrTask._DefaultName = "applyApCorr"
staticprotected

Definition at line 195 of file applyApCorr.py.

◆ apCorrInfoDict

lsst.meas.base.applyApCorr.ApplyApCorrTask.apCorrInfoDict

Definition at line 200 of file applyApCorr.py.

◆ ConfigClass

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

Definition at line 194 of file applyApCorr.py.


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