lsst.jointcal  master-gc935ebf72c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
star.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 
23 #include "pybind11/pybind11.h"
24 #include "pybind11/stl.h"
25 
26 #include <list>
27 
28 #include "lsst/jointcal/Point.h"
29 #include "lsst/jointcal/FatPoint.h"
30 #include "lsst/jointcal/BaseStar.h"
33 #include "lsst/jointcal/RefStar.h"
34 
35 namespace py = pybind11;
36 using namespace pybind11::literals;
37 
38 namespace lsst {
39 namespace jointcal {
40 namespace {
41 
42 void declarePoint(py::module &mod) {
43  py::class_<Point, std::shared_ptr<Point>> cls(mod, "Point");
44 
45  cls.def_readonly("x", &Point::x);
46  cls.def_readonly("y", &Point::y);
47 }
48 
49 void declareBaseStar(py::module &mod) {
50  py::class_<BaseStar, std::shared_ptr<BaseStar>, Point> cls(mod, "BaseStar");
51 
52  cls.def(py::init<>());
53  cls.def(py::init<double, double, double>(), "x"_a, "y"_a, "flux"_a);
54 
55  // these three are actually declared in FatPoint, but we don't need that in Python.
56  // NOTE: see DM-9814 about the necessity of the pointer cast below.
57  cls.def_readonly("vx", (double BaseStar::*)&BaseStar::vx);
58  cls.def_readonly("vy", (double BaseStar::*)&BaseStar::vy);
59  cls.def_readonly("vxy", (double BaseStar::*)&BaseStar::vxy);
60 
61  // cls.def("getFlux", &BaseStar::getFlux);
62  cls.def_property_readonly("flux", (double (BaseStar::*)() const) & BaseStar::getFlux);
63 
64  cls.def("__str__", &BaseStar::__str__);
65 }
66 
67 void declareRefStar(py::module &mod) {
68  py::class_<RefStar, std::shared_ptr<RefStar>, BaseStar> cls(mod, "RefStar");
69 
70  cls.def(py::init<const BaseStar &>(), "baseStar"_a);
71 }
72 
73 void declareFittedStar(py::module &mod) {
74  py::class_<FittedStar, std::shared_ptr<FittedStar>, BaseStar> cls(mod, "FittedStar");
75 
76  cls.def(py::init<const BaseStar &>(), "baseStar"_a);
77 }
78 
79 void declareMeasuredStar(py::module &mod) {
80  py::class_<MeasuredStar, std::shared_ptr<MeasuredStar>, BaseStar> cls(mod, "MeasuredStar");
81 
82  cls.def(py::init<const BaseStar &>(), "baseStar"_a);
83 }
84 
85 PYBIND11_PLUGIN(star) {
86  py::module mod("star");
87 
88  declarePoint(mod);
89  declareBaseStar(mod);
90  declareRefStar(mod);
91  declareFittedStar(mod);
92  declareMeasuredStar(mod);
93 
94  return mod.ptr();
95 }
96 } // namespace
97 } // namespace jointcal
98 } // namespace lsst