23 __all__ = [
'RefMatchConfig',
'RefMatchTask']
33 from .matchPessimisticB
import MatchPessimisticBTask
34 from .display
import displayAstrometry
35 from .
import makeMatchStatistics
39 matcher = pexConfig.ConfigurableField(
40 target=MatchPessimisticBTask,
41 doc=
"reference object/source matcher",
43 matchDistanceSigma = pexConfig.RangeField(
44 doc=
"the maximum match distance is set to " 45 " mean_match_distance + matchDistanceSigma*std_dev_match_distance; " 46 "ignored if not fitting a WCS",
51 sourceSelection = pexConfig.ConfigurableField(target=ScienceSourceSelectorTask,
52 doc=
"Selection of science sources")
53 referenceSelection = pexConfig.ConfigurableField(target=ReferenceSourceSelectorTask,
54 doc=
"Selection of reference sources")
58 """Match an input source catalog with objects from a reference catalog. 62 refObjLoader : `lsst.meas.algorithms.ReferenceLoader` 63 A reference object loader object 65 additional keyword arguments for pipe_base `lsst.pipe.base.Task` 67 ConfigClass = RefMatchConfig
68 _DefaultName =
"calibrationBaseClass" 71 pipeBase.Task.__init__(self, **kwargs)
76 self.makeSubtask(
"matcher")
77 self.makeSubtask(
"sourceSelection")
78 self.makeSubtask(
"referenceSelection")
81 """Sets the reference object loader for the task 86 An instance of a reference object loader task or class 92 """Load reference objects overlapping an exposure and match to sources 93 detected on that exposure. 97 exposure : `lsst.afw.image.Exposure` 98 exposure that the sources overlap 99 sourceCat : `lsst.afw.table.SourceCatalog.` 100 catalog of sources detected on the exposure 104 result : `lsst.pipe.base.Struct` 105 Result struct with Components: 107 - ``refCat`` : reference object catalog of objects that overlap the 108 exposure (`lsst.afw.table.SimpleCatalog`) 109 - ``matches`` : Matched sources and references 110 (`list` of `lsst.afw.table.ReferenceMatch`) 111 - ``matchMeta`` : metadata needed to unpersist matches 112 (`lsst.daf.base.PropertyList`) 116 ignores config.matchDistanceSigma 119 raise RuntimeError(
"Running matcher task with no refObjLoader set in __ini__ or setRefObjLoader")
125 sourceSelection = self.sourceSelection.
run(sourceCat)
130 filterName=expMd.filterName,
134 refSelection = self.referenceSelection.
run(loadRes.refCat)
139 filterName=expMd.filterName,
143 matchRes = self.matcher.matchObjectsToSources(
144 refCat=refSelection.sourceCat,
145 sourceCat=sourceSelection.sourceCat,
147 refFluxField=loadRes.fluxField,
148 match_tolerance=
None,
153 "Found %d matches with scatter = %0.3f +- %0.3f arcsec; " %
154 (len(matchRes.matches), distStats.distMean.asArcseconds(), distStats.distStdDev.asArcseconds())
158 frame =
int(debug.frame)
160 refCat=refSelection.sourceCat,
161 sourceCat=sourceSelection.sourceCat,
162 matches=matchRes.matches,
169 return pipeBase.Struct(
170 refCat=loadRes.refCat,
171 refSelection=refSelection,
172 sourceSelection=sourceSelection,
173 matches=matchRes.matches,
177 def _computeMatchStatsOnSky(self, matchList):
178 """Compute on-sky radial distance statistics for a match list 182 matchList : `list` of `lsst.afw.table.ReferenceMatch` 183 list of matches between reference object and sources; 184 the distance field is the only field read and it must be set to distance in radians 188 result : `lsst.pipe.base.Struct` 189 Result struct with components: 191 - ``distMean`` : clipped mean of on-sky radial separation (`float`) 192 - ``distStdDev`` : clipped standard deviation of on-sky radial 194 - ``maxMatchDist`` : distMean + self.config.matchDistanceSigma * 198 distMean = distStatsInRadians.getValue(afwMath.MEANCLIP)*lsst.geom.radians
199 distStdDev = distStatsInRadians.getValue(afwMath.STDEVCLIP)*lsst.geom.radians
200 return pipeBase.Struct(
202 distStdDev=distStdDev,
203 maxMatchDist=distMean + self.config.matchDistanceSigma * distStdDev,
206 def _getExposureMetadata(self, exposure):
207 """Extract metadata from an exposure. 211 exposure : `lsst.afw.image.Exposure` 215 result : `lsst.pipe.base.Struct` 216 Result struct with components: 218 - ``bbox`` : parent bounding box (`lsst.geom.Box2I`) 219 - ``wcs`` : exposure WCS (`lsst.afw.geom.SkyWcs`) 220 - ``calib`` : calibration (`lsst.afw.image.Calib`) 221 - ``filterName`` : name of filter (`str`) 222 - ``epoch`` : date of exposure (`astropy.time.Time`) 225 exposureInfo = exposure.getInfo()
226 filterName = exposureInfo.getFilter().getName()
or None 227 if filterName ==
"_unknown_":
230 if exposure.getInfo().hasVisitInfo():
231 epochTaiMjd = exposure.getInfo().getVisitInfo().getDate().get(system=DateTime.MJD,
233 epoch = astropy.time.Time(epochTaiMjd, scale=
"tai", format=
"mjd")
235 return pipeBase.Struct(
236 bbox=exposure.getBBox(),
237 wcs=exposureInfo.getWcs(),
238 calib=exposureInfo.getCalib()
if exposureInfo.hasCalib()
else None,
239 filterName=filterName,
def _computeMatchStatsOnSky(self, matchList)
def _getExposureMetadata(self, exposure)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
def displayAstrometry(refCat=None, sourceCat=None, distortedCentroidKey=None, bbox=None, exposure=None, matches=None, frame=1, title="", pause=True)
def setRefObjLoader(self, refObjLoader)
def loadAndMatch(self, exposure, sourceCat)
def __init__(self, refObjLoader, kwargs)