23 __all__ = [
"CatalogStarSelectorConfig",
"CatalogStarSelectorTask"]
27 from lsst.meas.algorithms
import BaseSourceSelectorTask, sourceSelectorRegistry
28 from lsst.pipe.base
import Struct
34 fluxLim = pexConfig.RangeField(
35 doc=
"specify the minimum psfFlux for good Psf Candidates",
40 fluxMax = pexConfig.RangeField(
41 doc=
"specify the maximum psfFlux for good Psf Candidates (ignored if == 0)",
46 badFlags = pexConfig.ListField(
47 doc=
"List of flags which cause a source to be rejected as bad",
50 "base_PixelFlags_flag_edge",
51 "base_PixelFlags_flag_interpolatedCenter",
52 "base_PixelFlags_flag_saturatedCenter",
58 """A functor to check whether a source has any flags set that should cause it to be labeled bad.""" 60 def __init__(self, table, fluxLim, fluxMax, badFlags):
61 self.
keys = [table.getSchema().find(name).key
for name
in badFlags]
62 self.
keys.append(table.getCentroidFlagKey())
70 if self.
fluxLim is not None and source.getPsfInstFlux() < self.
fluxLim:
84 @pexConfig.registerConfigurable(
"catalog", sourceSelectorRegistry)
86 """Select stars based on a reference catalog. 91 A boolean variable specify if the inherited source selector uses 92 matches to an external catalog, and thus requires the ``matches`` 93 argument to ``run()``. Set to True for this selector. 95 ConfigClass = CatalogStarSelectorConfig
99 """Return a selection of sources based on reference catalog matches. 103 sourceCat : `lsst.afw.table.SourceCatalog` 104 Catalog of sources to select from. 105 This catalog must be contiguous in memory. 106 matches : `list` of `lsst.afw.table.ReferenceMatch` 107 A match vector as produced by meas_astrom; required. 108 exposure : `lsst.afw.image.Exposure` or None 109 The exposure the catalog was built from; used for debug display. 113 struct : `lsst.pipe.base.Struct` 114 Result struct with components: 116 - selected : Boolean array of sources that were selected, same 117 length as sourceCat (`numpy.ndarray` of `bool`) 121 display = debugInfo.display
122 pauseAtEnd = debugInfo.pauseAtEnd
125 raise RuntimeError(
"CatalogStarSelectorTask requires matches")
127 mi = exposure.getMaskedImage()
131 ds9.mtv(mi, frame=frame, title=
"PSF candidates")
133 isGoodSource =
CheckSource(sourceCat, self.config.fluxLim, self.config.fluxMax, self.config.badFlags)
134 good = np.array([isGoodSource(record)
for record
in sourceCat])
136 with ds9.Buffering():
137 for ref, source, d
in matches:
138 if not ref.get(
"resolved"):
139 if not isGoodSource(source):
140 symb, ctype =
"+", ds9.RED
142 symb, ctype =
"+", ds9.GREEN
145 ds9.dot(symb, source.getX() - mi.getX0(), source.getY() - mi.getY0(),
146 size=4, frame=frame, ctype=ctype)
148 if display
and pauseAtEnd:
149 input(
"Continue? y[es] p[db] ")
151 return Struct(selected=good)
def selectSources(self, sourceCat, matches=None, exposure=None)
def __call__(self, source)
def __init__(self, table, fluxLim, fluxMax, badFlags)