LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Private Member Functions | Private Attributes | List of all members
lsst::afw::detection::Psf Class Referenceabstract

A polymorphic base class for representing an image's Point Spread Function. More...

#include <Psf.h>

Inheritance diagram for lsst::afw::detection::Psf:
lsst::daf::base::Citizen lsst::daf::base::Persistable lsst::afw::table::io::PersistableFacade< Psf > lsst::afw::table::io::Persistable lsst::afw::detection::GaussianPsf lsst::meas::algorithms::ImagePsf lsst::meas::algorithms::CoaddPsf lsst::meas::algorithms::KernelPsf lsst::meas::algorithms::WarpedPsf lsst::meas::algorithms::DoubleGaussianPsf lsst::meas::algorithms::PcaPsf lsst::meas::algorithms::SingleGaussianPsf

Public Types

enum  ImageOwnerEnum { COPY =0, INTERNAL =1 }
 Enum passed to computeImage and computeKernelImage to determine image ownership. More...
 
typedef boost::shared_ptr< PsfPtr
 
typedef boost::shared_ptr
< const Psf
ConstPtr
 
typedef math::Kernel::Pixel Pixel
 Pixel type of Image returned by computeImage. More...
 
typedef image::Image< PixelImage
 Image type returned by computeImage. More...
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 
- Public Types inherited from lsst::daf::base::Persistable
typedef boost::shared_ptr
< Persistable
Ptr
 

Public Member Functions

virtual ~Psf ()
 
virtual boost::shared_ptr< Psfclone () const =0
 Polymorphic deep-copy. More...
 
boost::shared_ptr< ImagecomputeImage (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. More...
 
boost::shared_ptr< ImagecomputeKernelImage (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. More...
 
double computePeak (geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
 Return the peak value of the PSF image. More...
 
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. More...
 
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. More...
 
boost::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. More...
 
image::Color getAverageColor () const
 Return the average Color of the stars used to construct the Psf. More...
 
virtual geom::Point2D getAveragePosition () const
 Return the average position of the stars used to construct the Psf. More...
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 
- Public Member Functions inherited from lsst::daf::base::Persistable
 Persistable (void)
 
virtual ~Persistable (void)
 
template<class Archive >
void serialize (Archive &, unsigned int const)
 
- Public Member Functions inherited from lsst::afw::table::io::Persistable
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object. More...
 
virtual bool isPersistable () const
 Return true if this particular object can be persisted using afw::table::io. More...
 
virtual ~Persistable ()
 

Static Public Member Functions

static boost::shared_ptr< ImagerecenterKernelImage (boost::shared_ptr< Image > im, geom::Point2D const &position, std::string const &warpAlgorithm="lanczos5", unsigned int warpBuffer=5)
 
- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 
- Static Public Member Functions inherited from lsst::afw::table::io::PersistableFacade< Psf >
static boost::shared_ptr< Psf > readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static boost::shared_ptr< Psf > readFits (std::string const &fileName, int hdu=0)
 Read an object from a regular FITS file. More...
 
static boost::shared_ptr< Psf > readFits (fits::MemFileManager &manager, int hdu=0)
 Read an object from a FITS file in memory. More...
 

Protected Member Functions

 Psf (bool isFixed=false)
 
- Protected Member Functions inherited from lsst::afw::table::io::Persistable
virtual std::string getPersistenceName () const
 Return the unique name used to persist this object and look up its factory. More...
 
virtual std::string getPythonModule () const
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
virtual void write (OutputArchiveHandle &handle) const
 Write the object to one or more catalogs. More...
 
 Persistable ()
 
 Persistable (Persistable const &other)
 
void operator= (Persistable const &other)
 

Private Member Functions

virtual boost::shared_ptr< ImagedoComputeImage (geom::Point2D const &position, image::Color const &color) const
 
virtual boost::shared_ptr< ImagedoComputeKernelImage (geom::Point2D const &position, image::Color const &color) const =0
 
virtual double doComputeApertureFlux (double radius, geom::Point2D const &position, image::Color const &color) const =0
 
virtual geom::ellipses::Quadrupole doComputeShape (geom::Point2D const &position, image::Color const &color) const =0
 

Static Private Member Functions

static geom::Point2D makeNullPoint ()
 

Private Attributes

bool const _isFixed
 
boost::shared_ptr< Image_cachedImage
 
boost::shared_ptr< Image_cachedKernelImage
 
image::Color _cachedImageColor
 
image::Color _cachedKernelImageColor
 
geom::Point2D _cachedImagePosition
 
geom::Point2D _cachedKernelImagePosition
 

Additional Inherited Members

- Protected Types inherited from lsst::afw::table::io::Persistable
typedef io::OutputArchiveHandle OutputArchiveHandle
 

Detailed Description

A polymorphic base class for representing an image's Point Spread Function.

Most of a Psf's functionality involves its evaluation at a position and color, either or both of which may be unspecified (which will result in evaluation at some average position or color). Unlike the closely-related Kernel class, there is no requirement that a Psf have a well-defined spatial function or any parameters. Psfs are not necessarily continuous, and the dimensions of image of the Psf at a point may not be fixed.

Psfs have two methods for getting at image at a point:

Because P does not need to have integer coordinates, these two images are fractionally offset from each other and we use interpolation to get (1) from (2).

Psfs are immutable - derived classes should have no non-const methods, and hence should be fully-defined after construction. This allows shared_ptrs to Psfs to be passed around and shared between objects without concern for whether they will be unexpectedly modified.

In most cases, Psf derived classes should inherit from meas::algorithms::ImagePsf or meas::algorithms::KernelPsf, as these will provide default implementions for several member functions.

Definition at line 68 of file Psf.h.

Member Typedef Documentation

typedef boost::shared_ptr<const Psf> lsst::afw::detection::Psf::ConstPtr
Deprecated:
shared_ptr to a const Psf

Definition at line 76 of file Psf.h.

Image type returned by computeImage.

Definition at line 79 of file Psf.h.

Pixel type of Image returned by computeImage.

Definition at line 78 of file Psf.h.

typedef boost::shared_ptr<Psf> lsst::afw::detection::Psf::Ptr
Deprecated:
shared_ptr to a Psf

Definition at line 75 of file Psf.h.

Member Enumeration Documentation

Enum passed to computeImage and computeKernelImage to determine image ownership.

Enumerator
COPY 

The image will be copied before returning; caller will own it.

INTERNAL 

An internal image will be returned without copying. The caller must not modify it, and it may be invalidated the next time a Psf member function is called with different color and/or position.

Definition at line 82 of file Psf.h.

82  {
83  COPY=0,
84  INTERNAL=1
88  };
The image will be copied before returning; caller will own it.
Definition: Psf.h:83

Constructor & Destructor Documentation

virtual lsst::afw::detection::Psf::~Psf ( )
inlinevirtual

Definition at line 90 of file Psf.h.

90 {}
lsst::afw::detection::Psf::Psf ( bool  isFixed = false)
explicitprotected

Main constructor for subclasses.

Parameters
[in]isFixedShould be true for Psf for which doComputeKernelImage always returns the same image, regardless of color or position arguments.

Member Function Documentation

virtual boost::shared_ptr< Psf > lsst::afw::detection::Psf::clone ( ) const
pure virtual

Polymorphic deep-copy.

Because Psfs are immutable, clones should generally be unnecessary, but they may be useful in allowing Psfs to maintain separate caches for their most recently returned images.

Implemented in lsst::meas::algorithms::WarpedPsf, lsst::meas::algorithms::CoaddPsf, lsst::afw::detection::GaussianPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::SingleGaussianPsf, lsst::meas::algorithms::DoubleGaussianPsf, and lsst::meas::algorithms::PcaPsf.

double lsst::afw::detection::Psf::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.

Parameters
[in]radiusRadius of the aperture to measure.
[in]positionPosition to evaluate the PSF at; defaults to getAveragePosition().
[in]colorColor of the source for which to evaluate the PSF; defaults to getAverageColor().

The flux is relative to a Psf image that has been normalized to unit integral, and the radius is in pixels.

boost::shared_ptr< Image > lsst::afw::detection::Psf::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.

The specified position is a floating point number, and the resulting image will have a Psf centered on that point when the returned image's xy0 is taken into account.

The returned image is normalized to sum to unity.

Parameters
[in]positionPosition to evaluate the PSF at; defaults to getAveragePosition().
[in]colorColor of the source for which to evaluate the PSF; defaults to getAverageColor().
[in]ownerWhether to copy the return value or return an internal image that must be handled with care (see ImageOwnerEnum).

The Psf class caches the most recent return value of computeImage, so repeated calls with the same arguments will be highly optimized.

Note
The real work is done in the virtual private member function Psf::doComputeImage; computeImage only handles caching and default arguments.
boost::shared_ptr< Image > lsst::afw::detection::Psf::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.

While the position need not be an integer, the center of the PSF image returned by computeKernelImage will in the center of the center pixel of the image, which will be (0,0) when the Image's xy0 is taken into account; this is the same behavior as Kernel::computeImage().

The returned image is normalized to sum to unity.

Parameters
[in]positionPosition to evaluate the PSF at; defaults to getAveragePosition().
[in]colorColor of the source for which to evaluate the PSF; defaults to getAverageColor().
[in]ownerWhether to copy the return value or return an internal image that must be handled with care (see ImageOwnerEnum).

The Psf class caches the most recent return value of computeKernelImage, so repeated calls with the same arguments will be highly optimized.

Note
The real work is done in the virtual private member function Psf::doComputeKernelImage; computeKernelImage only handles caching and default arguments.
double lsst::afw::detection::Psf::computePeak ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color() 
) const

Return the peak value of the PSF image.

Parameters
[in]positionPosition to evaluate the PSF at; defaults to getAveragePosition().
[in]colorColor of the source for which to evaluate the PSF; defaults to getAverageColor().

This calls computeKernelImage internally, but because this will usually be cached, it shouldn't be expensive (but be careful not to accidentally call it with no arguments when you actually want to call it with the same arguments just used to call computeImage or computeKernelImage).

geom::ellipses::Quadrupole lsst::afw::detection::Psf::computeShape ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color() 
) const

Compute the ellipse corresponding to the second moments of the Psf.

Parameters
[in]positionPosition to evaluate the PSF at; defaults to getAveragePosition().
[in]colorColor of the source for which to evaluate the PSF; defaults to getAverageColor().

The algorithm used to compute the moments is up to the derived class, and hence this method should not be used when a particular algorithm or weight function is required.

virtual double lsst::afw::detection::Psf::doComputeApertureFlux ( double  radius,
geom::Point2D const &  position,
image::Color const &  color 
) const
privatepure virtual

These virtual member functions are private, not protected, because we only want derived classes to implement them, not call them; they should call the corresponding compute*Image member functions instead so as to let the Psf base class handle caching properly.

Derived classes are responsible for ensuring that returned images sum to one.

Implemented in lsst::afw::detection::GaussianPsf, and lsst::meas::algorithms::ImagePsf.

virtual boost::shared_ptr< Image > lsst::afw::detection::Psf::doComputeImage ( geom::Point2D const &  position,
image::Color const &  color 
) const
privatevirtual

These virtual member functions are private, not protected, because we only want derived classes to implement them, not call them; they should call the corresponding compute*Image member functions instead so as to let the Psf base class handle caching properly.

Derived classes are responsible for ensuring that returned images sum to one.

virtual boost::shared_ptr< Image > lsst::afw::detection::Psf::doComputeKernelImage ( geom::Point2D const &  position,
image::Color const &  color 
) const
privatepure virtual

These virtual member functions are private, not protected, because we only want derived classes to implement them, not call them; they should call the corresponding compute*Image member functions instead so as to let the Psf base class handle caching properly.

Derived classes are responsible for ensuring that returned images sum to one.

Implemented in lsst::meas::algorithms::CoaddPsf, lsst::afw::detection::GaussianPsf, lsst::meas::algorithms::KernelPsf, and lsst::meas::algorithms::WarpedPsf.

virtual geom::ellipses::Quadrupole lsst::afw::detection::Psf::doComputeShape ( geom::Point2D const &  position,
image::Color const &  color 
) const
privatepure virtual

These virtual member functions are private, not protected, because we only want derived classes to implement them, not call them; they should call the corresponding compute*Image member functions instead so as to let the Psf base class handle caching properly.

Derived classes are responsible for ensuring that returned images sum to one.

Implemented in lsst::afw::detection::GaussianPsf, and lsst::meas::algorithms::ImagePsf.

image::Color lsst::afw::detection::Psf::getAverageColor ( ) const
inline

Return the average Color of the stars used to construct the Psf.

This is also the Color used to return an image if you don't specify a Color.

Definition at line 219 of file Psf.h.

219 { return image::Color(); }
virtual geom::Point2D lsst::afw::detection::Psf::getAveragePosition ( ) const
virtual

Return the average position of the stars used to construct the Psf.

This is also the position used to return an image if you don't specify a position.

Reimplemented in lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::WarpedPsf, and lsst::meas::algorithms::KernelPsf.

boost::shared_ptr< math::Kernel const > lsst::afw::detection::Psf::getLocalKernel ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color() 
) const

Return a FixedKernel corresponding to the Psf image at the given point.

This is implemented by calling computeKernelImage, and is simply provided for convenience.

static geom::Point2D lsst::afw::detection::Psf::makeNullPoint ( )
inlinestaticprivate

Definition at line 71 of file Psf.h.

71  {
72  return geom::Point2D(std::numeric_limits<double>::quiet_NaN());
73  }
Point< double, 2 > Point2D
Definition: Point.h:286
static boost::shared_ptr< Image > lsst::afw::detection::Psf::recenterKernelImage ( boost::shared_ptr< Image im,
geom::Point2D const &  position,
std::string const &  warpAlgorithm = "lanczos5",
unsigned int  warpBuffer = 5 
)
static

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.

warpAlgorithm is passed to afw::math::makeWarpingKernel() and can be "nearest", "bilinear", or "lanczosN"

warpBuffer zero-pads the image before recentering. Recommended value is 1 for bilinear, N for lanczosN (note that it would be cleaner to infer this value from the warping algorithm but this would require mild API changes; same issue occurs in e.g. afw::math::offsetImage()).

The point with integer coordinates (0,0) in the source image (with xy0 taken into account) corresponds to the point position in the destination image. If position is not integer-valued then we will need to fractionally shift the image using interpolation.

Note: if fractional recentering is performed, then a new image will be allocated and returned. If not, then the original image will be returned (after setting XY0).

Member Data Documentation

boost::shared_ptr< Image > lsst::afw::detection::Psf::_cachedImage
mutableprivate

Definition at line 288 of file Psf.h.

image::Color lsst::afw::detection::Psf::_cachedImageColor
mutableprivate

Definition at line 290 of file Psf.h.

geom::Point2D lsst::afw::detection::Psf::_cachedImagePosition
mutableprivate

Definition at line 292 of file Psf.h.

boost::shared_ptr< Image > lsst::afw::detection::Psf::_cachedKernelImage
mutableprivate

Definition at line 289 of file Psf.h.

image::Color lsst::afw::detection::Psf::_cachedKernelImageColor
mutableprivate

Definition at line 291 of file Psf.h.

geom::Point2D lsst::afw::detection::Psf::_cachedKernelImagePosition
mutableprivate

Definition at line 293 of file Psf.h.

bool const lsst::afw::detection::Psf::_isFixed
private

Definition at line 287 of file Psf.h.


The documentation for this class was generated from the following file: