lsst.jointcal  master-g9041cab851
 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  // these three are actually declared in FatPoint, but we don't need that in Python.
53  // NOTE: see DM-9814 about the necessity of the pointer cast below.
54  cls.def_readonly("vx", (double BaseStar::*)&BaseStar::vx);
55  cls.def_readonly("vy", (double BaseStar::*)&BaseStar::vy);
56  cls.def_readonly("vxy", (double BaseStar::*)&BaseStar::vxy);
57 
58  // cls.def("getFlux", &BaseStar::getFlux);
59  cls.def_property_readonly("flux", (double (BaseStar::*)() const) & BaseStar::getFlux);
60 
61  cls.def("__str__", &BaseStar::__str__);
62 }
63 
64 void declareRefStar(py::module &mod) {
65  py::class_<RefStar, std::shared_ptr<RefStar>, BaseStar> cls(mod, "RefStar");
66 
67  cls.def(py::init<double, double, double, double, std::vector<double> &, std::vector<double> &>(), "xx"_a,
68  "yy"_a, "defaultFlux"_a, "defaultFluxErr"_a, "refFluxList"_a, "refFluxErrList"_a);
69 }
70 
71 void declareFittedStar(py::module &mod) {
72  py::class_<FittedStar, std::shared_ptr<FittedStar>, BaseStar> cls(mod, "FittedStar");
73 
74  cls.def(py::init<BaseStar const &>(), "baseStar"_a);
75 }
76 
77 void declareMeasuredStar(py::module &mod) {
78  py::class_<MeasuredStar, std::shared_ptr<MeasuredStar>, BaseStar> cls(mod, "MeasuredStar");
79 
80  cls.def(py::init<BaseStar const &>(), "baseStar"_a);
81 }
82 
83 PYBIND11_PLUGIN(star) {
84  py::module mod("star");
85 
86  declarePoint(mod);
87  declareBaseStar(mod);
88  declareRefStar(mod);
89  declareFittedStar(mod);
90  declareMeasuredStar(mod);
91 
92  return mod.ptr();
93 }
94 } // namespace
95 } // namespace jointcal
96 } // namespace lsst