26#include <pybind11/pybind11.h>
39using namespace pybind11::literals;
41using lsst::utils::python::PySharedPtr;
48void wrapPsf(utils::python::WrapperCollection& wrappers) {
49 wrappers.addInheritanceDependency(
"lsst.afw.typehandling");
50 wrappers.addSignatureDependency(
"lsst.afw.geom.ellipses");
51 wrappers.addSignatureDependency(
"lsst.afw.image");
52 wrappers.addSignatureDependency(
"lsst.afw.fits");
54 auto clsPsf = wrappers.wrapType(
56 wrappers.module,
"Psf"
58 [](
auto& mod,
auto& cls) {
59 table::io::python::addPersistableMethods<Psf>(cls);
60 cls.def(py::init<bool, size_t>(),
"isFixed"_a=false,
"capacity"_a=100);
61 cls.def(
"clone", &Psf::clone);
62 cls.def(
"resized", &Psf::resized,
"width"_a,
"height"_a);
66 cls.def(
"computeImage",
67 py::overload_cast<lsst::geom::Point2D, image::Color, Psf::ImageOwnerEnum>(&Psf::computeImage, py::const_),
69 "color"_a = image::Color(),
70 "owner"_a = Psf::ImageOwnerEnum::COPY
72 cls.def(
"computeKernelImage",
73 py::overload_cast<lsst::geom::Point2D, image::Color, Psf::ImageOwnerEnum>(&Psf::computeKernelImage, py::const_),
75 "color"_a = image::Color(),
76 "owner"_a = Psf::ImageOwnerEnum::COPY
78 cls.def(
"computePeak",
79 py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computePeak, py::const_),
81 "color"_a = image::Color()
83 cls.def(
"computeApertureFlux",
84 py::overload_cast<double, lsst::geom::Point2D, image::Color>(&Psf::computeApertureFlux, py::const_),
87 "color"_a = image::Color()
89 cls.def(
"computeShape",
90 py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeShape, py::const_),
92 "color"_a = image::Color()
94 cls.def(
"computeBBox",
95 py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeBBox, py::const_),
97 "color"_a = image::Color()
99 cls.def(
"computeImageBBox",
100 py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeImageBBox, py::const_),
102 "color"_a = image::Color()
104 cls.def(
"computeKernelBBox",
105 py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeKernelBBox, py::const_),
107 "color"_a = image::Color()
109 cls.def(
"getLocalKernel",
110 py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::getLocalKernel, py::const_),
112 "color"_a = image::Color()
116 cls.def(
"computeImage",
118 py::gil_scoped_acquire gil;
119 auto warnings = py::module::import(
"warnings");
120 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
121 warnings.attr(
"warn")(
122 "Default position argument overload is deprecated and will be "
123 "removed in version 24.0. Please explicitly specify a position.",
124 "category"_a=FutureWarning
126 return psf.computeImage();
129 cls.def(
"computeKernelImage",
131 py::gil_scoped_acquire gil;
132 auto warnings = py::module::import(
"warnings");
133 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
134 warnings.attr(
"warn")(
135 "Default position argument overload is deprecated and will be "
136 "removed in version 24.0. Please explicitly specify a position.",
137 "category"_a=FutureWarning
139 return psf.computeKernelImage();
142 cls.def(
"computePeak",
144 py::gil_scoped_acquire gil;
145 auto warnings = py::module::import(
"warnings");
146 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
147 warnings.attr(
"warn")(
148 "Default position argument overload is deprecated and will be "
149 "removed in version 24.0. Please explicitly specify a position.",
150 "category"_a=FutureWarning
152 return psf.computePeak();
155 cls.def(
"computeApertureFlux",
157 py::gil_scoped_acquire gil;
158 auto warnings = py::module::import(
"warnings");
159 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
160 warnings.attr(
"warn")(
161 "Default position argument overload is deprecated and will be "
162 "removed in version 24.0. Please explicitly specify a position.",
163 "category"_a=FutureWarning
169 cls.def(
"computeShape",
171 py::gil_scoped_acquire gil;
172 auto warnings = py::module::import(
"warnings");
173 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
174 warnings.attr(
"warn")(
175 "Default position argument overload is deprecated and will be "
176 "removed in version 24.0. Please explicitly specify a position.",
177 "category"_a=FutureWarning
179 return psf.computeShape();
182 cls.def(
"computeBBox",
184 py::gil_scoped_acquire gil;
185 auto warnings = py::module::import(
"warnings");
186 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
187 warnings.attr(
"warn")(
188 "Default position argument overload is deprecated and will be "
189 "removed in version 24.0. Please explicitly specify a position.",
190 "category"_a=FutureWarning
192 return psf.computeBBox();
195 cls.def(
"computeImageBBox",
197 py::gil_scoped_acquire gil;
198 auto warnings = py::module::import(
"warnings");
199 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
200 warnings.attr(
"warn")(
201 "Default position argument overload is deprecated and will be "
202 "removed in version 24.0. Please explicitly specify a position.",
203 "category"_a=FutureWarning
205 return psf.computeImageBBox();
208 cls.def(
"computeKernelBBox",
210 py::gil_scoped_acquire gil;
211 auto warnings = py::module::import(
"warnings");
212 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
213 warnings.attr(
"warn")(
214 "Default position argument overload is deprecated and will be "
215 "removed in version 24.0. Please explicitly specify a position.",
216 "category"_a=FutureWarning
218 return psf.computeKernelBBox();
221 cls.def(
"getLocalKernel",
223 py::gil_scoped_acquire gil;
224 auto warnings = py::module::import(
"warnings");
225 auto FutureWarning = py::handle(PyEval_GetBuiltins())[
"FutureWarning"];
226 warnings.attr(
"warn")(
227 "Default position argument overload is deprecated and will be "
228 "removed in version 24.0. Please explicitly specify a position.",
229 "category"_a=FutureWarning
231 return psf.getLocalKernel();
239 "warpAlgorithm"_a =
"lanczos5",
"warpBuffer"_a = 5);
245 wrappers.wrapType(py::enum_<Psf::ImageOwnerEnum>(clsPsf,
"ImageOwnerEnum"), [](
auto& mod,
auto& enm) {
246 enm.value(
"COPY", Psf::ImageOwnerEnum::COPY);
247 enm.value(
"INTERNAL", Psf::ImageOwnerEnum::INTERNAL);
A polymorphic base class for representing an image's Point Spread Function.
static std::shared_ptr< Image > recenterKernelImage(std::shared_ptr< Image > im, lsst::geom::Point2D const &position, std::string const &warpAlgorithm="lanczos5", unsigned int warpBuffer=5)
Helper function for Psf::doComputeImage(): converts a kernel image (centered at (0,...
std::size_t getCacheCapacity() const
Return the capacity of the caches.
image::Color getAverageColor() const
Return the average Color of the stars used to construct the Psf.
void setCacheCapacity(std::size_t capacity)
Set the capacity of the caches.
virtual lsst::geom::Point2D getAveragePosition() const
Return the average position of the stars used to construct the Psf.
"Trampoline" for Psf to let it be used as a base class in Python.
Interface supporting iteration over heterogenous containers.
void wrapPsf(WrapperCollection &)
A base class for image defects.