lsst.meas.modelfit  13.0-8-g8613bc8+13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
unitSystem.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #include "pybind11/pybind11.h"
25 
27 
28 namespace py = pybind11;
29 using namespace pybind11::literals;
30 
31 namespace lsst {
32 namespace meas {
33 namespace modelfit {
34 namespace {
35 
36 using PyUnitSystem = py::class_<UnitSystem, std::shared_ptr<UnitSystem>>;
37 using PyLocalUnitTransform = py::class_<LocalUnitTransform, std::shared_ptr<LocalUnitTransform>>;
38 
39 PYBIND11_PLUGIN(unitSystem) {
40  py::module::import("lsst.afw.coord");
41  py::module::import("lsst.afw.image");
42 
43  py::module mod("unitSystem");
44 
45  // Data member wrappers in this module are intentionally read-only;
46  // setting them in Python should never be necessary and hence always
47  // represents a mistake we want to fail on as early as possible.
48 
49  PyUnitSystem clsUnitSystem(mod, "UnitSystem");
50  clsUnitSystem.def_readonly("wcs", &UnitSystem::wcs);
51  clsUnitSystem.def_readonly("calib", &UnitSystem::calib);
52  clsUnitSystem.def(py::init<afw::coord::Coord const &, std::shared_ptr<afw::image::Calib const>, double>(),
53  "position"_a, "calibIn"_a, "flux"_a);
54  clsUnitSystem.def(py::init<afw::coord::Coord const &, Scalar>(), "position"_a, "mag"_a);
55  clsUnitSystem.def(
56  py::init<std::shared_ptr<afw::image::Wcs const>, std::shared_ptr<afw::image::Calib const>>(),
57  "wcs"_a, "calib"_a);
58  clsUnitSystem.def(py::init<afw::image::Exposure<float> const &>(), "exposure"_a);
59  clsUnitSystem.def(py::init<afw::image::Exposure<double> const &>(), "exposure"_a);
60 
61  PyLocalUnitTransform clsLocalUnitTransform(mod, "LocalUnitTransform");
62  clsLocalUnitTransform.def_readonly("geometric", &LocalUnitTransform::geometric);
63  clsLocalUnitTransform.def_readonly("flux", &LocalUnitTransform::flux);
64  clsLocalUnitTransform.def_readonly("sb", &LocalUnitTransform::sb);
65  clsLocalUnitTransform.def(py::init<afw::coord::Coord const &, UnitSystem const &, UnitSystem const &>(),
66  "position"_a, "source"_a, "destination"_a);
67  clsLocalUnitTransform.def(py::init<>());
68 
69  return mod.ptr();
70 }
71 }
72 }
73 }
74 } // namespace lsst::meas::modelfit::anonymous