28 from .sourceSelector
import BaseSourceSelectorConfig, BaseSourceSelectorTask, sourceSelectorRegistry
33 sourceFluxType = pexConfig.Field(
34 doc=
"Type of source flux; typically one of Ap or Psf",
38 minSnr = pexConfig.Field(
40 doc=
"Minimum allowed signal-to-noise ratio for sources used for matching " 41 "(in the flux specified by sourceFluxType); <= 0 for no limit",
48 !Select sources that are useful for matching. 50 Good matching sources have high signal/noise, are non-blended. They need not 51 be PSF sources, just have reliable centroids. 53 ConfigClass = MatcherSourceSelectorConfig
56 BaseSourceSelectorTask.__init__(self, *args, **kwargs)
60 !Return a catalog of sources: a subset of sourceCat. 62 If sourceCat is cotiguous in memory, will use vectorized tests for ~100x 63 execution speed advantage over non-contiguous catalogs. This would be 64 even faster if we didn't have to check footprints for multiple peaks. 66 @param[in] sourceCat catalog of sources that may be sources 67 (an lsst.afw.table.SourceCatalog) 69 @return a pipeBase.Struct containing: 70 - sourceCat a catalog of sources 74 if sourceCat.isContiguous():
76 result = sourceCat[good]
78 result = table.SourceCatalog(sourceCat.table)
79 for i, source
in enumerate(sourceCat):
82 return Struct(sourceCat=result)
84 def _getSchemaKeys(self, schema):
85 """Extract and save the necessary keys from schema with asKey.""" 91 fluxPrefix =
"slot_%sFlux_" % (self.config.sourceFluxType,)
93 self.
fluxKey = schema[fluxPrefix +
"flux"].asKey()
97 def _isParent_vector(self, sourceCat):
98 """Return True for each source that is the parent source.""" 99 test = (sourceCat.get(self.
parentKey) == 0)
102 def _isParent(self, source):
103 """Return True if source is the parent source.""" 108 def _hasCentroid_vector(self, sourceCat):
109 """Return True for each source that has a valid centroid""" 114 def _hasCentroid(self, source):
115 """Return True if the source has a valid centroid""" 116 centroid = source.getCentroid()
117 return np.all(np.isfinite(centroid))
and not source.getCentroidFlag()
119 def _goodSN_vector(self, sourceCat):
120 """Return True for each source that has Signal/Noise > config.minSnr.""" 121 if self.config.minSnr <= 0:
124 with np.errstate(invalid=
"ignore"):
127 def _goodSN(self, source):
128 """Return True if source has Signal/Noise > config.minSnr.""" 129 return (self.config.minSnr <= 0
or 132 def _isUsable_vector(self, sourceCat):
134 Return True for each source that is usable for matching, even if it may 135 have a poor centroid. 137 For a source to be usable it must: 138 - have a valid centroid 140 - have a valid flux (of the type specified in this object's constructor) 141 - have adequate signal-to-noise 148 def _isUsable(self, source):
150 Return True if the source is usable for matching, even if it may have a 153 For a source to be usable it must: 154 - have a valid centroid 156 - have a valid flux (of the type specified in this object's constructor) 157 - have adequate signal-to-noise 167 !Select sources that are useful for matching. 169 Good matching sources have high signal/noise, are non-blended. They need not 170 be PSF sources, just have reliable centroids. This inherited class adds 171 the removal of saturated, interpolated, and edge_key objects to the set of 172 bad flags. It is a temporary addition designed preserve the source selction 173 used in matchOptimisticB. Once matchPessimisticB is adopted as the default 174 source selector the class will be removed and the saturated, interpoalted, and 175 edge_key flags will be added to the matcherSourceSelector class. 177 TODO: Once DM-10399 is complete an RFC will be filed to make matchPessimisticB 178 the default matcher this class will replace matcherSourceSelector with this source 179 selector resulting in only one matcherSourceSeletor. The ticket describing 180 this work is DM-10800. 182 def _getSchemaKeys(self, schema):
183 """Extract and save the necessary keys from schema with asKey.""" 184 MatcherSourceSelectorTask._getSchemaKeys(self, schema)
186 self.
edgeKey = schema[
"base_PixelFlags_flag_edge"].asKey()
190 def _isUsable_vector(self, sourceCat):
192 Return True for each source that is usable for matching, even if it may 193 have a poor centroid. 195 For a source to be usable it must: 196 - have a valid centroid 198 - have a valid flux (of the type specified in this object's constructor) 199 - have adequate signal-to-noise 201 result = MatcherSourceSelectorTask._isUsable_vector(self, sourceCat)
204 & ~sourceCat.get(self.
edgeKey) \
208 def _isUsable(self, source):
210 Return True if the source is usable for matching, even if it may have a 213 For a source to be usable it must: 214 - have a valid centroid 216 - have a valid flux (of the type specified in this object's constructor) 217 - have adequate signal-to-noise 219 result = MatcherSourceSelectorTask._isUsable(self, source)
222 and not source.get(self.
edgeKey) \
227 sourceSelectorRegistry.register(
"matcher", MatcherSourceSelectorTask)
228 sourceSelectorRegistry.register(
"matcherPessimistic",
229 MatcherPessimisticSourceSelectorTask)
def selectSources(self, sourceCat, matches=None)
def _goodSN_vector(self, sourceCat)
def _isParent(self, source)
def _goodSN(self, source)
def _hasCentroid_vector(self, sourceCat)
def _hasCentroid(self, source)
def _isUsable(self, source)
def __init__(self, args, kwargs)
def _isUsable_vector(self, sourceCat)
def _isParent_vector(self, sourceCat)
def _getSchemaKeys(self, schema)
Base class for source selectors.