Skip to content

Commit

Permalink
Merge pull request #701 from lsst/tickets/DM-31707
Browse files Browse the repository at this point in the history
DM-31707: Remove deprecated interfaces
  • Loading branch information
mwittgen authored Jul 12, 2023
2 parents 8929684 + fdfdf25 commit 4d318ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 219 deletions.
55 changes: 0 additions & 55 deletions include/lsst/afw/detection/Psf.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
image::Color color = image::Color(),
ImageOwnerEnum owner = COPY) const;

// Using the default position automatically implies use of the default color, owner.
[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
std::shared_ptr<Image> computeImage() const;

/**
* Return an Image of the PSF, in a form suitable for convolution.
Expand All @@ -181,12 +175,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
std::shared_ptr<Image> computeKernelImage(lsst::geom::Point2D position,
image::Color color = image::Color(),
ImageOwnerEnum owner = COPY) const;
// Using the default position automatically implies use of the default color, owner.
[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
std::shared_ptr<Image> computeKernelImage() const;

/**
* Return the peak value of the PSF image.
Expand All @@ -202,12 +190,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
double computePeak(lsst::geom::Point2D position,
image::Color color = image::Color()) const;

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
double computePeak() const;

/**
* Compute the "flux" of the Psf model within a circular aperture of the given radius.
*
Expand All @@ -222,12 +204,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
double computeApertureFlux(double radius, lsst::geom::Point2D position,
image::Color color = image::Color()) const;

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
double computeApertureFlux(double radius) const;

/**
* Compute the ellipse corresponding to the second moments of the Psf.
*
Expand All @@ -241,12 +217,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
geom::ellipses::Quadrupole computeShape(lsst::geom::Point2D position,
image::Color color = image::Color()) const;

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
geom::ellipses::Quadrupole computeShape() const;

/**
* Return a FixedKernel corresponding to the Psf image at the given point.
*
Expand All @@ -260,11 +230,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
std::shared_ptr<math::Kernel const> getLocalKernel(lsst::geom::Point2D position,
image::Color color = image::Color()) const;

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
std::shared_ptr<math::Kernel const> getLocalKernel() const;

/**
* Return the average Color of the stars used to construct the Psf
Expand All @@ -290,12 +255,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
lsst::geom::Box2I computeBBox(lsst::geom::Point2D position,
image::Color color = image::Color()) const;

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
lsst::geom::Box2I computeBBox() const;

/**
* Return the bounding box of the image returned by computeImage()
*
Expand All @@ -306,12 +265,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
lsst::geom::Box2I computeImageBBox(lsst::geom::Point2D position,
image::Color color = image::Color()) const;

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
lsst::geom::Box2I computeImageBBox() const;

/**
* Return the bounding box of the image returned by computeImage()
*
Expand All @@ -325,14 +278,6 @@ class Psf : public afw::table::io::PersistableFacade<Psf>,
return computeBBox(position, color);
}

[[deprecated(
"Default position argument overload is deprecated and will be removed "
"in version 24.0. Please use overload with explicit position."
)]]
lsst::geom::Box2I computeKernelBBox() const {
return computeBBox();
}

/**
* Helper function for Psf::doComputeImage(): converts a kernel image (centered at (0,0) when xy0
* is taken into account) to an image centered at position when xy0 is taken into account.
Expand Down
141 changes: 9 additions & 132 deletions python/lsst/afw/detection/_psf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,178 +61,55 @@ void wrapPsf(utils::python::WrapperCollection& wrappers) {
cls.def("clone", &Psf::clone);
cls.def("resized", &Psf::resized, "width"_a, "height"_a);

// Position-required overloads. Can (likely) remove overload_cast<> once deprecation period for
// default position argument ends.
cls.def("computeImage",
py::overload_cast<lsst::geom::Point2D, image::Color, Psf::ImageOwnerEnum>(&Psf::computeImage, py::const_),
&Psf::computeImage,
"position"_a,
"color"_a = image::Color(),
"owner"_a = Psf::ImageOwnerEnum::COPY
);
cls.def("computeKernelImage",
py::overload_cast<lsst::geom::Point2D, image::Color, Psf::ImageOwnerEnum>(&Psf::computeKernelImage, py::const_),
&Psf::computeKernelImage,
"position"_a,
"color"_a = image::Color(),
"owner"_a = Psf::ImageOwnerEnum::COPY
);
cls.def("computePeak",
py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computePeak, py::const_),
&Psf::computePeak,
"position"_a,
"color"_a = image::Color()
);
cls.def("computeApertureFlux",
py::overload_cast<double, lsst::geom::Point2D, image::Color>(&Psf::computeApertureFlux, py::const_),
&Psf::computeApertureFlux,
"radius"_a,
"position"_a,
"color"_a = image::Color()
);
cls.def("computeShape",
py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeShape, py::const_),
&Psf::computeShape,
"position"_a,
"color"_a = image::Color()
);
cls.def("computeBBox",
py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeBBox, py::const_),
&Psf::computeBBox,
"position"_a,
"color"_a = image::Color()
);
cls.def("computeImageBBox",
py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeImageBBox, py::const_),
&Psf::computeImageBBox,
"position"_a,
"color"_a = image::Color()
);
cls.def("computeKernelBBox",
py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeKernelBBox, py::const_),
&Psf::computeKernelBBox,
"position"_a,
"color"_a = image::Color()
);
cls.def("getLocalKernel",
py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::getLocalKernel, py::const_),
&Psf::getLocalKernel,
"position"_a,
"color"_a = image::Color()
);

// Deprecated default position argument overloads.
cls.def("computeImage",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeImage();
}
);
cls.def("computeKernelImage",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeKernelImage();
}
);
cls.def("computePeak",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computePeak();
}
);
cls.def("computeApertureFlux",
[](const Psf& psf, double radius) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeApertureFlux(radius);
},
"radius"_a
);
cls.def("computeShape",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeShape();
}
);
cls.def("computeBBox",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeBBox();
}
);
cls.def("computeImageBBox",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeImageBBox();
}
);
cls.def("computeKernelBBox",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.computeKernelBBox();
}
);
cls.def("getLocalKernel",
[](const Psf& psf) {
py::gil_scoped_acquire gil;
auto warnings = py::module::import("warnings");
auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
warnings.attr("warn")(
"Default position argument overload is deprecated and will be "
"removed in version 24.0. Please explicitly specify a position.",
"category"_a=FutureWarning
);
return psf.getLocalKernel();
}
);
// End deprecated default position argument overloads.

cls.def("getAverageColor", &Psf::getAverageColor);
cls.def("getAveragePosition", &Psf::getAveragePosition);
cls.def_static("recenterKernelImage", &Psf::recenterKernelImage, "im"_a, "position"_a,
Expand Down
32 changes: 0 additions & 32 deletions src/detection/Psf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ std::shared_ptr<image::Image<double>> Psf::recenterKernelImage(std::shared_ptr<I
return im;
}

std::shared_ptr<Psf::Image> Psf::computeImage() const {
return computeImage(makeNullPoint());
}

std::shared_ptr<Psf::Image> Psf::computeImage(lsst::geom::Point2D position, image::Color color,
ImageOwnerEnum owner) const {
if (isPointNull(position)) position = getAveragePosition();
Expand All @@ -115,10 +111,6 @@ std::shared_ptr<Psf::Image> Psf::computeImage(lsst::geom::Point2D position, imag
return result;
}

std::shared_ptr<Psf::Image> Psf::computeKernelImage() const {
return computeKernelImage(makeNullPoint());
}

std::shared_ptr<Psf::Image> Psf::computeKernelImage(lsst::geom::Point2D position, image::Color color,
ImageOwnerEnum owner) const {
if (_isFixed || isPointNull(position)) position = getAveragePosition();
Expand All @@ -132,10 +124,6 @@ std::shared_ptr<Psf::Image> Psf::computeKernelImage(lsst::geom::Point2D position
return result;
}

lsst::geom::Box2I Psf::computeBBox() const {
return computeBBox(makeNullPoint());
}

lsst::geom::Box2I Psf::computeBBox(lsst::geom::Point2D position, image::Color color) const {
if (isPointNull(position)) position = getAveragePosition();
if (color.isIndeterminate()) color = getAverageColor();
Expand All @@ -147,10 +135,6 @@ lsst::geom::Box2I Psf::computeBBox(lsst::geom::Point2D position, image::Color co
}
}

lsst::geom::Box2I Psf::computeImageBBox() const {
return computeImageBBox(makeNullPoint());
}

lsst::geom::Box2I Psf::computeImageBBox(lsst::geom::Point2D position, image::Color color) const {
if (isPointNull(position)) position = getAveragePosition();
if (color.isIndeterminate()) color = getAverageColor();
Expand All @@ -162,10 +146,6 @@ lsst::geom::Box2I Psf::computeImageBBox(lsst::geom::Point2D position, image::Col
}
}

std::shared_ptr<math::Kernel const> Psf::getLocalKernel() const {
return getLocalKernel(makeNullPoint());
}

std::shared_ptr<math::Kernel const> Psf::getLocalKernel(lsst::geom::Point2D position,
image::Color color) const {
if (isPointNull(position)) position = getAveragePosition();
Expand All @@ -175,31 +155,19 @@ std::shared_ptr<math::Kernel const> Psf::getLocalKernel(lsst::geom::Point2D posi
return std::make_shared<math::FixedKernel>(*image);
}

double Psf::computePeak() const {
return computePeak(makeNullPoint());
}

double Psf::computePeak(lsst::geom::Point2D position, image::Color color) const {
if (isPointNull(position)) position = getAveragePosition();
if (color.isIndeterminate()) color = getAverageColor();
std::shared_ptr<Image> image = computeKernelImage(position, color, INTERNAL);
return (*image)(-image->getX0(), -image->getY0());
}

double Psf::computeApertureFlux(double radius) const {
return computeApertureFlux(radius, makeNullPoint());
}

double Psf::computeApertureFlux(double radius, lsst::geom::Point2D position, image::Color color) const {
if (isPointNull(position)) position = getAveragePosition();
if (color.isIndeterminate()) color = getAverageColor();
return doComputeApertureFlux(radius, position, color);
}

geom::ellipses::Quadrupole Psf::computeShape() const {
return computeShape(makeNullPoint());
}

geom::ellipses::Quadrupole Psf::computeShape(lsst::geom::Point2D position, image::Color color) const {
if (isPointNull(position)) position = getAveragePosition();
if (color.isIndeterminate()) color = getAverageColor();
Expand Down

0 comments on commit 4d318ec

Please sign in to comment.