lsst.afw  14.0-42-g99f9a3040+1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | List of all members
lsst::afw::detection::GaussianPsf Class Reference

A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purposes. More...

#include <GaussianPsf.h>

Inheritance diagram for lsst::afw::detection::GaussianPsf:
lsst::afw::table::io::PersistableFacade< GaussianPsf > lsst::afw::detection::Psf lsst::daf::base::Citizen lsst::daf::base::Persistable lsst::afw::table::io::PersistableFacade< Psf > lsst::afw::table::io::Persistable

Public Types

enum  ImageOwnerEnum { COPY = 0, INTERNAL = 1 }
 Enum passed to computeImage and computeKernelImage to determine image ownership. More...
 
typedef math::Kernel::Pixel Pixel
 Pixel type of Image returned by computeImage. More...
 
typedef image::Image< Pixel > Image
 Image type returned by computeImage. More...
 
typedef unsigned long memId
 
typedef memId(* memNewCallback) (const memId cid)
 
typedef memId(* memCallback) (const Citizen *ptr)
 
typedef std::shared_ptr< Persistable > Ptr
 

Public Member Functions

 GaussianPsf (int width, int height, double sigma)
 Constructor for a GaussianPsf. More...
 
 GaussianPsf (geom::Extent2I const &dimensions, double sigma)
 Constructor for a GaussianPsf. More...
 
 ~GaussianPsf ()
 
 GaussianPsf (GaussianPsf const &)
 
 GaussianPsf (GaussianPsf &&)
 
GaussianPsf & operator= (GaussianPsf const &)=delete
 
GaussianPsf & operator= (GaussianPsf &&)=delete
 
virtual std::shared_ptr< afw::detection::Psf > clone () const
 Polymorphic deep copy; should usually be unnecessary because Psfs are immutable. More...
 
virtual std::shared_ptr< afw::detection::Psf > resized (int width, int height) const
 Return a clone with specified kernel dimensions. More...
 
geom::Extent2I getDimensions () const
 Return the dimensions of the images returned by computeImage() More...
 
double getSigma () const
 Return the radius of the Gaussian. More...
 
virtual bool isPersistable () const
 Whether the Psf is persistable; always true. More...
 
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. More...
 
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. 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...
 
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. 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...
 
geom::Box2I computeBBox (geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
 Return the bounding box of the image returned by computeKernelImage() More...
 
std::string repr () const
 
void markPersistent (void)
 
memId getId () const
 
void serialize (Archive &, unsigned int const)
 
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...
 

Static Public Member Functions

static std::shared_ptr< GaussianPsf > readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< GaussianPsf > readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< GaussianPsf > readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
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. More...
 
static bool hasBeenCorrupted ()
 
static memId getNextMemId ()
 
static int init ()
 
static int census (int, memId startingMemId=0)
 
static void census (std::ostream &stream, memId startingMemId=0)
 
static const std::vector< const Citizen *> * census ()
 
static int census (int, memId startingMemId=0)
 
static void census (std::ostream &stream, memId startingMemId=0)
 
static const std::vector< const Citizen *> * census ()
 
static memId setNewCallbackId (memId id)
 
static memId setNewCallbackId (memId id)
 
static memId setDeleteCallbackId (memId id)
 
static memId setDeleteCallbackId (memId id)
 
static memNewCallback setNewCallback (memNewCallback func)
 
static memCallback setDeleteCallback (memCallback func)
 
static memCallback setCorruptionCallback (memCallback func)
 
static std::shared_ptr< Psf > readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< Psf > readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< Psf > readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 

Public Attributes

 magicSentinel
 

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Protected Member Functions

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...
 

Detailed Description

A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purposes.

This class is essentially an alternate implementation of meas::algorithms::SingleGaussianPsf; While SingleGaussianPsf inherits from ImagePsf and KernelPsf, and hence delegates to those various operations relating to the PSF model image (e.g. computeShape()), GaussianPsf computes these analytically.

Definition at line 43 of file GaussianPsf.h.

Member Typedef Documentation

◆ Image

Image type returned by computeImage.

Definition at line 78 of file Psf.h.

◆ OutputArchiveHandle

typedef io::OutputArchiveHandle lsst::afw::table::io::Persistable::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

◆ Pixel

Pixel type of Image returned by computeImage.

Definition at line 77 of file Psf.h.

Member Enumeration Documentation

◆ ImageOwnerEnum

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 81 of file Psf.h.

Constructor & Destructor Documentation

◆ GaussianPsf() [1/4]

lsst::afw::detection::GaussianPsf::GaussianPsf ( int  width,
int  height,
double  sigma 
)

Constructor for a GaussianPsf.

Parameters
[in]widthNumber of columns in realizations of the PSF at a point.
[in]heightNumber of rows in realizations of the PSF at a point.
[in]sigmaRadius of the Gaussian.

Definition at line 96 of file GaussianPsf.cc.

◆ GaussianPsf() [2/4]

lsst::afw::detection::GaussianPsf::GaussianPsf ( geom::Extent2I const &  dimensions,
double  sigma 
)

Constructor for a GaussianPsf.

Parameters
[in]dimensionsNumber of columns, rows in realizations of the PSF at a point.
[in]sigmaRadius of the Gaussian.

Definition at line 101 of file GaussianPsf.cc.

◆ ~GaussianPsf()

lsst::afw::detection::GaussianPsf::~GaussianPsf ( )
default

◆ GaussianPsf() [3/4]

lsst::afw::detection::GaussianPsf::GaussianPsf ( GaussianPsf const &  )
default

◆ GaussianPsf() [4/4]

lsst::afw::detection::GaussianPsf::GaussianPsf ( GaussianPsf &&  )
default

Member Function Documentation

◆ clone()

std::shared_ptr< afw::detection::Psf > lsst::afw::detection::GaussianPsf::clone ( void  ) const
virtual

Polymorphic deep copy; should usually be unnecessary because Psfs are immutable.

Implements lsst::afw::detection::Psf.

Definition at line 110 of file GaussianPsf.cc.

◆ computeApertureFlux()

double lsst::afw::detection::Psf::computeApertureFlux ( double  radius,
geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color() 
) const
inherited

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.

◆ computeBBox()

geom::Box2I lsst::afw::detection::Psf::computeBBox ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color() 
) const
inherited

Return the bounding box of the image returned by computeKernelImage()

◆ computeImage()

std::shared_ptr<Image> lsst::afw::detection::Psf::computeImage ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color(),
ImageOwnerEnum  owner = COPY 
) const
inherited

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.

◆ computeKernelImage()

std::shared_ptr<Image> lsst::afw::detection::Psf::computeKernelImage ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color(),
ImageOwnerEnum  owner = COPY 
) const
inherited

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.

◆ computePeak()

double lsst::afw::detection::Psf::computePeak ( geom::Point2D  position = makeNullPoint(),
image::Color  color = image::Color() 
) const
inherited

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).

◆ computeShape()

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

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.

◆ getAverageColor()

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

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.

◆ getAveragePosition()

virtual geom::Point2D lsst::afw::detection::Psf::getAveragePosition ( ) const
virtualinherited

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.

◆ getDimensions()

geom::Extent2I lsst::afw::detection::GaussianPsf::getDimensions ( ) const
inline

Return the dimensions of the images returned by computeImage()

Definition at line 75 of file GaussianPsf.h.

◆ getLocalKernel()

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

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

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

◆ getPersistenceName()

std::string lsst::afw::detection::GaussianPsf::getPersistenceName ( ) const
protectedvirtual

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 118 of file GaussianPsf.cc.

◆ getPythonModule()

std::string lsst::afw::detection::GaussianPsf::getPythonModule ( ) const
protectedvirtual

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 120 of file GaussianPsf.cc.

◆ getSigma()

double lsst::afw::detection::GaussianPsf::getSigma ( ) const
inline

Return the radius of the Gaussian.

Definition at line 78 of file GaussianPsf.h.

◆ isPersistable()

virtual bool lsst::afw::detection::GaussianPsf::isPersistable ( ) const
inlinevirtual

Whether the Psf is persistable; always true.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 81 of file GaussianPsf.h.

◆ operator=() [1/2]

GaussianPsf& lsst::afw::detection::GaussianPsf::operator= ( GaussianPsf const &  )
delete

◆ operator=() [2/2]

GaussianPsf& lsst::afw::detection::GaussianPsf::operator= ( GaussianPsf &&  )
delete

◆ readFits() [1/6]

static std::shared_ptr<GaussianPsf > lsst::afw::table::io::PersistableFacade< GaussianPsf >::readFits ( fits::Fits &  fitsfile)
inlinestaticinherited

Read an object from an already open FITS object.

Parameters
[in]fitsfileFITS object to read from, already positioned at the desired HDU.

Definition at line 183 of file Persistable.h.

◆ readFits() [2/6]

static std::shared_ptr<Psf > lsst::afw::table::io::PersistableFacade< Psf >::readFits ( fits::Fits &  fitsfile)
inlinestaticinherited

Read an object from an already open FITS object.

Parameters
[in]fitsfileFITS object to read from, already positioned at the desired HDU.

Definition at line 183 of file Persistable.h.

◆ readFits() [3/6]

static std::shared_ptr<Psf > lsst::afw::table::io::PersistableFacade< Psf >::readFits ( std::string const &  fileName,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a regular FITS file.

Parameters
[in]fileNameName of the file to read.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 194 of file Persistable.h.

◆ readFits() [4/6]

static std::shared_ptr<GaussianPsf > lsst::afw::table::io::PersistableFacade< GaussianPsf >::readFits ( std::string const &  fileName,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a regular FITS file.

Parameters
[in]fileNameName of the file to read.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 194 of file Persistable.h.

◆ readFits() [5/6]

static std::shared_ptr<Psf > lsst::afw::table::io::PersistableFacade< Psf >::readFits ( fits::MemFileManager &  manager,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a FITS file in memory.

Parameters
[in]managerManager for the memory to read from.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 205 of file Persistable.h.

◆ readFits() [6/6]

static std::shared_ptr<GaussianPsf > lsst::afw::table::io::PersistableFacade< GaussianPsf >::readFits ( fits::MemFileManager &  manager,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a FITS file in memory.

Parameters
[in]managerManager for the memory to read from.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 205 of file Persistable.h.

◆ recenterKernelImage()

static std::shared_ptr<Image> lsst::afw::detection::Psf::recenterKernelImage ( std::shared_ptr< Image >  im,
geom::Point2D const &  position,
std::string const &  warpAlgorithm = "lanczos5",
unsigned int  warpBuffer = 5 
)
staticinherited

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).

◆ resized()

std::shared_ptr< afw::detection::Psf > lsst::afw::detection::GaussianPsf::resized ( int  width,
int  height 
) const
virtual

Return a clone with specified kernel dimensions.

Implements lsst::afw::detection::Psf.

Definition at line 114 of file GaussianPsf.cc.

◆ write()

void lsst::afw::detection::GaussianPsf::write ( OutputArchiveHandle &  handle) const
protectedvirtual

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 122 of file GaussianPsf.cc.

◆ writeFits() [1/3]

void lsst::afw::table::io::Persistable::writeFits ( std::string const &  fileName,
std::string const &  mode = "w" 
) const
inherited

Write the object to a regular FITS file.

Parameters
[in]fileNameName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

◆ writeFits() [2/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::MemFileManager &  manager,
std::string const &  mode = "w" 
) const
inherited

Write the object to a FITS image in memory.

Parameters
[in]managerName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

◆ writeFits() [3/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::Fits &  fitsfile) const
inherited

Write the object to an already-open FITS object.

Parameters
[in]fitsfileOpen FITS object to write to.

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