lsst.afw  13.0-73-gb2a4e38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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"
33 #include "lsst/afw/math/Kernel.h"
34 #include "lsst/afw/image/Color.h"
36 
37 namespace lsst {
38 namespace afw {
39 namespace detection {
40 
41 class PsfFormatter;
42 
70 class Psf : public daf::base::Citizen,
71  public daf::base::Persistable,
74  static geom::Point2D makeNullPoint() { return geom::Point2D(std::numeric_limits<double>::quiet_NaN()); }
75 
76 public:
79 
82  COPY = 0,
83  INTERNAL = 1
87  };
88 
89  virtual ~Psf() {}
90 
98  virtual std::shared_ptr<Psf> clone() const = 0;
99 
120  std::shared_ptr<Image> computeImage(geom::Point2D position = makeNullPoint(),
121  image::Color color = image::Color(),
122  ImageOwnerEnum owner = COPY) const;
123 
146  std::shared_ptr<Image> computeKernelImage(geom::Point2D position = makeNullPoint(),
147  image::Color color = image::Color(),
148  ImageOwnerEnum owner = COPY) const;
149 
161  double computePeak(geom::Point2D position = makeNullPoint(), image::Color color = image::Color()) const;
162 
174  double computeApertureFlux(double radius, geom::Point2D position = makeNullPoint(),
175  image::Color color = image::Color()) const;
176 
187  geom::ellipses::Quadrupole computeShape(geom::Point2D position = makeNullPoint(),
188  image::Color color = image::Color()) const;
189 
196  std::shared_ptr<math::Kernel const> getLocalKernel(geom::Point2D position = makeNullPoint(),
197  image::Color color = image::Color()) const;
198 
205 
211  virtual geom::Point2D getAveragePosition() const;
212 
216  geom::Box2I computeBBox(geom::Point2D position = makeNullPoint(),
217  image::Color color = image::Color()) const;
218 
237  static std::shared_ptr<Image> recenterKernelImage(std::shared_ptr<Image> im,
238  geom::Point2D const& position,
239  std::string const& warpAlgorithm = "lanczos5",
240  unsigned int warpBuffer = 5);
241 
242 protected:
249  explicit Psf(bool isFixed = false);
250 
251 private:
253 
260  virtual std::shared_ptr<Image> doComputeImage(geom::Point2D const& position,
261  image::Color const& color) const;
262  virtual std::shared_ptr<Image> doComputeKernelImage(geom::Point2D const& position,
263  image::Color const& color) const = 0;
264  virtual double doComputeApertureFlux(double radius, geom::Point2D const& position,
265  image::Color const& color) const = 0;
266  virtual geom::ellipses::Quadrupole doComputeShape(geom::Point2D const& position,
267  image::Color const& color) const = 0;
268  virtual geom::Box2I doComputeBBox(geom::Point2D const& position, image::Color const& color) const = 0;
270 
271  bool const _isFixed;
272  mutable std::shared_ptr<Image> _cachedImage;
273  mutable std::shared_ptr<Image> _cachedKernelImage;
274  mutable image::Color _cachedImageColor;
275  mutable image::Color _cachedKernelImageColor;
276  mutable geom::Point2D _cachedImagePosition;
277  mutable geom::Point2D _cachedKernelImagePosition;
278 
279  LSST_PERSIST_FORMATTER(PsfFormatter)
280 };
281 }
282 }
283 } // namespace lsst::afw::detection
284 
285 #endif // !LSST_AFW_DETECTION_Psf_h_INCLUDED
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
std::shared_ptr< Image > computeImage(geom::Point2D position=makeNullPoint(), image::Color color=image::Color(), ImageOwnerEnum owner=COPY) const
Return an Image of the PSF, in a form that can be compared directly with star images.
image::Color getAverageColor() const
Return the average Color of the stars used to construct the Psf.
Definition: Psf.h:204
std::shared_ptr< math::Kernel const > getLocalKernel(geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Return a FixedKernel corresponding to the Psf image at the given point.
ImageOwnerEnum
Enum passed to computeImage and computeKernelImage to determine image ownership.
Definition: Psf.h:81
std::shared_ptr< Image > computeKernelImage(geom::Point2D position=makeNullPoint(), image::Color color=image::Color(), ImageOwnerEnum owner=COPY) const
Return an Image of the PSF, in a form suitable for convolution.
An integer coordinate rectangle.
Definition: Box.h:55
Psf(bool isFixed=false)
Main constructor for subclasses.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:73
virtual std::shared_ptr< Psf > clone() const =0
Polymorphic deep-copy.
Point< double, 2 > Point2D
Definition: Point.h:273
math::Kernel::Pixel Pixel
Pixel type of Image returned by computeImage.
Definition: Psf.h:77
virtual ~Psf()
Definition: Psf.h:89
Formatter for persistence of Psf instances.
Definition: PsfFormatter.h:21
virtual geom::Point2D getAveragePosition() const
Return the average position of the stars used to construct the Psf.
double computePeak(geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Return the peak value of the PSF image.
geom::ellipses::Quadrupole computeShape(geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Compute the ellipse corresponding to the second moments of the Psf.
An internal image will be returned without copying.
Definition: Psf.h:83
Describe the colour of a source.
Definition: Color.h:26
double computeApertureFlux(double radius, geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Compute the &quot;flux&quot; of the Psf model within a circular aperture of the given radius.
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:70
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:173
image::Image< Pixel > Image
Image type returned by computeImage.
Definition: Psf.h:78
The image will be copied before returning; caller will own it.
Definition: Psf.h:82
geom::Box2I computeBBox(geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Return the bounding box of the image returned by computeKernelImage()
static std::shared_ptr< Image > recenterKernelImage(std::shared_ptr< Image > im, 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,0) when xy0 is taken into account) to an image centered at position when xy0 is taken into account.