lsst.meas.astrom  14.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
createWcsWithSip.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 #include <vector>
27 
28 #include "numpy/arrayobject.h"
29 #include "ndarray/pybind11.h"
30 
31 #include "lsst/afw/geom/Box.h"
32 #include "lsst/afw/image/TanWcs.h"
33 #include "lsst/afw/table/Match.h"
35 
36 namespace py = pybind11;
37 using namespace pybind11::literals;
38 
39 namespace lsst {
40 namespace meas {
41 namespace astrom {
42 namespace sip {
43 namespace {
44 
45 template <typename MatchT>
46 static void declareCreateWcsWithSip(py::module &mod, std::string const &name) {
47  py::class_<CreateWcsWithSip<MatchT>, std::shared_ptr<CreateWcsWithSip<MatchT>>> cls(mod, name.c_str());
48 
49  cls.def(py::init<std::vector<MatchT> const &, afw::image::Wcs const &, int const,
50  afw::geom::Box2I const &, int const>(),
51  "matches"_a, "linearWcs"_a, "order"_a, "bbox"_a = afw::geom::Box2I(), "ngrid"_a = 0);
52 
53  cls.def("getNewWcs", &CreateWcsWithSip<MatchT>::getNewWcs);
54  cls.def("getScatterInPixels", &CreateWcsWithSip<MatchT>::getScatterInPixels);
55  cls.def("getScatterOnSky", &CreateWcsWithSip<MatchT>::getScatterOnSky);
56  cls.def("getLinearScatterInPixels", &CreateWcsWithSip<MatchT>::getLinearScatterInPixels);
57  cls.def("getLinearScatterOnSky", &CreateWcsWithSip<MatchT>::getLinearScatterOnSky);
58  cls.def("getOrder", &CreateWcsWithSip<MatchT>::getOrder);
59  cls.def("getNPoints", &CreateWcsWithSip<MatchT>::getNPoints);
60  cls.def("getNGrid", &CreateWcsWithSip<MatchT>::getNGrid);
61 
62  mod.def("makeCreateWcsWithSip", &makeCreateWcsWithSip<MatchT>, "matches"_a, "linearWcs"_a, "order"_a,
63  "bbox"_a = afw::geom::Box2I(), "ngrid"_a = 0);
64 }
65 
66 } // namespace lsst::meas::astrom::sip::<anonymous>
67 
68 PYBIND11_PLUGIN(createWcsWithSip) {
69  py::module mod("createWcsWithSip");
70 
71  // Need to import numpy for ndarray and eigen conversions
72  if (_import_array() < 0) {
73  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
74  return nullptr;
75  }
76 
77  declareCreateWcsWithSip<afw::table::ReferenceMatch>(mod, "CreateWcsWithSipReferenceMatch");
78  declareCreateWcsWithSip<afw::table::SourceMatch>(mod, "CreateWcsWithSipSourceMatch");
79 
80  return mod.ptr();
81 }
82 }
83 }
84 }
85 } // namespace lsst::meas::astrom::sip
PYBIND11_PLUGIN(makeMatchStatistics)