2__all__ = [
"DirectMatchConfig",
"DirectMatchTask",
"DirectMatchConfigWithoutLoader"]
8from lsst.meas.algorithms
import (LoadReferenceObjectsConfig, 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 = ConfigField(dtype=LoadReferenceObjectsConfig,
29 doc="Configuration of reference object loader")
33 """Simple, brute force matching of a source catalog to a reference catalog.
38 Compatibility parameter. Should
not be used.
39 refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`
or `
None`
40 For loading reference objects.
42 Other keyword arguments required
for instantiating a Task (such
as
45 ConfigClass = DirectMatchConfig
46 _DefaultName = "directMatch"
48 def __init__(self, butler=None, refObjLoader=None, **kwargs):
49 Task.__init__(self, **kwargs)
52 if not isinstance(self.
config, DirectMatchConfig):
53 raise RuntimeError(
"DirectMatchTask must be initialized with DirectMatchConfig "
54 "if a refObjLoader is not supplied at initialization")
55 warnings.warn(
"The 'butler' parameter is no longer used and can be safely removed.",
56 category=FutureWarning, stacklevel=2)
58 self.makeSubtask(
"sourceSelection")
59 self.makeSubtask(
"referenceSelection")
62 """Set the reference object loader for the task.
66 refObjLoader : `lsst.meas.algorithms.ReferenceObjectLoader`
67 An instance of a reference object loader.
71 def run(self, catalog, filterName=None, epoch=None):
72 """Load reference objects and match to them.
79 Name of filter loading fluxes.
80 epoch : `astropy.time.Time` or `
None`
81 Epoch to which to correct proper motion
and parallax,
or `
None` to
82 not apply such corrections.
86 result : `lsst.pipe.base.Struct`
87 Result struct
with components:
90 Matched sources
with associated reference
93 Match metadata (`lsst.meas.astrom.MatchMetadata`).
96 raise RuntimeError(
"Running matcher task with no refObjLoader set in __ini__ or setRefObjLoader")
98 matchMeta = self.
refObjLoader.getMetadataCircle(circle.center, circle.radius, filterName, epoch=epoch)
99 emptyResult = Struct(matches=[], matchMeta=matchMeta)
100 sourceSelection = self.sourceSelection.
run(catalog)
101 if len(sourceSelection.sourceCat) == 0:
102 self.log.warning(
"No objects selected from %d objects in source catalog", len(catalog))
104 refData = self.
refObjLoader.loadSkyCircle(circle.center, circle.radius, filterName, epoch=epoch)
105 refCat = refData.refCat
106 refSelection = self.referenceSelection.
run(refCat)
107 if len(refSelection.sourceCat) == 0:
108 self.log.warning(
"No objects selected from %d objects in reference catalog", len(refCat))
111 self.
config.matchRadius*arcseconds)
112 self.log.info(
"Matched %d from %d/%d input and %d/%d reference sources",
113 len(matches), len(sourceSelection.sourceCat), len(catalog),
114 len(refSelection.sourceCat), len(refCat))
115 return Struct(matches=matches, matchMeta=matchMeta, refCat=refCat, sourceSelection=sourceSelection,
116 refSelection=refSelection)
119 """Calculate a circle enclosing the catalog.
128 result : `lsst.pipe.base.Struct`
129 Result struct with components:
132 ICRS center coordinate (`lsst.afw.geom.SpherePoint`).
136 coordList = [src.getCoord() for src
in catalog]
137 center = averageSpherePoint(coordList)
138 radius = max(center.separation(coord)
for coord
in coordList)
139 return Struct(center=center, radius=radius + self.
config.matchRadius*arcseconds)
run(self, catalog, filterName=None, epoch=None)
setRefObjLoader(self, refObjLoader)
__init__(self, butler=None, refObjLoader=None, **kwargs)
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())