23 #include "pybind11/pybind11.h"
24 #include "pybind11/stl.h"
26 #include "lsst/pex/config/python.h"
31 namespace py = pybind11;
32 using namespace pybind11::literals;
40 template <
typename Catalog1,
typename Catalog2>
41 void declareMatch2(py::module &mod, std::string
const &prefix) {
42 typedef typename Catalog1::Record Record1;
43 typedef typename Catalog2::Record Record2;
44 typedef std::vector<Match<typename Catalog1::Record, typename Catalog2::Record>> MatchList;
46 using Class = Match<Record1, Record2>;
47 py::class_<Class, std::shared_ptr<Class>> clsMatch(mod, (prefix +
"Match").c_str());
48 clsMatch.def(py::init<>());
49 clsMatch.def(py::init<std::shared_ptr<Record1>
const &, std::shared_ptr<Record2>
const &,
double>(),
50 "first"_a,
"second"_a,
"distance"_a);
58 mod.def(
"unpackMatches", &unpackMatches<Catalog1, Catalog2>,
"matches"_a,
"cat1"_a,
"cat2"_a);
60 mod.def(
"matchRaDec", (MatchList(*)(Catalog1
const &, Catalog2
const &,
geom::Angle,
61 MatchControl
const &))matchRaDec<Catalog1, Catalog2>,
62 "cat1"_a,
"cat2"_a,
"radius"_a,
"mc"_a = MatchControl());
70 template <
typename Catalog>
71 void declareMatch1(py::module &mod) {
72 typedef std::vector<Match<typename Catalog::Record, typename Catalog::Record>> MatchList;
74 (MatchList(*)(Catalog
const &,
geom::Angle, MatchControl
const &))matchRaDec<Catalog>,
"cat"_a,
75 "radius"_a,
"mc"_a = MatchControl());
85 py::module mod(
"match",
"Python wrapper for afw _match library");
87 py::class_<MatchControl> clsMatchControl(mod,
"MatchControl");
88 clsMatchControl.def(py::init<>());
89 LSST_DECLARE_CONTROL_FIELD(clsMatchControl,
MatchControl, findOnlyClosest);
90 LSST_DECLARE_CONTROL_FIELD(clsMatchControl,
MatchControl, symmetricMatch);
91 LSST_DECLARE_CONTROL_FIELD(clsMatchControl,
MatchControl, includeMismatches);
93 declareMatch2<SimpleCatalog, SimpleCatalog>(mod,
"Simple");
94 declareMatch2<SimpleCatalog, SourceCatalog>(mod,
"Reference");
95 declareMatch2<SourceCatalog, SourceCatalog>(mod,
"Source");
96 declareMatch1<SimpleCatalog>(mod);
97 declareMatch1<SourceCatalog>(mod);
lsst::afw::geom::Angle Angle
Pass parameters to algorithms that match list of sources.
PYBIND11_PLUGIN(_cameraPoint)
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
SourceMatchVector matchXy(SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between...
std::vector< SourceMatch > SourceMatchVector