2__all__ = [
"DirectMatchConfig",
"DirectMatchTask",
"DirectMatchConfigWithoutLoader"]
8from lsst.meas.algorithms
import (LoadIndexedReferenceObjectsTask, ScienceSourceSelectorTask,
9 ReferenceSourceSelectorTask)
11from lsst.geom import arcseconds, averageSpherePoint
15 """Configuration for `DirectMatchTask` when an already-initialized
16 ``refObjLoader`` will be passed to this task.
18 matchRadius = Field(dtype=float, default=0.25, doc="Matching radius, arcsec")
19 sourceSelection = ConfigurableField(target=ScienceSourceSelectorTask,
20 doc=
"Selection of science sources")
21 referenceSelection = ConfigurableField(target=ReferenceSourceSelectorTask,
22 doc=
"Selection of reference sources")
26 """Configuration for `DirectMatchTask`.
28 refObjLoader = ConfigurableField(target=LoadIndexedReferenceObjectsTask, doc="Load reference objects")
32 """Simple, brute force matching of a source catalog to a reference catalog.
37 Compatibility parameter. Should
not be used.
38 refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`
or `
None`
39 For loading reference objects.
41 Other keyword arguments required
for instantiating a Task (such
as
44 ConfigClass = DirectMatchConfig
45 _DefaultName = "directMatch"
47 def __init__(self, butler=None, refObjLoader=None, **kwargs):
48 Task.__init__(self, **kwargs)
51 if not isinstance(self.config, DirectMatchConfig):
52 raise RuntimeError(
"DirectMatchTask must be initialized with DirectMatchConfig "
53 "if a refObjLoader is not supplied at initialization")
54 warnings.warn(
"The 'butler' parameter is no longer used and can be safely removed.",
55 category=FutureWarning, stacklevel=2)
57 self.makeSubtask(
"sourceSelection")
58 self.makeSubtask(
"referenceSelection")
61 """Set the reference object loader for the task.
65 refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`
66 An instance of a reference object loader.
70 def run(self, catalog, filterName=None, epoch=None):
71 """Load reference objects and match to them.
78 Name of filter loading fluxes.
79 epoch : `astropy.time.Time` or `
None`
80 Epoch to which to correct proper motion
and parallax,
or `
None` to
81 not apply such corrections.
85 result : `lsst.pipe.base.Struct`
86 Result struct
with components:
89 Matched sources
with associated reference
92 Match metadata (`lsst.meas.astrom.MatchMetadata`).
95 raise RuntimeError(
"Running matcher task with no refObjLoader set in __ini__ or setRefObjLoader")
97 matchMeta = self.
refObjLoader.getMetadataCircle(circle.center, circle.radius, filterName, epoch=epoch)
98 emptyResult = Struct(matches=[], matchMeta=matchMeta)
99 sourceSelection = self.sourceSelection.
run(catalog)
100 if len(sourceSelection.sourceCat) == 0:
101 self.log.warning(
"No objects selected from %d objects in source catalog", len(catalog))
103 refData = self.
refObjLoader.loadSkyCircle(circle.center, circle.radius, filterName, epoch=epoch)
104 refCat = refData.refCat
105 refSelection = self.referenceSelection.
run(refCat)
106 if len(refSelection.sourceCat) == 0:
107 self.log.warning(
"No objects selected from %d objects in reference catalog", len(refCat))
110 self.config.matchRadius*arcseconds)
111 self.log.info(
"Matched %d from %d/%d input and %d/%d reference sources",
112 len(matches), len(sourceSelection.sourceCat), len(catalog),
113 len(refSelection.sourceCat), len(refCat))
114 return Struct(matches=matches, matchMeta=matchMeta, refCat=refCat, sourceSelection=sourceSelection,
115 refSelection=refSelection)
118 """Calculate a circle enclosing the catalog.
127 result : `lsst.pipe.base.Struct`
128 Result struct with components:
131 ICRS center coordinate (`lsst.afw.geom.SpherePoint`).
135 coordList = [src.getCoord() for src
in catalog]
136 center = averageSpherePoint(coordList)
137 radius = max(center.separation(coord)
for coord
in coordList)
138 return Struct(center=center, radius=radius + self.config.matchRadius*arcseconds)
def setRefObjLoader(self, refObjLoader)
def run(self, catalog, filterName=None, epoch=None)
def __init__(self, butler=None, refObjLoader=None, **kwargs)
def calculateCircle(self, catalog)
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > matchRaDec(Cat1 const &cat1, Cat2 const &cat2, lsst::geom::Angle radius, MatchControl const &mc=MatchControl())