lsst.afw  13.0-98-g5a654715e+2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
separable.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2016 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 //#include <pybind11/operators.h>
25 //#include <pybind11/stl.h>
26 
33 
34 namespace py = pybind11;
35 
36 using namespace py::literals;
37 
38 using namespace lsst::afw::geom::ellipses;
39 
40 template <typename Ellipticity_, typename Radius_>
41 void declareSeparable(py::module &mod, const std::string &suffix) {
43 
44  py::class_<Class, std::shared_ptr<Class>, BaseCore> cls(mod, ("Separable" + suffix).c_str());
45 
46  // py::enum_<typename Class::ParameterEnum>(mod, "ParameterEnum")
47  // .value("E0", Class::ParameterEnum::E0)
48  // .value("E1", Class::ParameterEnum::E1)
49  // .value("RADIUS", Class::ParameterEnum::RADIUS)
50  // .export_values();
51 
52  cls.def(py::init<double, double, double, bool>(), "e1"_a = 0.0, "e2"_a = 0.0, "radius"_a = Radius_(),
53  "normalize"_a = true);
54  // cls.def(py::init<std::complex<double> const &, double, bool>(),
55  // "complex"_a, "radius"_a=Radius_(), "normalize"_a=true);
56  // cls.def(py::init<Ellipticity_ const &, double, bool>(),
57  // "ellipticity"_a, "radius"_a=Radius_(), "normalize"_a=true);
58  // cls.def(py::init<BaseCore::ParameterVector const &, bool>(),
59  // "vector"_a, "normalize"_a=true);
60  cls.def(py::init<Class const &>());
61  cls.def(py::init<BaseCore const &>());
62 
63  cls.def("getE1", &Class::getE1);
64  cls.def("setE1", &Class::setE1);
65  cls.def("getE2", &Class::getE2);
66  cls.def("setE2", &Class::setE2);
67  cls.def("getRadius", (Radius_ const &(Class::*)() const) & Class::getRadius);
68  cls.def("setRadius", (void (Class::*)(double)) & Class::setRadius);
69  cls.def("setRadius", (void (Class::*)(Radius_ const &)) & Class::setRadius);
70  cls.def("getEllipticity", (Ellipticity_ const &(Class::*)() const) & Class::getEllipticity);
71  cls.def("clone", &Class::clone);
72  cls.def("getName", &Class::getName);
73  cls.def("normalize", &Class::normalize);
74  cls.def("assign", [](Class &self, Class &other) { self = other; });
75  cls.def("assign", [](Class &self, BaseCore &other) { self = other; });
76  cls.def("transform", [](Class &self, lsst::afw::geom::LinearTransform const &t) {
77  return std::static_pointer_cast<Class>(self.transform(t).copy());
78  });
79  cls.def("transformInPlace",
80  [](Class &self, lsst::afw::geom::LinearTransform const &t) { self.transform(t).inPlace(); });
81  cls.def("__str__",
82  [](Class &self) { return py::str("(%s, %s)").format(self.getEllipticity(), self.getRadius()); });
83  cls.def("__repr__", [](Class &self) {
84  return py::str("Separable(%r, %r)").format(self.getEllipticity(), self.getRadius());
85  });
86 }
87 
88 PYBIND11_PLUGIN(_separable) {
89  py::module mod("_separable", "Python wrapper for afw _separable library");
90 
91  declareSeparable<Distortion, DeterminantRadius>(mod, "DistortionDeterminantRadius");
92  declareSeparable<Distortion, TraceRadius>(mod, "DistortionTraceRadius");
93  declareSeparable<Distortion, LogDeterminantRadius>(mod, "DistortionLogDeterminantRadius");
94  declareSeparable<Distortion, LogTraceRadius>(mod, "DistortionLogTraceRadius");
95 
96  declareSeparable<ConformalShear, DeterminantRadius>(mod, "ConformalShearDeterminantRadius");
97  declareSeparable<ConformalShear, TraceRadius>(mod, "ConformalShearTraceRadius");
98  declareSeparable<ConformalShear, LogDeterminantRadius>(mod, "ConformalShearLogDeterminantRadius");
99  declareSeparable<ConformalShear, LogTraceRadius>(mod, "ConformalShearLogTraceRadius");
100 
101  declareSeparable<ReducedShear, DeterminantRadius>(mod, "ReducedShearDeterminantRadius");
102  declareSeparable<ReducedShear, TraceRadius>(mod, "ReducedShearTraceRadius");
103  declareSeparable<ReducedShear, LogDeterminantRadius>(mod, "ReducedShearLogDeterminantRadius");
104  declareSeparable<ReducedShear, LogTraceRadius>(mod, "ReducedShearLogTraceRadius");
105 
106  return mod.ptr();
107 }
A 2D linear coordinate transformation.
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
void declareSeparable(py::module &mod, const std::string &suffix)
Definition: separable.cc:41
double const _a
Definition: RandomImage.cc:77
An ellipse core with a complex ellipticity and radius parameterization.
Definition: radii.h:44
A base class for parametrizations of the &quot;core&quot; of an ellipse - the ellipticity and size...
Definition: BaseCore.h:55