27 from .sourceSelector
import BaseSourceSelectorConfig, BaseSourceSelectorTask, sourceSelectorRegistry
32 sourceFluxType = pexConfig.Field(
33 doc=
"Type of source flux; typically one of Ap or Psf",
37 minSnr = pexConfig.Field(
39 doc=
"Minimum allowed signal-to-noise ratio for sources used for matching " 40 "(in the flux specified by sourceFluxType); <= 0 for no limit",
45 @pexConfig.registerConfigurable(
"matcher", sourceSelectorRegistry)
47 """Select sources that are useful for matching. 49 Good matching sources have high signal/noise, are non-blended. They need not 50 be PSF sources, just have reliable centroids. 52 Distinguished from astrometrySourceSelector because it is more lenient 53 (i.e. not checking footprints or bad flags). 55 ConfigClass = MatcherSourceSelectorConfig
58 BaseSourceSelectorTask.__init__(self, *args, **kwargs)
61 """Return a selection of sources that are useful for matching. 65 sourceCat : `lsst.afw.table.SourceCatalog` 66 Catalog of sources to select from. 67 This catalog must be contiguous in memory. 68 matches : `list` of `lsst.afw.table.ReferenceMatch` or None 69 Ignored in this SourceSelector. 70 exposure : `lsst.afw.image.Exposure` or None 71 The exposure the catalog was built from; used for debug display. 75 struct : `lsst.pipe.base.Struct` 76 The struct contains the following data: 78 - selected : `array` of `bool`` 79 Boolean array of sources that were selected, same length as 85 return Struct(selected=good)
87 def _getSchemaKeys(self, schema):
88 """Extract and save the necessary keys from schema with asKey.""" 94 fluxPrefix =
"slot_%sFlux_" % (self.config.sourceFluxType,)
96 self.
fluxKey = schema[fluxPrefix +
"instFlux"].asKey()
98 self.
fluxErrKey = schema[fluxPrefix +
"instFluxErr"].asKey()
100 def _isParent(self, sourceCat):
101 """Return True for each source that is the parent source.""" 102 test = (sourceCat.get(self.
parentKey) == 0)
105 def _hasCentroid(self, sourceCat):
106 """Return True for each source that has a valid centroid""" 111 def _goodSN(self, sourceCat):
112 """Return True for each source that has Signal/Noise > config.minSnr.""" 113 if self.config.minSnr <= 0:
116 with np.errstate(invalid=
"ignore"):
117 return sourceCat.get(self.
fluxKey)/sourceCat.get(self.
fluxErrKey) > self.config.minSnr
119 def _isUsable(self, sourceCat):
121 Return True for each source that is usable for matching, even if it may 122 have a poor centroid. 124 For a source to be usable it must: 125 - have a valid centroid 127 - have a valid instFlux (of the type specified in this object's constructor) 128 - have adequate signal-to-noise 136 @pexConfig.registerConfigurable(
"matcherPessimistic", sourceSelectorRegistry)
138 """Select sources that are useful for matching. 140 Good matching sources have high signal/noise, are non-blended. They need not 141 be PSF sources, just have reliable centroids. This inherited class adds 142 the removal of saturated, interpolated, and edge_key objects to the set of 143 bad flags. It is a temporary addition designed preserve the source selction 144 used in matchOptimisticB. Once matchPessimisticB is adopted as the default 145 source selector the class will be removed and the saturated, interpoalted, and 146 edge_key flags will be added to the matcherSourceSelector class. 148 TODO: Once DM-10399 is complete an RFC will be filed to make matchPessimisticB 149 the default matcher this class will replace matcherSourceSelector with this source 150 selector resulting in only one matcherSourceSeletor. The ticket describing 151 this work is DM-10800. 153 def _getSchemaKeys(self, schema):
154 """Extract and save the necessary keys from schema with asKey.""" 155 MatcherSourceSelectorTask._getSchemaKeys(self, schema)
157 self.
edgeKey = schema[
"base_PixelFlags_flag_edge"].asKey()
161 def _isUsable(self, sourceCat):
163 Return True for each source that is usable for matching, even if it may 164 have a poor centroid. 166 For a source to be usable it must: 167 - have a valid centroid 169 - have a valid instFlux (of the type specified in this object's constructor) 170 - have adequate signal-to-noise 172 result = MatcherSourceSelectorTask._isUsable(self, sourceCat)
175 & ~sourceCat.get(self.
edgeKey) \
def _isParent(self, sourceCat)
def __init__(self, args, kwargs)
def selectSources(self, sourceCat, matches=None, exposure=None)
def _isUsable(self, sourceCat)
def _goodSN(self, sourceCat)
def _getSchemaKeys(self, schema)
def _hasCentroid(self, sourceCat)