LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
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;
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
Cache of most recently used values.
Definition: Cache.h:74
An integer coordinate rectangle.
Definition: Box.h:55
Point< double, 2 > Point2D
Definition: Point.h:324
A base class for image defects.