22 #include "pybind11/pybind11.h"
24 #include "numpy/arrayobject.h"
25 #include "ndarray/pybind11.h"
29 namespace py = pybind11;
30 using namespace pybind11::literals;
36 py::module::import(
"lsst.afw.geom");
37 py::module::import(
"lsst.afw.image");
39 py::module mod(
"shapeletFunction");
41 if (_import_array() < 0) {
42 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
46 py::class_<ShapeletFunction, std::shared_ptr<ShapeletFunction>> clsShapeletFunction(mod,
49 clsShapeletFunction.def_readonly_static(
"FLUX_FACTOR", &ShapeletFunction::FLUX_FACTOR);
51 clsShapeletFunction.def(py::init<int, BasisTypeEnum>(),
"order"_a,
"basisType"_a);
52 clsShapeletFunction.def(py::init<
int,
BasisTypeEnum, ndarray::Array<double, 1, 1>
const &>(),
"order"_a,
53 "basisType"_a,
"coefficients"_a);
54 clsShapeletFunction.def(py::init<int, BasisTypeEnum, double, afw::geom::Point2D const &>(),
"order"_a,
55 "basisType"_a,
"radius"_a,
"center"_a = afw::geom::Point2D());
56 clsShapeletFunction.def(py::init<
int,
BasisTypeEnum,
double, afw::geom::Point2D
const &,
57 ndarray::Array<double, 1, 1>
const &>(),
58 "order"_a,
"basisType"_a,
"radius"_a,
"center"_a,
"coefficients"_a);
59 clsShapeletFunction.def(py::init<int, BasisTypeEnum, afw::geom::ellipses::Ellipse const &>(),
"order"_a,
60 "basisType"_a,
"ellipse"_a);
61 clsShapeletFunction.def(py::init<
int,
BasisTypeEnum, afw::geom::ellipses::Ellipse
const &,
62 ndarray::Array<double const, 1, 1>
const &>(),
63 "order"_a,
"basisType"_a,
"ellipse"_a,
"coefficients"_a);
64 clsShapeletFunction.def(py::init<ShapeletFunction>());
66 clsShapeletFunction.def(
"getOrder", &ShapeletFunction::getOrder);
67 clsShapeletFunction.def(
"getEllipse", (afw::geom::ellipses::Ellipse & (
ShapeletFunction::*)()) &
68 ShapeletFunction::getEllipse,
69 py::return_value_policy::reference_internal);
70 clsShapeletFunction.def(
"setEllipse", &ShapeletFunction::setEllipse);
71 clsShapeletFunction.def(
"getBasisType", &ShapeletFunction::getBasisType);
72 clsShapeletFunction.def(
"changeBasisType", &ShapeletFunction::changeBasisType);
73 clsShapeletFunction.def(
"normalize", &ShapeletFunction::normalize,
"value"_a = 1.0);
74 clsShapeletFunction.def(
"getCoefficients", (ndarray::Array<double, 1, 1>
const (
ShapeletFunction::*)()) &
75 ShapeletFunction::getCoefficients);
76 clsShapeletFunction.def(
"convolve", &ShapeletFunction::convolve);
77 clsShapeletFunction.def(
"evaluate", &ShapeletFunction::evaluate);
78 clsShapeletFunction.def(
"shiftInPlace", &ShapeletFunction::shiftInPlace);
79 clsShapeletFunction.def(
"transformInPlace", &ShapeletFunction::transformInPlace);
81 py::class_<ShapeletFunctionEvaluator, std::shared_ptr<ShapeletFunctionEvaluator>>
82 clsShapeletFunctionEvaluator(mod,
"ShapeletFunctionEvaluator");
84 clsShapeletFunctionEvaluator.def(py::init<ShapeletFunction const &>(),
"function"_a);
86 clsShapeletFunctionEvaluator.def(
"__call__",
88 ShapeletFunctionEvaluator::operator());
89 clsShapeletFunctionEvaluator.def(
91 ShapeletFunctionEvaluator::operator());
92 clsShapeletFunctionEvaluator.def(
94 ShapeletFunctionEvaluator::operator());
96 ndarray::Array<double const, 1>
const &,
97 ndarray::Array<double const, 1>
const &)
const) &
98 ShapeletFunctionEvaluator::operator());
100 clsShapeletFunctionEvaluator.def(
102 afw::geom::Point2I
const &)
const) &
103 ShapeletFunctionEvaluator::addToImage,
104 "array"_a,
"xy0"_a = afw::geom::Point2D());
105 clsShapeletFunctionEvaluator.def(
107 ShapeletFunctionEvaluator::addToImage,
109 clsShapeletFunctionEvaluator.def(
"integrate", &ShapeletFunctionEvaluator::integrate);
110 clsShapeletFunctionEvaluator.def(
"computeMoments", &ShapeletFunctionEvaluator::computeMoments);
111 clsShapeletFunctionEvaluator.def(
"update", &ShapeletFunctionEvaluator::update);
Evaluates a ShapeletFunction.
PYBIND11_PLUGIN(basisEvaluator)
BasisTypeEnum
An enum that sets whether to use real-valued polar shapelets or Cartesian shapelets.
A 2-d function defined by an expansion onto a Gauss-Laguerre or Gauss-Hermite basis.