24 Definition and registration of classification plugins
29 import lsst.pex.config
30 from .catalogCalculation
import CatalogCalculationPluginConfig, CatalogCalculationPlugin
31 from .pluginRegistry
import register
34 "CatalogCalculationClassificationConfig",
"CatalogCalculationClassificationPlugin",
39 fluxRatio = lsst.pex.config.Field(dtype=float, default=.925, optional=
True,
40 doc=
"critical ratio of model to psf flux")
41 modelErrFactor = lsst.pex.config.Field(dtype=float, default=0.0, optional=
True,
42 doc=
"correction factor for modelFlux error")
43 psfErrFactor = lsst.pex.config.Field(dtype=float, default=0.0, optional=
True,
44 doc=
"correction factor for psfFlux error")
47 @
register(
"base_ClassificationExtendedness")
50 A binary measure of the extendedness of a source, based a simple cut on the ratio of the
51 PSF flux to the model flux.
53 Because the fluxes on which this algorithm is based on are slot measurements, they can be provided
54 by different algorithms, and the "fluxRatio" threshold used by this algorithm should generally
55 be set differently for different algorithms. To do this, plot the difference between the PSF
56 magnitude and the model magnitude vs. the PSF magnitude, and look for where the cloud of galaxies
60 ConfigClass = CatalogCalculationClassificationConfig
64 return cls.DEFAULT_CATALOGCALCULATION
66 def __init__(self, config, name, schema, metadata):
67 CatalogCalculationPlugin.__init__(self, config, name, schema, metadata)
69 doc=
"Set to 1 for extended sources, 0 for point sources.")
70 self.
keyFlag = schema.addField(name +
"_flag", type=
"Flag", doc=
"Set to 1 for any fatal failure.")
73 modelFlux = measRecord.getModelFlux()
74 psfFlux = measRecord.getPsfFlux()
75 modelFluxFlag = (measRecord.getModelFluxFlag()
76 if measRecord.table.getModelFluxFlagKey().isValid()
78 psfFluxFlag = (measRecord.getPsfFluxFlag()
79 if measRecord.table.getPsfFluxFlagKey().isValid()
81 flux1 = self.config.fluxRatio*modelFlux
82 if self.config.modelErrFactor != 0:
83 flux1 += self.config.modelErrFactor*measRecord.getModelFluxErr()
85 if not self.config.psfErrFactor == 0:
86 flux2 += self.config.psfErrFactor*measRecord.getPsfFluxErr()
92 if numpy.isnan(flux1)
or numpy.isnan(flux2)
or modelFluxFlag
or psfFluxFlag:
97 def fail(self, measRecord, error=None):
98 measRecord.set(self.
keyFlag,
True)
def register
A Python decorator that registers a class, using the given name, in its base class's PluginRegistry...