lsst.meas.astrom  13.0-14-g9415442+18
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
matchOptimisticB.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  *
4  * This product includes software developed by the
5  * LSST Project (http://www.lsst.org/).
6  * See the COPYRIGHT file
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
24 
25 #include <memory>
26 
27 #include "lsst/pex/config/python.h" // defines LSST_DECLARE_CONTROL_FIELD
29 
30 namespace py = pybind11;
31 using namespace pybind11::literals;
32 
33 namespace lsst {
34 namespace meas {
35 namespace astrom {
36 namespace {
37 
38 static void declareRecordProxy(py::module &mod) {
39  py::class_<RecordProxy, std::shared_ptr<RecordProxy>> cls(mod, "RecordProxy");
40 
41  cls.def_readwrite("record", &RecordProxy::record);
42  cls.def_readwrite("position", &RecordProxy::position);
43  cls.def_readwrite("used", &RecordProxy::used);
44 
45  cls.def(py::init<std::shared_ptr<afw::table::SimpleRecord>, afw::geom::Point2D const &>(), "record"_a,
46  "position"_a);
47 
48  // TO DO: decide if we need to wrap operator PTR(lsst::afw::table::SimpleRecord)()
49 
50  cls.def("__eq__", &RecordProxy::operator==, py::is_operator());
51  cls.def("__ne__", &RecordProxy::operator!=, py::is_operator());
52 
53  cls.def("getX", &RecordProxy::getX);
54  cls.def("getY", &RecordProxy::getY);
55 }
56 
57 static void declareProxyPair(py::module &mod) {
58  py::class_<ProxyPair, std::shared_ptr<ProxyPair>> cls(mod, "ProxyPair");
59 
60  cls.def_readwrite("first", &ProxyPair::first);
61  cls.def_readwrite("second", &ProxyPair::second);
62  cls.def_readwrite("distance", &ProxyPair::distance);
63  cls.def_readwrite("pa", &ProxyPair::pa);
64 
65  cls.def(py::init<RecordProxy const &, RecordProxy const &>(), "s1"_a, "s2"_a);
66 }
67 
68 static void declareMatchOptimisticBControl(py::module &mod) {
69  py::class_<MatchOptimisticBControl> cls(mod, "MatchOptimisticBControl");
70 
71  cls.def(py::init<>());
72 
73  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, refFluxField);
74  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, sourceFluxField);
75  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, numBrightStars);
76  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, minMatchedPairs);
77  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, matchingAllowancePix);
78  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, maxOffsetPix);
79  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, maxRotationDeg);
80  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, allowedNonperpDeg);
81  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, numPointsForShape);
82  LSST_DECLARE_CONTROL_FIELD(cls, MatchOptimisticBControl, maxDeterminant);
83 
84  cls.def("validate", &MatchOptimisticBControl::validate);
85 }
86 
87 } // namespace lsst::meas::astrom::<anonymous>
88 
90  py::module mod("matchOptimisticB");
91 
92  declareRecordProxy(mod);
93  declareProxyPair(mod);
94  declareMatchOptimisticBControl(mod);
95 
96  mod.def("makeProxies", (ProxyVector(*)(afw::table::SourceCatalog const &, afw::image::Wcs const &,
97  afw::image::Wcs const &)) &
99  "sourceCat"_a, "distortedWcs"_a, "tanWcs"_a);
100  mod.def("makeProxies",
101  (ProxyVector(*)(afw::table::SimpleCatalog const &, afw::image::Wcs const &)) & makeProxies,
102  "posRefCat"_a, "tanWcs"_a);
103 
104  mod.def("matchOptimisticB", &matchOptimisticB, "posRefCat"_a, "sourceCat"_a, "control"_a, "wcs"_a,
105  "posRefBegInd"_a = 0, "verbose"_a = false);
106 
107  return mod.ptr();
108 }
109 }
110 }
111 } // namespace lsst::meas::astrom
PYBIND11_PLUGIN(makeMatchStatistics)
std::vector< RecordProxy > ProxyVector
lsst::afw::table::ReferenceMatchVector matchOptimisticB(lsst::afw::table::SimpleCatalog const &posRefCat, lsst::afw::table::SourceCatalog const &sourceCat, MatchOptimisticBControl const &control, afw::image::Wcs const &wcs, int posRefBegInd=0, bool verbose=false)
Match sources to stars in a position reference catalog using optimistic pattern matching B...
ProxyVector makeProxies(lsst::afw::table::SourceCatalog const &sourceCat, afw::image::Wcs const &distortedWcs, afw::image::Wcs const &tanWcs)