23 #include <pybind11/pybind11.h>
24 #include <pybind11/operators.h>
25 #include <pybind11/stl.h>
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
29 #include "ndarray/converter.h"
31 #include "lsst/pex/config/python.h"
38 namespace py = pybind11;
40 using namespace lsst::afw::math;
42 using ClsField = py::class_<ChebyshevBoundedField, std::shared_ptr<ChebyshevBoundedField>,
BoundedField,
45 template <
typename PixelT>
53 py::module mod(
"_chebyshevBoundedField",
"Python wrapper for afw _chebyshevBoundedField library");
55 if (_import_array() < 0) {
56 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
61 lsst::afw::table::io::python::declarePersistableFacade<ChebyshevBoundedField>(mod,
62 "ChebyshevBoundedField");
63 py::class_<ChebyshevBoundedFieldControl> clsChebyshevBoundedFieldControl(mod,
64 "ChebyshevBoundedFieldControl");
65 ClsField clsChebyshevBoundedField(mod,
"ChebyshevBoundedField");
71 clsChebyshevBoundedFieldControl.def(py::init<>());
72 clsChebyshevBoundedField.def(
76 clsChebyshevBoundedField.def(
"__rmul__",
79 clsChebyshevBoundedField.def(
"__mul__",
82 clsChebyshevBoundedField.def(
"__eq__", &BoundedField::operator==, py::is_operator());
83 clsChebyshevBoundedField.def(
"__ne__", &BoundedField::operator!=, py::is_operator());
93 clsChebyshevBoundedField.def_static(
94 "fit", (std::shared_ptr<ChebyshevBoundedField>(*)(
96 ndarray::Array<double const, 1>
const &, ndarray::Array<double const, 1>
const &,
99 clsChebyshevBoundedField.def_static(
100 "fit", (std::shared_ptr<ChebyshevBoundedField>(*)(
102 ndarray::Array<double const, 1>
const &, ndarray::Array<double const, 1>
const &,
103 ndarray::Array<double const, 1>
const &, Control
const &)) &
104 ChebyshevBoundedField::fit);
109 declareTemplates<double>(clsChebyshevBoundedField);
110 declareTemplates<float>(clsChebyshevBoundedField);
A control object used when fitting ChebyshevBoundedField to data (see ChebyshevBoundedField::fit) ...
int computeSize() const
Return the number of nonzero coefficients in the Chebyshev function defined by this object...
An integer coordinate rectangle.
ndarray::Array< double const, 2, 2 > getCoefficients() const
Return the coefficient matrix.
A BoundedField based on 2-d Chebyshev polynomials of the first kind.
py::class_< ChebyshevBoundedField, std::shared_ptr< ChebyshevBoundedField >, BoundedField, lsst::afw::table::io::PersistableFacade< ChebyshevBoundedField >> ClsField
An abstract base class for 2-d functions defined on an integer bounding boxes.
static std::shared_ptr< ChebyshevBoundedField > fit(afw::geom::Box2I const &bbox, ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y, ndarray::Array< double const, 1 > const &z, Control const &ctrl)
Fit a Chebyshev approximation to non-gridded data with equal weights.
A class to represent a 2-dimensional array of pixels.
std::shared_ptr< ChebyshevBoundedField > truncate(Control const &ctrl) const
Return a new ChebyshevBoudedField with maximum orders set by the given control object.
PYBIND11_PLUGIN(_approximate)
void declareTemplates(ClsField &cls)