lsst.afw  22.0.1-32-g5ddfab5d3+23bd69c089
Psf.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 #ifndef LSST_AFW_DETECTION_Psf_h_INCLUDED
24 #define LSST_AFW_DETECTION_Psf_h_INCLUDED
25 
26 #include <string>
27 #include <limits>
28 
29 #include <memory>
30 
31 #include "lsst/utils/CacheFwd.h"
33 #include "lsst/afw/math/Kernel.h"
34 #include "lsst/afw/image/Color.h"
37 
38 namespace lsst {
39 namespace afw {
40 namespace detection {
41 namespace detail {
42 
44 struct PsfCacheKey;
45 
46 } // namespace detail
47 
77  static lsst::geom::Point2D makeNullPoint() {
79  }
80 
81 public:
84 
87  COPY = 0,
88  INTERNAL = 1
92  };
93 
94  Psf(Psf const&);
95  Psf& operator=(Psf const&) = delete;
96  Psf& operator=(Psf&&) = delete;
97 
98  Psf(Psf&&);
99  ~Psf() override;
100 
108  virtual std::shared_ptr<Psf> clone() const = 0;
109 
117 
126  virtual std::shared_ptr<Psf> resized(int width, int height) const = 0;
127 
149  image::Color color = image::Color(),
150  ImageOwnerEnum owner = COPY) const;
151 
152  // Using the default position automatically implies use of the default color, owner.
153  [[deprecated(
154  "Default position argument overload is deprecated and will be removed "
155  "in version 24.0. Please use overload with explicit position."
156  )]]
158 
182  image::Color color = image::Color(),
183  ImageOwnerEnum owner = COPY) const;
184  // Using the default position automatically implies use of the default color, owner.
185  [[deprecated(
186  "Default position argument overload is deprecated and will be removed "
187  "in version 24.0. Please use overload with explicit position."
188  )]]
190 
202  double computePeak(lsst::geom::Point2D position,
203  image::Color color = image::Color()) const;
204 
205  [[deprecated(
206  "Default position argument overload is deprecated and will be removed "
207  "in version 24.0. Please use overload with explicit position."
208  )]]
209  double computePeak() const;
210 
222  double computeApertureFlux(double radius, lsst::geom::Point2D position,
223  image::Color color = image::Color()) const;
224 
225  [[deprecated(
226  "Default position argument overload is deprecated and will be removed "
227  "in version 24.0. Please use overload with explicit position."
228  )]]
229  double computeApertureFlux(double radius) const;
230 
242  image::Color color = image::Color()) const;
243 
244  [[deprecated(
245  "Default position argument overload is deprecated and will be removed "
246  "in version 24.0. Please use overload with explicit position."
247  )]]
249 
261  image::Color color = image::Color()) const;
262 
263  [[deprecated(
264  "Default position argument overload is deprecated and will be removed "
265  "in version 24.0. Please use overload with explicit position."
266  )]]
268 
275 
281  virtual lsst::geom::Point2D getAveragePosition() const;
282 
291  image::Color color = image::Color()) const;
292 
293  [[deprecated(
294  "Default position argument overload is deprecated and will be removed "
295  "in version 24.0. Please use overload with explicit position."
296  )]]
298 
307  image::Color color = image::Color()) const;
308 
309  [[deprecated(
310  "Default position argument overload is deprecated and will be removed "
311  "in version 24.0. Please use overload with explicit position."
312  )]]
314 
324  image::Color color = image::Color()) const {
325  return computeBBox(position, color);
326  }
327 
328  [[deprecated(
329  "Default position argument overload is deprecated and will be removed "
330  "in version 24.0. Please use overload with explicit position."
331  )]]
333  return computeBBox();
334  }
335 
355  lsst::geom::Point2D const& position,
356  std::string const& warpAlgorithm = "lanczos5",
357  unsigned int warpBuffer = 5);
358 
364 
369  void setCacheCapacity(std::size_t capacity);
370 
371 protected:
379  explicit Psf(bool isFixed = false, std::size_t capacity = 100);
380 
382 
391  image::Color const& color) const;
393  image::Color const& color) const;
395 
396 private:
398 
406  image::Color const& color) const = 0;
407  virtual double doComputeApertureFlux(double radius, lsst::geom::Point2D const& position,
408  image::Color const& color) const = 0;
410  image::Color const& color) const = 0;
412  image::Color const& color) const = 0;
414 
415  bool const _isFixed;
416  using PsfCache = utils::Cache<detail::PsfCacheKey, std::shared_ptr<Image>>;
417  std::unique_ptr<PsfCache> _imageCache;
418  std::unique_ptr<PsfCache> _kernelImageCache;
419 };
420 } // namespace detection
421 } // namespace afw
422 } // namespace lsst
423 
424 #endif // !LSST_AFW_DETECTION_Psf_h_INCLUDED
A polymorphic base class for representing an image's Point Spread Function.
Definition: Psf.h:76
Psf & operator=(Psf const &)=delete
virtual std::shared_ptr< Psf > resized(int width, int height) const =0
Return clone with specified kernel dimensions.
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,...
Definition: Psf.cc:85
math::Kernel::Pixel Pixel
Pixel type of Image returned by computeImage.
Definition: Psf.h:82
lsst::geom::Box2I computeBBox() const
Definition: Psf.cc:135
virtual std::shared_ptr< Image > doComputeImage(lsst::geom::Point2D const &position, image::Color const &color) const
These virtual members are protected (rather than private) so that python-implemented derived classes ...
Definition: Psf.cc:199
lsst::geom::Box2I computeImageBBox() const
Definition: Psf.cc:145
std::size_t getCacheCapacity() const
Return the capacity of the caches.
Definition: Psf.cc:213
virtual std::shared_ptr< Image > doComputeKernelImage(lsst::geom::Point2D const &position, image::Color const &color) const =0
These virtual member functions are private, not protected, because we only want derived classes to im...
double computeApertureFlux(double radius, lsst::geom::Point2D position, image::Color color=image::Color()) const
Compute the "flux" of the Psf model within a circular aperture of the given radius.
Definition: Psf.cc:183
std::shared_ptr< typehandling::Storable > cloneStorable() const override
Polymorphic deep-copy.
Definition: Psf.h:116
std::shared_ptr< Image > computeImage() const
Definition: Psf.cc:101
lsst::geom::Box2I computeKernelBBox() const
Definition: Psf.h:332
std::shared_ptr< Image > computeKernelImage() const
Definition: Psf.cc:118
std::shared_ptr< math::Kernel const > getLocalKernel() const
Definition: Psf.cc:155
Psf(Psf const &)
Definition: Psf.cc:78
Psf & operator=(Psf &&)=delete
double computePeak() const
Definition: Psf.cc:168
virtual std::shared_ptr< Psf > clone() const =0
Polymorphic deep-copy.
image::Color getAverageColor() const
Return the average Color of the stars used to construct the Psf.
Definition: Psf.h:274
virtual lsst::geom::Box2I doComputeImageBBox(lsst::geom::Point2D const &position, image::Color const &color) const
Definition: Psf.cc:205
ImageOwnerEnum
Enum passed to computeImage and computeKernelImage to determine image ownership.
Definition: Psf.h:86
@ COPY
The image will be copied before returning; caller will own it.
Definition: Psf.h:87
@ INTERNAL
An internal image will be returned without copying.
Definition: Psf.h:88
virtual lsst::geom::Box2I doComputeBBox(lsst::geom::Point2D const &position, image::Color const &color) const =0
void setCacheCapacity(std::size_t capacity)
Set the capacity of the caches.
Definition: Psf.cc:215
geom::ellipses::Quadrupole computeShape() const
Definition: Psf.cc:189
virtual double doComputeApertureFlux(double radius, lsst::geom::Point2D const &position, image::Color const &color) const =0
virtual lsst::geom::Point2D getAveragePosition() const
Return the average position of the stars used to construct the Psf.
Definition: Psf.cc:211
lsst::geom::Box2I computeKernelBBox(lsst::geom::Point2D position, image::Color color=image::Color()) const
Return the bounding box of the image returned by computeImage()
Definition: Psf.h:323
virtual geom::ellipses::Quadrupole doComputeShape(lsst::geom::Point2D const &position, image::Color const &color) const =0
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
Describe the colour of a source.
Definition: Color.h:26
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
Interface supporting iteration over heterogenous containers.
Definition: Storable.h:58
Point< double, 2 > Point2D
A base class for image defects.