23 #include <pybind11/pybind11.h>
25 #include <pybind11/stl.h>
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
29 #include "ndarray/converter.h"
33 namespace py = pybind11;
35 using namespace lsst::afw::math;
39 py::class_<KdTree<T>> clsKdTree(mod, (
"KdTree" + suffix).c_str());
40 clsKdTree.def(py::init<>());
44 clsKdTree.def(
"getData", (ndarray::Array<T, 1, 1> (
KdTree<T>::*)(
int)
const) & KdTree<T>::getData);
54 py::class_<Covariogram<T>, std::shared_ptr<Covariogram<T>>> clsCovariogram(
55 mod, (
"Covariogram" + suffix).c_str());
56 clsCovariogram.def(py::init<>());
60 py::class_<SquaredExpCovariogram<T>, std::shared_ptr<SquaredExpCovariogram<T>>,
Covariogram<T>>
61 clsSquaredExpCovariogram(mod, (
"SquaredExpCovariogram" + suffix).c_str());
62 clsSquaredExpCovariogram.def(py::init<>());
67 py::class_<NeuralNetCovariogram<T>, std::shared_ptr<NeuralNetCovariogram<T>>,
Covariogram<T>>
68 clsNeuralNetCovariogram(mod, (
"NeuralNetCovariogram" + suffix).c_str());
69 clsNeuralNetCovariogram.def(py::init<>());
76 py::class_<GaussianProcess<T>> clsGaussianProcess(mod, (
"GaussianProcess" + suffix).c_str());
78 clsGaussianProcess.def(py::init<ndarray::Array<T, 2, 2>
const &, ndarray::Array<T, 1, 1>
const &,
80 clsGaussianProcess.def(py::init<ndarray::Array<T, 2, 2>
const &, ndarray::Array<T, 1, 1>
const &,
81 ndarray::Array<T, 1, 1>
const &, ndarray::Array<T, 1, 1>
const &,
83 clsGaussianProcess.def(py::init<ndarray::Array<T, 2, 2>
const &, ndarray::Array<T, 2, 2>
const &,
85 clsGaussianProcess.def(py::init<ndarray::Array<T, 2, 2>
const &, ndarray::Array<T, 1, 1>
const &,
86 ndarray::Array<T, 1, 1>
const &, ndarray::Array<T, 2, 2>
const &,
89 clsGaussianProcess.def(
91 (T (
GaussianProcess<T>::*)(ndarray::Array<T, 1, 1>, ndarray::Array<T, 1, 1>
const &,
int)
const) &
93 clsGaussianProcess.def(
"interpolate",
95 ndarray::Array<T, 1, 1>
const &,
int)
const) &
96 GaussianProcess<T>::interpolate);
97 clsGaussianProcess.def(
"selfInterpolate",
100 clsGaussianProcess.def(
102 (
void (
GaussianProcess<T>::*)(ndarray::Array<T, 1, 1>, ndarray::Array<T, 1, 1>,
int,
int)
const) &
103 GaussianProcess<T>::selfInterpolate);
106 clsGaussianProcess.def(
"addPoint", (
void (
GaussianProcess<T>::*)(ndarray::Array<T, 1, 1>
const &, T)) &
108 clsGaussianProcess.def(
"addPoint", (
void (
GaussianProcess<T>::*)(ndarray::Array<T, 1, 1>
const &,
109 ndarray::Array<T, 1, 1>
const &)) &
110 GaussianProcess<T>::addPoint);
111 clsGaussianProcess.def(
"batchInterpolate",
113 ndarray::Array<T, 2, 2>
const &)
const) &
115 clsGaussianProcess.def(
117 (
void (
GaussianProcess<T>::*)(ndarray::Array<T, 1, 1>, ndarray::Array<T, 2, 2>
const &)
const) &
118 GaussianProcess<T>::batchInterpolate);
119 clsGaussianProcess.def(
"batchInterpolate",
121 ndarray::Array<T, 2, 2>
const &)
const) &
122 GaussianProcess<T>::batchInterpolate);
123 clsGaussianProcess.def(
125 (
void (
GaussianProcess<T>::*)(ndarray::Array<T, 2, 2>, ndarray::Array<T, 2, 2>
const &)
const) &
126 GaussianProcess<T>::batchInterpolate);
130 clsGaussianProcess.def(
"getData",
132 ndarray::Array<int, 1, 1>)
const) &
134 clsGaussianProcess.def(
"getData",
136 ndarray::Array<int, 1, 1>)
const) &
137 GaussianProcess<T>::getData);
141 py::module mod(
"_gaussianProcess",
"Python wrapper for afw _gaussianProcess library");
143 if (_import_array() < 0) {
144 PyErr_SetString(PyExc_ImportError,
"numpy.core.multiarray failed to import");
148 declareCovariograms<double>(mod,
"D");
149 declareGaussianProcess<double>(mod,
"D");
150 declareKdTree<double>(mod,
"D");
Stores values of a function sampled on an image and allows you to interpolate the function to unsampl...
The parent class of covariogram functions for use in Gaussian Process interpolation.
void declareKdTree(py::module &mod, const std::string &suffix)
The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches...
a Covariogram that recreates a neural network with one hidden layer and infinite units in that layer ...
void declareCovariograms(py::module &mod, const std::string &suffix)
void declareGaussianProcess(py::module &mod, const std::string &suffix)
PYBIND11_PLUGIN(_approximate)