lsst.afw  13.0-100-ge0459d59f+2
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 
108  virtual std::shared_ptr<Psf> resized(int width, int height) const = 0;
109 
130  std::shared_ptr<Image> computeImage(geom::Point2D position = makeNullPoint(),
132  ImageOwnerEnum owner = COPY) const;
133 
156  std::shared_ptr<Image> computeKernelImage(geom::Point2D position = makeNullPoint(),
158  ImageOwnerEnum owner = COPY) const;
159 
171  double computePeak(geom::Point2D position = makeNullPoint(), image::Color color = image::Color()) const;
172 
184  double computeApertureFlux(double radius, geom::Point2D position = makeNullPoint(),
185  image::Color color = image::Color()) const;
186 
197  geom::ellipses::Quadrupole computeShape(geom::Point2D position = makeNullPoint(),
198  image::Color color = image::Color()) const;
199 
206  std::shared_ptr<math::Kernel const> getLocalKernel(geom::Point2D position = makeNullPoint(),
207  image::Color color = image::Color()) const;
208 
215 
221  virtual geom::Point2D getAveragePosition() const;
222 
226  geom::Box2I computeBBox(geom::Point2D position = makeNullPoint(),
227  image::Color color = image::Color()) const;
228 
247  static std::shared_ptr<Image> recenterKernelImage(std::shared_ptr<Image> im,
248  geom::Point2D const& position,
249  std::string const& warpAlgorithm = "lanczos5",
250  unsigned int warpBuffer = 5);
251 
252 protected:
259  explicit Psf(bool isFixed = false);
260 
261 private:
263 
270  virtual std::shared_ptr<Image> doComputeImage(geom::Point2D const& position,
271  image::Color const& color) const;
272  virtual std::shared_ptr<Image> doComputeKernelImage(geom::Point2D const& position,
273  image::Color const& color) const = 0;
274  virtual double doComputeApertureFlux(double radius, geom::Point2D const& position,
275  image::Color const& color) const = 0;
276  virtual geom::ellipses::Quadrupole doComputeShape(geom::Point2D const& position,
277  image::Color const& color) const = 0;
278  virtual geom::Box2I doComputeBBox(geom::Point2D const& position, image::Color const& color) const = 0;
280 
281  bool const _isFixed;
282  mutable std::shared_ptr<Image> _cachedImage;
283  mutable std::shared_ptr<Image> _cachedKernelImage;
284  mutable image::Color _cachedImageColor;
285  mutable image::Color _cachedKernelImageColor;
286  mutable geom::Point2D _cachedImagePosition;
287  mutable geom::Point2D _cachedKernelImagePosition;
288 
289  LSST_PERSIST_FORMATTER(PsfFormatter)
290 };
291 }
292 }
293 } // namespace lsst::afw::detection
294 
295 #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:81
double computePeak(geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Return the peak value of the PSF image.
image::Color getAverageColor() const
Return the average Color of the stars used to construct the Psf.
Definition: Psf.h:214
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.
A base class for image defects.
Definition: cameraGeom.dox:3
Point< double, 2 > Point2D
Definition: Point.h:273
math::Kernel::Pixel Pixel
Pixel type of Image returned by computeImage.
Definition: Psf.h:77
virtual geom::Point2D getAveragePosition() const
Return the average position of the stars used to construct the Psf.
double computeApertureFlux(double radius, geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Compute the "flux" of the Psf model within a circular aperture of the given radius.
virtual std::shared_ptr< Psf > resized(int width, int height) const =0
Return clone with specified kernel dimensions.
virtual ~Psf()
Definition: Psf.h:89
Formatter for persistence of Psf instances.
Definition: PsfFormatter.h:21
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.
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.
An internal image will be returned without copying.
Definition: Psf.h:83
geom::Box2I computeBBox(geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
Return the bounding box of the image returned by computeKernelImage()
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.
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: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
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.
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.