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 88 @anchor CatalogStarSelectorTask_ 90 @section meas_astrom_catalogStarSelector_Contents Contents 92 - @ref meas_astrom_catalogStarSelector_Purpose 93 - @ref meas_astrom_catalogStarSelector_Initialize 94 - @ref meas_astrom_catalogStarSelector_IO 95 - @ref meas_astrom_catalogStarSelector_Config 96 - @ref meas_astrom_catalogStarSelector_Debug 98 @section meas_astrom_catalogStarSelector_Purpose Description 100 Select stars using a match list: select sources where the matching reference object is unresolved, 101 plus the source passes the following tests: 102 - no flag from config.badFlags is set 103 - psf flux >= config.fluxLim 104 - psf flux <= config.fluxMax (not checked if fluxMax == 0) 106 @section meas_astrom_catalogStarSelector_Initialize Task initialisation 108 @copydoc \_\_init\_\_ 110 @section meas_astrom_catalogStarSelector_IO Invoking the Task 112 Like all star selectors, the main method is `run`. Unlike most star selectors, 113 this one requires the `matches` argument (the `usesMatches` property is true). 115 @section meas_astrom_catalogStarSelector_Config Configuration parameters 117 See @ref CatalogStarSelectorConfig 119 @section meas_astrom_catalogStarSelector_Debug Debug variables 121 CatalogStarSelectorTask has a debug dictionary with the following keys: 124 <dd>bool; if True display debug information 126 <dd>bool; if True wait after displaying everything and wait for user input 129 For example, put something like: 133 di = lsstDebug.getInfo(name) # N.b. lsstDebug.Info(name) would call us recursively 134 if name.endswith("catalogStarSelector"): 139 lsstDebug.Info = DebugInfo 141 into your `debug.py` file and run your task with the `--debug` flag. 143 ConfigClass = CatalogStarSelectorConfig
147 """Return a selection of sources based on reference catalog matches. 151 sourceCat : `lsst.afw.table.SourceCatalog` 152 Catalog of sources to select from. 153 This catalog must be contiguous in memory. 154 matches : `list` of `lsst.afw.table.ReferenceMatch` 155 A match vector as produced by meas_astrom; required. 156 exposure : `lsst.afw.image.Exposure` or None 157 The exposure the catalog was built from; used for debug display. 161 struct : `lsst.pipe.base.Struct` 162 The struct contains the following data: 164 - selected : `numpy.ndarray` of `bool`` 165 Boolean array of sources that were selected, same length as 170 display = debugInfo.display
171 pauseAtEnd = debugInfo.pauseAtEnd
174 raise RuntimeError(
"CatalogStarSelectorTask requires matches")
176 mi = exposure.getMaskedImage()
180 ds9.mtv(mi, frame=frame, title=
"PSF candidates")
182 isGoodSource =
CheckSource(sourceCat, self.config.fluxLim, self.config.fluxMax, self.config.badFlags)
183 good = np.array([isGoodSource(record)
for record
in sourceCat])
185 with ds9.Buffering():
186 for ref, source, d
in matches:
187 if not ref.get(
"resolved"):
188 if not isGoodSource(source):
189 symb, ctype =
"+", ds9.RED
191 symb, ctype =
"+", ds9.GREEN
194 ds9.dot(symb, source.getX() - mi.getX0(), source.getY() - mi.getY0(),
195 size=4, frame=frame, ctype=ctype)
197 if display
and pauseAtEnd:
198 input(
"Continue? y[es] p[db] ")
200 return Struct(selected=good)
def selectSources(self, sourceCat, matches=None, exposure=None)
def __call__(self, source)
def __init__(self, table, fluxLim, fluxMax, badFlags)
Select stars based on a reference catalog.