93 def __init__(self, refObjLoader=None, **kwargs):
94 pipeBase.Task.__init__(self, **kwargs)
100 if self.config.sourceSelector.name ==
'matcher':
101 if self.config.sourceSelector[
'matcher'].sourceFluxType != self.config.sourceFluxType:
102 raise RuntimeError(
"The sourceFluxType in the sourceSelector['matcher'] must match "
103 "the configured sourceFluxType")
105 self.makeSubtask(
"matcher")
106 self.makeSubtask(
"sourceSelector")
107 self.makeSubtask(
"referenceSelector")
121 """Load reference objects overlapping an exposure and match to sources
122 detected on that exposure.
126 exposure : `lsst.afw.image.Exposure`
127 exposure that the sources overlap
128 sourceCat : `lsst.afw.table.SourceCatalog.`
129 catalog of sources detected on the exposure
133 result : `lsst.pipe.base.Struct`
134 Result struct with Components:
136 - ``refCat`` : reference object catalog of objects that overlap the
137 exposure (`lsst.afw.table.SimpleCatalog`)
138 - ``matches`` : Matched sources and references
139 (`list` of `lsst.afw.table.ReferenceMatch`)
140 - ``matchMeta`` : metadata needed to unpersist matches
141 (`lsst.daf.base.PropertyList`)
145 ignores config.matchDistanceSigma
148 raise RuntimeError(
"Running matcher task with no refObjLoader set in __ini__ or setRefObjLoader")
152 epoch = exposure.visitInfo.date.toAstropy()
154 sourceSelection = self.sourceSelector.run(sourceCat)
156 sourceFluxField =
"slot_%sFlux_instFlux" % (self.config.sourceFluxType)
159 bbox=exposure.getBBox(),
161 filterName=exposure.filter.bandLabel,
165 refSelection = self.referenceSelector.run(loadRes.refCat, exposure=exposure)
168 bbox=exposure.getBBox(),
170 filterName=exposure.filter.bandLabel,
174 matchRes = self.matcher.matchObjectsToSources(
175 refCat=refSelection.sourceCat,
176 sourceCat=sourceSelection.sourceCat,
178 sourceFluxField=sourceFluxField,
179 refFluxField=loadRes.fluxField,
181 bbox=exposure.getBBox(),
186 "Found %d matches with scatter = %0.3f +- %0.3f arcsec; ",
187 len(matchRes.matches), distStats.distMean.asArcseconds(), distStats.distStdDev.asArcseconds()
191 frame = int(debug.frame)
193 refCat=refSelection.sourceCat,
194 sourceCat=sourceSelection.sourceCat,
195 matches=matchRes.matches,
197 bbox=exposure.getBBox(),
202 return pipeBase.Struct(
203 refCat=loadRes.refCat,
204 refSelection=refSelection,
205 sourceSelection=sourceSelection,
206 matches=matchRes.matches,
211 """Compute on-sky radial distance statistics for a match list
215 matchList : `list` of `lsst.afw.table.ReferenceMatch`
216 list of matches between reference object and sources;
217 the distance field is the only field read and it must be set to distance in radians
221 result : `lsst.pipe.base.Struct`
222 Result struct with components:
224 - ``distMean`` : clipped mean of on-sky radial separation (`float`)
225 - ``distStdDev`` : clipped standard deviation of on-sky radial
227 - ``maxMatchDist`` : distMean + self.config.matchDistanceSigma *
231 distMean = distStatsInRadians.getValue(afwMath.MEANCLIP)*lsst.geom.radians
232 distStdDev = distStatsInRadians.getValue(afwMath.STDEVCLIP)*lsst.geom.radians
233 return pipeBase.Struct(
235 distStdDev=distStdDev,
236 maxMatchDist=distMean + self.config.matchDistanceSigma * distStdDev,