23 #include <pybind11/pybind11.h>
25 #include <pybind11/stl.h>
32 using namespace py::literals;
37 py::class_<Kernel, std::shared_ptr<Kernel>> clsKernel(mod,
"Kernel");
39 lsst::afw::table::io::python::addPersistableMethods<Kernel>(clsKernel);
42 clsKernel.def(
"resized", &Kernel::resized,
"width"_a,
"height"_a);
43 clsKernel.def(
"computeImage", &Kernel::computeImage,
"image"_a,
"doNormalize"_a,
"x"_a = 0.0,
45 clsKernel.def(
"getDimensions", &Kernel::getDimensions);
46 clsKernel.def(
"setDimensions", &Kernel::setDimensions);
47 clsKernel.def(
"setWidth", &Kernel::setWidth);
48 clsKernel.def(
"setHeight", &Kernel::setHeight);
49 clsKernel.def(
"getWidth", &Kernel::getWidth);
50 clsKernel.def(
"getHeight", &Kernel::getHeight);
51 clsKernel.def(
"getCtr", &Kernel::getCtr);
52 clsKernel.def(
"getBBox", &Kernel::getBBox);
53 clsKernel.def(
"getNKernelParameters", &Kernel::getNKernelParameters);
54 clsKernel.def(
"getNSpatialParameters", &Kernel::getNSpatialParameters);
55 clsKernel.def(
"getSpatialFunction", &Kernel::getSpatialFunction);
56 clsKernel.def(
"getSpatialFunctionList", &Kernel::getSpatialFunctionList);
57 clsKernel.def(
"getKernelParameter", &Kernel::getKernelParameter);
58 clsKernel.def(
"getKernelParameters", &Kernel::getKernelParameters);
59 clsKernel.def(
"growBBox", &Kernel::growBBox);
60 clsKernel.def(
"shrinkBBox", &Kernel::shrinkBBox);
61 clsKernel.def(
"setCtr", &Kernel::setCtr);
62 clsKernel.def(
"getSpatialParameters", &Kernel::getSpatialParameters);
63 clsKernel.def(
"isSpatiallyVarying", &Kernel::isSpatiallyVarying);
64 clsKernel.def(
"setKernelParameters",
66 clsKernel.def(
"setKernelParameters",
69 clsKernel.def(
"computeKernelParametersFromSpatialModel",
70 &Kernel::computeKernelParametersFromSpatialModel);
71 clsKernel.def(
"toString", &Kernel::toString,
"prefix"_a =
"");
72 clsKernel.def(
"computeCache", &Kernel::computeCache);
73 clsKernel.def(
"getCacheSize", &Kernel::getCacheSize);
75 py::class_<FixedKernel, std::shared_ptr<FixedKernel>,
Kernel> clsFixedKernel(mod,
"FixedKernel");
77 clsFixedKernel.def(py::init<>());
79 clsFixedKernel.def(py::init<lsst::afw::math::Kernel const &, lsst::geom::Point2D const &>(),
"kernel"_a,
82 clsFixedKernel.def(
"resized", &FixedKernel::resized,
"width"_a,
"height"_a);
83 clsFixedKernel.def(
"toString", &FixedKernel::toString,
"prefix"_a =
"");
84 clsFixedKernel.def(
"getSum", &FixedKernel::getSum);
85 clsFixedKernel.def(
"isPersistable", &FixedKernel::isPersistable);
87 py::class_<AnalyticKernel, std::shared_ptr<AnalyticKernel>,
Kernel> clsAnalyticKernel(mod,
89 clsAnalyticKernel.def(py::init<>());
91 clsAnalyticKernel.def(py::init<int, int, AnalyticKernel::KernelFunction const &>(),
"width"_a,
"height"_a,
93 clsAnalyticKernel.def(
94 py::init<int, int, AnalyticKernel::KernelFunction const &, Kernel::SpatialFunction const &>(),
95 "width"_a,
"height"_a,
"kernelFunction"_a,
"spatialFunction"_a);
98 "width"_a,
"height"_a,
"kernelFunction"_a,
"spatialFunctionList"_a);
100 clsAnalyticKernel.def(
"resized", &AnalyticKernel::resized,
"width"_a,
"height"_a);
101 clsAnalyticKernel.def(
"computeImage", &AnalyticKernel::computeImage,
"image"_a,
"doNormalize"_a,
102 "x"_a = 0.0,
"y"_a = 0.0);
103 clsAnalyticKernel.def(
"getKernelParameters", &AnalyticKernel::getKernelParameters);
104 clsAnalyticKernel.def(
"getKernelFunction", &AnalyticKernel::getKernelFunction);
105 clsAnalyticKernel.def(
"toString", &AnalyticKernel::toString,
"prefix"_a =
"");
106 clsAnalyticKernel.def(
"isPersistable", &AnalyticKernel::isPersistable);
108 py::class_<DeltaFunctionKernel, std::shared_ptr<DeltaFunctionKernel>,
Kernel> clsDeltaFunctionKernel(
109 mod,
"DeltaFunctionKernel");
111 clsDeltaFunctionKernel.def(py::init<int, int, lsst::geom::Point2I const &>(),
"width"_a,
"height"_a,
114 clsDeltaFunctionKernel.def(
"resized", &DeltaFunctionKernel::resized,
"width"_a,
"height"_a);
115 clsDeltaFunctionKernel.def(
"getPixel", &DeltaFunctionKernel::getPixel);
116 clsDeltaFunctionKernel.def(
"toString", &DeltaFunctionKernel::toString,
"prefix"_a =
"");
117 clsDeltaFunctionKernel.def(
"isPersistable", &DeltaFunctionKernel::isPersistable);
119 py::class_<LinearCombinationKernel, std::shared_ptr<LinearCombinationKernel>,
Kernel>
120 clsLinearCombinationKernel(mod,
"LinearCombinationKernel");
122 clsLinearCombinationKernel.def(py::init<>());
124 "kernelList"_a,
"kernelParameters"_a);
125 clsLinearCombinationKernel.def(py::init<KernelList const &, Kernel::SpatialFunction const &>(),
126 "kernelList"_a,
"spatialFunction"_a);
127 clsLinearCombinationKernel.def(
129 "spatialFunctionList"_a);
131 clsLinearCombinationKernel.def(
"resized", &LinearCombinationKernel::resized,
"width"_a,
"height"_a);
132 clsLinearCombinationKernel.def(
"getKernelParameters", &LinearCombinationKernel::getKernelParameters);
133 clsLinearCombinationKernel.def(
"getKernelList", &LinearCombinationKernel::getKernelList);
134 clsLinearCombinationKernel.def(
"getKernelSumList", &LinearCombinationKernel::getKernelSumList);
135 clsLinearCombinationKernel.def(
"getNBasisKernels", &LinearCombinationKernel::getNBasisKernels);
136 clsLinearCombinationKernel.def(
"checkKernelList", &LinearCombinationKernel::checkKernelList);
137 clsLinearCombinationKernel.def(
"isDeltaFunctionBasis", &LinearCombinationKernel::isDeltaFunctionBasis);
138 clsLinearCombinationKernel.def(
"refactor", &LinearCombinationKernel::refactor);
139 clsLinearCombinationKernel.def(
"toString", &LinearCombinationKernel::toString,
"prefix"_a =
"");
140 clsLinearCombinationKernel.def(
"isPersistable", &LinearCombinationKernel::isPersistable);
142 py::class_<SeparableKernel, std::shared_ptr<SeparableKernel>,
Kernel> clsSeparableKernel(
143 mod,
"SeparableKernel");
145 clsSeparableKernel.def(py::init<>());
149 "width"_a,
"height"_a,
"kernelColFunction"_a,
"kernelRowFunction"_a);
150 clsSeparableKernel.def(
153 "width"_a,
"height"_a,
"kernelColFunction"_a,
"kernelRowFunction"_a,
"spatialFunction"_a);
157 "width"_a,
"height"_a,
"kernelColFunction"_a,
"kernelRowFunction"_a,
158 "spatialFunctionList"_a);
160 clsSeparableKernel.def(
"resized", &SeparableKernel::resized,
"width"_a,
"height"_a);
161 clsSeparableKernel.def(
"computeVectors", &SeparableKernel::computeVectors);
162 clsSeparableKernel.def(
"getKernelParameter", &SeparableKernel::getKernelParameter);
163 clsSeparableKernel.def(
"getKernelParameters", &SeparableKernel::getKernelParameters);
164 clsSeparableKernel.def(
"getKernelColFunction", &SeparableKernel::getKernelColFunction);
165 clsSeparableKernel.def(
"getKernelRowFunction", &SeparableKernel::getKernelRowFunction);
166 clsSeparableKernel.def(
"toString", &SeparableKernel::toString,
"prefix"_a =
"");
167 clsSeparableKernel.def(
"computeCache", &SeparableKernel::computeCache);
168 clsSeparableKernel.def(
"getCacheSize", &SeparableKernel::getCacheSize);
A class to represent a 2-dimensional array of pixels.
A Function taking one argument.
A Function taking two arguments.
Kernels are used for convolution with MaskedImages and (eventually) Images.
void setSpatialParameters(afw::math::Kernel *kernel, std::vector< double > const &coeffs)
Fit a Kernel's spatial variability from a set of stars.
PYBIND11_MODULE(kernel, mod)