23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
28 #include "numpy/arrayobject.h"
29 #include "ndarray/pybind11.h"
30 #include "ndarray/converter.h"
37 namespace py = pybind11;
39 using namespace lsst::afw::math;
40 using namespace py::literals;
47 using PyClass = py::class_<BoundedField, std::shared_ptr<BoundedField>,
48 afw::table::io::PersistableFacade<BoundedField>,
49 afw::table::io::Persistable>;
51 template <
typename PixelT>
53 cls.def(
"fillImage", &BoundedField::fillImage<PixelT>,
54 "image"_a,
"overlapOnly"_a =
false,
"xStep"_a = 1,
"yStep"_a = 1);
55 cls.def(
"addToImage", &BoundedField::addToImage<PixelT>,
"image"_a,
"scaleBy"_a = 1.0,
56 "overlapOnly"_a =
false,
"xStep"_a = 1,
"yStep"_a = 1);
57 cls.def(
"multiplyImage", &BoundedField::multiplyImage<PixelT>,
58 "image"_a,
"overlapOnly"_a =
false,
"xStep"_a = 1,
"yStep"_a = 1);
59 cls.def(
"divideImage", &BoundedField::divideImage<PixelT>,
60 "image"_a,
"overlapOnly"_a =
false,
"xStep"_a = 1,
"yStep"_a = 1);
64 py::module mod(
"_boundedField",
"Python wrapper for afw _boundedField library");
66 if (_import_array() < 0) {
67 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
71 afw::table::io::python::declarePersistableFacade<BoundedField>(mod,
"BoundedField");
72 PyClass
cls(mod,
"BoundedField");
75 cls.def(
"__mul__", &BoundedField::operator*, py::is_operator());
76 cls.def(
"__truediv__", &BoundedField::operator/, py::is_operator());
77 cls.def(
"__eq__", &BoundedField::operator==, py::is_operator());
78 cls.def(
"__ne__", &BoundedField::operator!=, py::is_operator());
82 (ndarray::Array<double, 1, 1> (
BoundedField::*)(ndarray::Array<double const, 1>
const &,
83 ndarray::Array<double const, 1>
const &)
const) &
84 BoundedField::evaluate);
92 declareTemplates<double>(
cls);
93 declareTemplates<float>(
cls);
96 std::ostringstream os;
101 std::ostringstream os;
102 os <<
"BoundedField(" <<
self <<
")";
virtual double evaluate(geom::Point2D const &position) const =0
Evaluate the field at the given point.
virtual double integrate() const
Compute the integral of this function over its bounding-box.
virtual double mean() const
Compute the mean of this function over its bounding-box.
geom::Box2I getBBox() const
Return the bounding box that defines the region where the field is valid.
An abstract base class for 2-d functions defined on an integer bounding boxes.
PYBIND11_PLUGIN(_approximate)
void declareTemplates(ClsField &cls)