Coverage for python/lsst/meas/algorithms/matcherSourceSelector.py : 40%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # # Copyright 2008-2017 AURA/LSST. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <https://www.lsstcorp.org/LegalNotices/>. #
doc="Type of source flux; typically one of Ap or Psf", dtype=str, default="Ap", ) dtype=float, doc="Minimum allowed signal-to-noise ratio for sources used for matching " "(in the flux specified by sourceFluxType); <= 0 for no limit", default=40, ) dtype=bool, doc="Exclude objects that have saturated, interpolated, or edge " "pixels using PixelFlags. For matchOptimisticB set this to False " "to recover previous matcher selector behavior.", default=True, )
"""Select sources that are useful for matching.
Good matching sources have high signal/noise, are non-blended. They need not be PSF sources, just have reliable centroids.
Distinguished from astrometrySourceSelector because it is more lenient (i.e. not checking footprints or bad flags). """
BaseSourceSelectorTask.__init__(self, *args, **kwargs)
"""Return a selection of sources that are useful for matching.
Parameters: ----------- sourceCat : `lsst.afw.table.SourceCatalog` Catalog of sources to select from. This catalog must be contiguous in memory. matches : `list` of `lsst.afw.table.ReferenceMatch` or None Ignored in this SourceSelector. exposure : `lsst.afw.image.Exposure` or None The exposure the catalog was built from; used for debug display.
Return ------ struct : `lsst.pipe.base.Struct` The struct contains the following data:
- selected : `array` of `bool`` Boolean array of sources that were selected, same length as sourceCat. """ self._getSchemaKeys(sourceCat.schema)
good = self._isUsable(sourceCat) if self.config.excludePixelFlags: good = good & self._isGood(sourceCat) return Struct(selected=good)
"""Extract and save the necessary keys from schema with asKey.""" self.parentKey = schema["parent"].asKey() self.centroidXKey = schema["slot_Centroid_x"].asKey() self.centroidYKey = schema["slot_Centroid_y"].asKey() self.centroidFlagKey = schema["slot_Centroid_flag"].asKey()
fluxPrefix = "slot_%sFlux_" % (self.config.sourceFluxType,) self.fluxField = fluxPrefix + "instFlux" self.fluxKey = schema[fluxPrefix + "instFlux"].asKey() self.fluxFlagKey = schema[fluxPrefix + "flag"].asKey() self.fluxErrKey = schema[fluxPrefix + "instFluxErr"].asKey()
self.edgeKey = schema["base_PixelFlags_flag_edge"].asKey() self.interpolatedCenterKey = schema["base_PixelFlags_flag_interpolatedCenter"].asKey() self.saturatedKey = schema["base_PixelFlags_flag_saturated"].asKey()
"""Return True for each source that is the parent source.""" test = (sourceCat.get(self.parentKey) == 0) return test
"""Return True for each source that has a valid centroid""" return np.isfinite(sourceCat.get(self.centroidXKey)) \ & np.isfinite(sourceCat.get(self.centroidYKey)) \ & ~sourceCat.get(self.centroidFlagKey)
"""Return True for each source that has Signal/Noise > config.minSnr.""" if self.config.minSnr <= 0: return True else: with np.errstate(invalid="ignore"): # suppress NAN warnings return sourceCat.get(self.fluxKey)/sourceCat.get(self.fluxErrKey) > self.config.minSnr
""" Return True for each source that is usable for matching, even if it may have a poor centroid.
For a source to be usable it must: - have a valid centroid - not be deblended - have a valid instFlux (of the type specified in this object's constructor) - have adequate signal-to-noise """ return self._hasCentroid(sourceCat) \ & self._isParent(sourceCat) \ & self._goodSN(sourceCat) \ & ~sourceCat.get(self.fluxFlagKey)
""" Return True for each source that is usable for matching, even if it may have a poor centroid.
For a source to be usable it must: - Not be on a CCD edge. - Not have an interpolated pixel within 3x3 around their centroid. - Not have a saturated pixel in their footprint. """ return ~sourceCat.get(self.edgeKey) & \ ~sourceCat.get(self.interpolatedCenterKey) & \ ~sourceCat.get(self.saturatedKey) |