lsst.meas.base  13.0-26-g0f127ff+5
fluxUtilities.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2017 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
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 
26 
27 namespace py = pybind11;
28 using namespace py::literals;
29 
30 namespace lsst {
31 namespace meas {
32 namespace base {
33 
34 namespace {
35 
36 using PyFluxResult = py::class_<FluxResult, std::shared_ptr<FluxResult>>;
37 using PyFluxResultKey =
38  py::class_<FluxResultKey, std::shared_ptr<FluxResultKey>>;
39 using PyMagResult = py::class_<MagResult, std::shared_ptr<MagResult>>;
40 using PyMagResultKey =
41  py::class_<MagResultKey, std::shared_ptr<MagResultKey>>;
42 
43 void declareFluxResult(py::module &mod) {
44  PyFluxResult cls(mod, "FluxResult");
45 
46  cls.def_readwrite("flux", &FluxResult::flux);
47  cls.def_readwrite("fluxSigma", &FluxResult::fluxSigma);
48 }
49 
50 void declareFluxResultKey(py::module &mod) {
51  PyFluxResultKey cls(mod, "FluxResultKey");
52 
53  cls.def(py::init<>());
54  cls.def(py::init<afw::table::Key<meas::base::Flux> const &, afw::table::Key<FluxErrElement> const &>(),
55  "flux"_a, "fluxSigma"_a);
56  cls.def(py::init<afw::table::SubSchema const &>());
57 
58  cls.def("__eq__", &FluxResultKey::operator==, py::is_operator());
59  cls.def("__ne__", &FluxResultKey::operator!=, py::is_operator());
60 
61  cls.def("get", &FluxResultKey::get);
62  cls.def("set", &FluxResultKey::set);
63  cls.def_static("addFields", &FluxResultKey::addFields, "schema"_a, "name"_a, "doc"_a);
64  cls.def("isValid", &FluxResultKey::isValid);
65  cls.def("getFlux", &FluxResultKey::getFlux);
66  cls.def("getFluxSigma", &FluxResultKey::getFluxSigma);
67 }
68 
69 void declareMagResult(py::module &mod) {
70  PyMagResult cls(mod, "MagResult");
71 
72  cls.def_readwrite("mag", &MagResult::mag);
73  cls.def_readwrite("magErr", &MagResult::magErr);
74 }
75 
76 void declareMagResultKey(py::module &mod) {
77  PyMagResultKey cls(mod, "MagResultKey");
78 
79  cls.def(py::init<>());
80  cls.def(py::init<afw::table::SubSchema const &>());
81 
82  cls.def("get", &MagResultKey::get);
83  cls.def("set",
84  (void (MagResultKey::*)(afw::table::BaseRecord &, MagResult const &) const) & MagResultKey::set);
85  cls.def("set",
86  (void (MagResultKey::*)(afw::table::BaseRecord &, std::pair<double, double> const &) const) &
87  MagResultKey::set);
88  cls.def_static("addFields", &MagResultKey::addFields, "schema"_a, "name"_a);
89 }
90 } // <anonymous>
91 
93  py::module::import("lsst.afw.table");
94 
95  py::module mod("fluxUtilities");
96 
97  declareFluxResult(mod);
98  declareFluxResultKey(mod);
99  declareMagResult(mod);
100  declareMagResultKey(mod);
101 
102  return mod.ptr();
103 }
104 
105 } // base
106 } // meas
107 } // lsst
PYBIND11_PLUGIN(fluxUtilities)
Definition: mainpage.dox:3