LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
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: