22 from __future__
import absolute_import, division, print_function
24 __all__ = [
'RefMatchConfig',
'RefMatchTask']
30 import lsst.pipe.base
as pipeBase
31 from .matchOptimisticB
import MatchOptimisticBTask
32 from .display
import displayAstrometry
33 from .
import makeMatchStatistics
37 matcher = pexConfig.ConfigurableField(
38 target=MatchOptimisticBTask,
39 doc=
"reference object/source matcher",
41 matchDistanceSigma = pexConfig.RangeField(
42 doc=
"the maximum match distance is set to " 43 " mean_match_distance + matchDistanceSigma*std_dev_match_distance; " +
44 "ignored if not fitting a WCS",
60 """!Match an input source catalog with objects from a reference catalog 64 ConfigClass = RefMatchConfig
65 _DefaultName =
"calibrationBaseClass" 67 def __init__(self, refObjLoader, schema=None, **kwargs):
68 """!Construct a RefMatchTask 70 @param[in] refObjLoader A reference object loader object 71 @param[in] schema ignored; available for compatibility with an older astrometry task 72 @param[in] kwargs additional keyword arguments for pipe_base Task.\_\_init\_\_ 74 pipeBase.Task.__init__(self, **kwargs)
76 self.makeSubtask(
"matcher")
80 """!Load reference objects overlapping an exposure and match to sources detected on that exposure 82 @param[in] exposure exposure that the sources overlap 83 @param[in] sourceCat catalog of sources detected on the exposure (an lsst.afw.table.SourceCatalog) 85 @return an lsst.pipe.base.Struct with these fields: 86 - refCat reference object catalog of objects that overlap the exposure (with some margin) 87 (an lsst::afw::table::SimpleCatalog) 88 - matches a list of lsst.afw.table.ReferenceMatch 89 - matchMeta metadata needed to unpersist matches (an lsst.daf.base.PropertyList) 91 @note ignores config.matchDistanceSigma 101 filterName=expMd.filterName,
107 filterName=expMd.filterName,
111 matchRes = self.matcher.matchObjectsToSources(
112 refCat=loadRes.refCat,
115 refFluxField=loadRes.fluxField,
116 match_tolerance=
None,
121 "Found %d matches with scatter = %0.3f +- %0.3f arcsec; " %
122 (len(matchRes.matches), distStats.distMean.asArcseconds(), distStats.distStdDev.asArcseconds())
126 frame = int(debug.frame)
128 refCat=loadRes.refCat,
130 matches=matchRes.matches,
137 return pipeBase.Struct(
138 refCat=loadRes.refCat,
139 matches=matchRes.matches,
143 def _computeMatchStatsOnSky(self, matchList):
144 """Compute on-sky radial distance statistics for a match list 146 @param[in] matchList list of matches between reference object and sources; 147 the distance field is the only field read and it must be set to distance in radians 149 @return a pipe_base Struct containing these fields: 150 - distMean clipped mean of on-sky radial separation 151 - distStdDev clipped standard deviation of on-sky radial separation 152 - maxMatchDist distMean + self.config.matchDistanceSigma*distStdDev 155 distMean = distStatsInRadians.getValue(afwMath.MEANCLIP)*afwGeom.radians
156 distStdDev = distStatsInRadians.getValue(afwMath.STDEVCLIP)*afwGeom.radians
157 return pipeBase.Struct(
159 distStdDev=distStdDev,
160 maxMatchDist=distMean + self.config.matchDistanceSigma*distStdDev,
163 def _getExposureMetadata(self, exposure):
164 """!Extract metadata from an exposure 166 @return an lsst.pipe.base.Struct containing the following exposure metadata: 167 - bbox: parent bounding box 168 - wcs: WCS (an lsst.afw.image.Wcs) 169 - calib calibration (an lsst.afw.image.Calib), or None if unknown 170 - filterName: name of filter, or None if unknown 172 exposureInfo = exposure.getInfo()
173 filterName = exposureInfo.getFilter().getName()
or None 174 if filterName ==
"_unknown_":
176 return pipeBase.Struct(
177 bbox=exposure.getBBox(),
178 wcs=getDistortedWcs(exposureInfo, log=self.log),
179 calib=exposureInfo.getCalib()
if exposureInfo.hasCalib()
else None,
180 filterName=filterName,
def _computeMatchStatsOnSky(self, matchList)
def __init__(self, refObjLoader, schema=None, kwargs)
Construct a RefMatchTask.
def _getExposureMetadata(self, exposure)
Extract metadata from an exposure.
Match an input source catalog with objects from a reference catalog.
def displayAstrometry(refCat=None, sourceCat=None, distortedCentroidKey=None, bbox=None, exposure=None, matches=None, frame=1, title="", pause=True)
def loadAndMatch(self, exposure, sourceCat)
Load reference objects overlapping an exposure and match to sources detected on that exposure...