lsst.afw  14.0-69-ge506bfb5f
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/daf/base.h"
32 #include "lsst/utils/CacheFwd.h"
34 #include "lsst/afw/math/Kernel.h"
35 #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 
48 class PsfFormatter;
49 
77 class Psf : public daf::base::Citizen,
81  static geom::Point2D makeNullPoint() { return geom::Point2D(std::numeric_limits<double>::quiet_NaN()); }
82 
83 public:
86 
89  COPY = 0,
90  INTERNAL = 1
94  };
95 
96  Psf(Psf const&);
97  Psf& operator=(Psf const&) = delete;
98  Psf& operator=(Psf&&) = delete;
99 
100  Psf(Psf&&);
101  virtual ~Psf();
102 
110  virtual std::shared_ptr<Psf> clone() const = 0;
111 
120  virtual std::shared_ptr<Psf> resized(int width, int height) const = 0;
121 
142  std::shared_ptr<Image> computeImage(geom::Point2D position = makeNullPoint(),
144  ImageOwnerEnum owner = COPY) const;
145 
168  std::shared_ptr<Image> computeKernelImage(geom::Point2D position = makeNullPoint(),
170  ImageOwnerEnum owner = COPY) const;
171 
183  double computePeak(geom::Point2D position = makeNullPoint(), image::Color color = image::Color()) const;
184 
196  double computeApertureFlux(double radius, geom::Point2D position = makeNullPoint(),
197  image::Color color = image::Color()) const;
198 
209  geom::ellipses::Quadrupole computeShape(geom::Point2D position = makeNullPoint(),
210  image::Color color = image::Color()) const;
211 
218  std::shared_ptr<math::Kernel const> getLocalKernel(geom::Point2D position = makeNullPoint(),
219  image::Color color = image::Color()) const;
220 
227 
233  virtual geom::Point2D getAveragePosition() const;
234 
238  geom::Box2I computeBBox(geom::Point2D position = makeNullPoint(),
239  image::Color color = image::Color()) const;
240 
259  static std::shared_ptr<Image> recenterKernelImage(std::shared_ptr<Image> im,
260  geom::Point2D const& position,
261  std::string const& warpAlgorithm = "lanczos5",
262  unsigned int warpBuffer = 5);
263 
268  std::size_t getCacheCapacity() const;
269 
274  void setCacheCapacity(std::size_t capacity);
275 
276 protected:
284  explicit Psf(bool isFixed = false, std::size_t capacity=100);
285 
286 private:
288 
295  virtual std::shared_ptr<Image> doComputeImage(geom::Point2D const& position,
296  image::Color const& color) const;
297  virtual std::shared_ptr<Image> doComputeKernelImage(geom::Point2D const& position,
298  image::Color const& color) const = 0;
299  virtual double doComputeApertureFlux(double radius, geom::Point2D const& position,
300  image::Color const& color) const = 0;
301  virtual geom::ellipses::Quadrupole doComputeShape(geom::Point2D const& position,
302  image::Color const& color) const = 0;
303  virtual geom::Box2I doComputeBBox(geom::Point2D const& position, image::Color const& color) const = 0;
305 
306  bool const _isFixed;
308  std::unique_ptr<PsfCache> _imageCache;
309  std::unique_ptr<PsfCache> _kernelImageCache;
310 
312 };
313 }
314 }
315 } // namespace lsst::afw::detection
316 
317 #endif // !LSST_AFW_DETECTION_Psf_h_INCLUDED
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
ImageOwnerEnum
Enum passed to computeImage and computeKernelImage to determine image ownership.
Definition: Psf.h:88
image::Color getAverageColor() const
Return the average Color of the stars used to construct the Psf.
Definition: Psf.h:226
An integer coordinate rectangle.
Definition: Box.h:55
STL class.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
A base class for image defects.
Point< double, 2 > Point2D
Definition: Point.h:304
math::Kernel::Pixel Pixel
Pixel type of Image returned by computeImage.
Definition: Psf.h:84
Formatter for persistence of Psf instances.
Definition: PsfFormatter.h:21
STL class.
#define LSST_PERSIST_FORMATTER(formatter...)
Describe the colour of a source.
Definition: Color.h:26
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:77
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
image::Image< Pixel > Image
Image type returned by computeImage.
Definition: Psf.h:85