lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
baseCore.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/stl.h>
25 
26 #include "numpy/arrayobject.h"
27 #include "ndarray/pybind11.h"
28 #include "ndarray/converter.h"
29 
33 
34 namespace py = pybind11;
35 
36 using namespace lsst::afw::geom::ellipses;
37 
38 PYBIND11_PLUGIN(_baseCore) {
39  py::module mod("_baseCore", "Python wrapper for afw _baseCore library");
40 
41  if (_import_array() < 0) {
42  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
43  return nullptr;
44  }
45 
46  /* Module level */
47  py::class_<BaseCore, std::shared_ptr<BaseCore>> clsBaseCore(mod, "BaseCore");
48 
49  /* Member types and enums */
50  py::class_<BaseCore::Convolution> clsBaseCoreConvolution(clsBaseCore, "Convolution");
51  py::class_<BaseCore::Transformer> clsBaseCoreTransformer(clsBaseCore, "Transformer");
52 
53  // clsBaseCoreTransformer.def(py::init<BaseCore &, LinearTransform const &>());
54  //
55  // clsBaseCoreTransformer.def("inPlace", &BaseCore::Transformer::inPlace);
56  // clsBaseCoreTransformer.def("apply", &BaseCore::Transformer::apply);
57  // clsBaseCoreTransformer.def("d", &BaseCore::Transformer::d);
58  // clsBaseCoreTransformer.def("dTransform", &BaseCore::Transformer::dTransform);
59  //
60  // clsBaseCoreTransformer.def_readwrite("input", &BaseCore::Transformer::input);
61  // clsBaseCoreTransformer.def_readonly("transform", &BaseCore::Transformer::transform);
62 
63  /* Constructors */
64 
65  /* Operators */
66  clsBaseCore.def("__eq__", &BaseCore::operator==, py::is_operator());
67  clsBaseCore.def("__nq__", &BaseCore::operator!=, py::is_operator());
68 
69  /* Members */
70  clsBaseCore.def("getName", &BaseCore::getName);
71  clsBaseCore.def("clone", &BaseCore::clone);
72  clsBaseCore.def("normalize", &BaseCore::normalize);
73  clsBaseCore.def("grow", &BaseCore::grow);
74  clsBaseCore.def("scale", &BaseCore::scale);
75  clsBaseCore.def("getArea", &BaseCore::getArea);
76  clsBaseCore.def("getDeterminantRadius", &BaseCore::getDeterminantRadius);
77  clsBaseCore.def("getTraceRadius", &BaseCore::getTraceRadius);
78  // clsBaseCore.def("transform", (typename BaseCore::Transformer const
79  // (BaseCore::*)(lsst::afw::geom::LinearTransform const &) const) &BaseCore::transform);
80  // clsBaseCore.def("getGridTransform", &BaseCore::getGridTransform);
81  clsBaseCore.def("convolve", (BaseCore::Convolution (BaseCore::*)(BaseCore const &)) & BaseCore::convolve);
82  clsBaseCore.def("computeDimensions", &BaseCore::computeDimensions);
83  clsBaseCore.def("getParameterVector", &BaseCore::getParameterVector);
84  clsBaseCore.def("setParameterVector", &BaseCore::setParameterVector);
85  // clsBaseCore.def("transformInPlace", [](BaseCore & self, lsst::afw::geom::LinearTransform const & t)
86  // {
87  // self.transform(t).inPlace();
88  // });
89 
90  return mod.ptr();
91 }
Extent2D computeDimensions() const
Return the size of the bounding box for the ellipse core.
ParameterVector const getParameterVector() const
Return the core parameters as a vector.
double getArea() const
Return the area of the ellipse core.
std::shared_ptr< BaseCore > clone() const
Deep-copy the Core.
Definition: BaseCore.h:82
void setParameterVector(ParameterVector const &vector)
Set the core parameters from a vector.
void grow(double buffer)
Increase the major and minor radii of the ellipse core by the given buffer.
Convolution convolve(BaseCore const &other)
Definition: Convolution.h:93
double getTraceRadius() const
Return the radius defined as the square root of one half the trace of the quadrupole matrix...
void scale(double factor)
Scale the size of the ellipse core by the given factor.
virtual void normalize()=0
Put the parameters into a &quot;standard form&quot;, and throw InvalidParameterError if they cannot be normaliz...
double getDeterminantRadius() const
Return the radius defined as the 4th root of the determinant of the quadrupole matrix.
A base class for parametrizations of the &quot;core&quot; of an ellipse - the ellipticity and size...
Definition: BaseCore.h:55
virtual std::string getName() const =0
Return a string that identifies this parametrization.
PYBIND11_PLUGIN(spanSet)
Definition: spanSet.cc:204
A temporary-only expression object for ellipse core convolution.
Definition: Convolution.h:46