LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Related Functions | List of all members
lsst::meas::algorithms::WarpedPsf Class Reference

A Psf class that maps an arbitrary Psf through a coordinate transformation. More...

#include <WarpedPsf.h>

Inheritance diagram for lsst::meas::algorithms::WarpedPsf:
lsst::meas::algorithms::ImagePsf lsst::afw::table::io::PersistableFacade< ImagePsf > lsst::afw::detection::Psf lsst::afw::table::io::PersistableFacade< Psf > lsst::afw::typehandling::Storable 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< PixelImage
 Image type returned by computeImage. More...
 

Public Member Functions

 WarpedPsf (boost::shared_ptr< afw::detection::Psf const > undistortedPsf, boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > distortion, boost::shared_ptr< afw::math::WarpingControl const > control)
 Construct WarpedPsf from unwarped psf and distortion. More...
 
 WarpedPsf (boost::shared_ptr< afw::detection::Psf const > undistortedPsf, boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > distortion, std::string const &kernelName="lanczos3", unsigned int cache=10000)
 
virtual geom::Point2D getAveragePosition () const
 Return the average of the positions of the stars that went into this Psf. More...
 
virtual boost::shared_ptr< afw::detection::Psfclone () const
 Polymorphic deep copy. Usually unnecessary, as Psfs are immutable. More...
 
virtual boost::shared_ptr< afw::detection::Psfresized (int width, int height) const
 Return a clone with specified kernel dimensions. More...
 
std::shared_ptr< typehandling::Storable > cloneStorable () const override
 Polymorphic deep-copy. More...
 
std::shared_ptr< ImagecomputeImage (lsst::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< ImagecomputeKernelImage (lsst::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 (lsst::geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
 Return the peak value of the PSF image. More...
 
double computeApertureFlux (double radius, lsst::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 (lsst::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 (lsst::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...
 
lsst::geom::Box2I computeBBox (lsst::geom::Point2D position=makeNullPoint(), image::Color color=image::Color()) const
 Return the bounding box of the image returned by computeKernelImage() More...
 
std::size_t getCacheCapacity () const
 Return the capacity of the caches. More...
 
void setCacheCapacity (std::size_t capacity)
 Set the capacity of the caches. More...
 
virtual std::string toString () const
 Create a string representation of this object (optional operation). More...
 
virtual std::size_t hash_value () const
 Return a hash of this object (optional operation). More...
 
virtual bool equals (Storable const &other) const noexcept
 Compare this object to another Storable. More...
 
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 noexcept
 Return true if this particular object can be persisted using afw::table::io. More...
 

Static Public Member Functions

static std::shared_ptr< ImagePsfreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< ImagePsfreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< ImagePsfreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< PsfreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< PsfreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< PsfreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< ImagePsfdynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr. More...
 
static std::shared_ptr< PsfdynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr. More...
 
static std::shared_ptr< ImagerecenterKernelImage (std::shared_ptr< Image > im, lsst::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...
 

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Protected Member Functions

virtual boost::shared_ptr< afw::detection::Psf::ImagedoComputeKernelImage (geom::Point2D const &position, afw::image::Color const &color) const
 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. More...
 
virtual double doComputeApertureFlux (double radius, geom::Point2D const &position, afw::image::Color const &color) const
 
virtual afw::geom::ellipses::Quadrupole doComputeShape (geom::Point2D const &position, afw::image::Color const &color) const
 
virtual std::shared_ptr< ImagedoComputeImage (lsst::geom::Point2D const &position, image::Color const &color) const
 This virtual member is protected (rather than private) so that python-implemented derived classes may opt to use the default implementation. More...
 
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...
 

Static Protected Member Functions

template<class T >
static bool singleClassEquals (T const &lhs, Storable const &rhs)
 Test if a Storable is of a particular class and equal to another object. More...
 

Protected Attributes

boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
 
boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > _distortion
 

Related Functions

(Note that these are not member functions.)

std::ostreamoperator<< (std::ostream &os, Storable const &storable)
 Output operator for Storable. More...
 

Detailed Description

A Psf class that maps an arbitrary Psf through a coordinate transformation.

If K_0(x,x') is the unwarped PSF, and f is the coordinate transform, then the warped PSF is defined by

K(f(x),f(x')) = K_0(x,x') (*)

We linearize the coordinate transform in the vicinity of the point where the PSF is computed. The definition (*) does not include the Jacobian of the transformation, since the afw convention is that PSF's are normalized to have integral 1 anyway.

Definition at line 50 of file WarpedPsf.h.

Member Typedef Documentation

◆ Image

Image type returned by computeImage.

Definition at line 83 of file Psf.h.

◆ OutputArchiveHandle

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

Definition at line 108 of file Persistable.h.

◆ Pixel

typedef math::Kernel::Pixel lsst::afw::detection::Psf::Pixel
inherited

Pixel type of Image returned by computeImage.

Definition at line 82 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 86 of file Psf.h.

86  {
87  COPY = 0,
88  INTERNAL = 1
92  };

Constructor & Destructor Documentation

◆ WarpedPsf() [1/2]

lsst::meas::algorithms::WarpedPsf::WarpedPsf ( boost::shared_ptr< afw::detection::Psf const >  undistortedPsf,
boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const >  distortion,
boost::shared_ptr< afw::math::WarpingControl const >  control 
)

Construct WarpedPsf from unwarped psf and distortion.

If p is the nominal pixel position, and p' is the true position on the sky, then our convention for the transform is that p' = distortion.applyForward(p)

Definition at line 138 of file WarpedPsf.cc.

141  : ImagePsf(false),
142  _undistortedPsf(undistortedPsf),
143  _distortion(distortion),
144  _warpingControl(control) {
145  _init();
146 }

◆ WarpedPsf() [2/2]

lsst::meas::algorithms::WarpedPsf::WarpedPsf ( boost::shared_ptr< afw::detection::Psf const >  undistortedPsf,
boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const >  distortion,
std::string const &  kernelName = "lanczos3",
unsigned int  cache = 10000 
)

Definition at line 148 of file WarpedPsf.cc.

151  : ImagePsf(false),
152  _undistortedPsf(undistortedPsf),
153  _distortion(distortion),
154  _warpingControl(new afw::math::WarpingControl(kernelName, "", cache)) {
155  _init();
156 }

Member Function Documentation

◆ clone()

boost::shared_ptr< afw::detection::Psf > lsst::meas::algorithms::WarpedPsf::clone ( ) const
virtual

Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.

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

Definition at line 176 of file WarpedPsf.cc.

176  {
177  return std::make_shared<WarpedPsf>(_undistortedPsf->clone(), _distortion, _warpingControl);
178 }

◆ cloneStorable()

std::shared_ptr<typehandling::Storable> lsst::afw::detection::Psf::cloneStorable ( ) const
inlineoverridevirtualinherited

Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.

This method is an alias of clone that can be called from a reference to Storable.

Reimplemented from lsst::afw::typehandling::Storable.

Definition at line 116 of file Psf.h.

116 { return clone(); }

◆ computeApertureFlux()

double Psf::computeApertureFlux ( double  radius,
lsst::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.

Definition at line 150 of file Psf.cc.

150  {
151  if (isPointNull(position)) position = getAveragePosition();
152  if (color.isIndeterminate()) color = getAverageColor();
153  return doComputeApertureFlux(radius, position, color);
154 }

◆ computeBBox()

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

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

Definition at line 128 of file Psf.cc.

128  {
129  if (isPointNull(position)) position = getAveragePosition();
130  if (color.isIndeterminate()) color = getAverageColor();
131  return doComputeBBox(position, color);
132 }

◆ computeImage()

std::shared_ptr< Psf::Image > Psf::computeImage ( lsst::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.

Definition at line 102 of file Psf.cc.

103  {
104  if (isPointNull(position)) position = getAveragePosition();
105  if (color.isIndeterminate()) color = getAverageColor();
106  std::shared_ptr<Psf::Image> result = (*_imageCache)(
107  detail::PsfCacheKey(position, color),
108  [this](detail::PsfCacheKey const &key) { return doComputeImage(key.position, key.color); });
109  if (owner == COPY) {
110  result = std::make_shared<Image>(*result, true);
111  }
112  return result;
113 }

◆ computeKernelImage()

std::shared_ptr< Psf::Image > Psf::computeKernelImage ( lsst::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.

Definition at line 115 of file Psf.cc.

116  {
117  if (_isFixed || isPointNull(position)) position = getAveragePosition();
118  if (_isFixed || color.isIndeterminate()) color = getAverageColor();
119  std::shared_ptr<Psf::Image> result = (*_kernelImageCache)(
120  detail::PsfCacheKey(position, color),
121  [this](detail::PsfCacheKey const &key) { return doComputeKernelImage(key.position, key.color); });
122  if (owner == COPY) {
123  result = std::make_shared<Image>(*result, true);
124  }
125  return result;
126 }

◆ computePeak()

double Psf::computePeak ( lsst::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).

Definition at line 143 of file Psf.cc.

143  {
144  if (isPointNull(position)) position = getAveragePosition();
145  if (color.isIndeterminate()) color = getAverageColor();
147  return (*image)(-image->getX0(), -image->getY0());
148 }

◆ computeShape()

geom::ellipses::Quadrupole Psf::computeShape ( lsst::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.

Definition at line 156 of file Psf.cc.

156  {
157  if (isPointNull(position)) position = getAveragePosition();
158  if (color.isIndeterminate()) color = getAverageColor();
159  return doComputeShape(position, color);
160 }

◆ doComputeApertureFlux()

double lsst::meas::algorithms::ImagePsf::doComputeApertureFlux ( double  radius,
geom::Point2D const &  position,
afw::image::Color const &  color 
) const
protectedvirtualinherited

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

Definition at line 45 of file ImagePsf.cc.

46  {
47  afw::image::Image<double> const& image(*computeKernelImage(position, color, INTERNAL));
48 
49  geom::Point2D const center(0.0, 0.0);
50  afw::geom::ellipses::Axes const axes(radius, radius);
51  base::ApertureFluxResult result = base::ApertureFluxAlgorithm::computeSincFlux(
52  image, afw::geom::ellipses::Ellipse(axes, center), base::ApertureFluxControl());
53  return result.instFlux;
54 }

◆ doComputeImage()

std::shared_ptr< Psf::Image > Psf::doComputeImage ( lsst::geom::Point2D const &  position,
image::Color const &  color 
) const
protectedvirtualinherited

This virtual member is protected (rather than private) so that python-implemented derived classes may opt to use the default implementation.

C++ derived classes may override this method, but should not call it.

Definition at line 162 of file Psf.cc.

163  {
164  std::shared_ptr<Psf::Image> im = computeKernelImage(position, color, COPY);
165  return recenterKernelImage(im, position);
166 }

◆ doComputeKernelImage()

boost::shared_ptr< afw::detection::Psf::Image > lsst::meas::algorithms::WarpedPsf::doComputeKernelImage ( geom::Point2D const &  position,
afw::image::Color const &  color 
) const
protectedvirtual

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.

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

Definition at line 188 of file WarpedPsf.cc.

188  {
190  geom::Point2D tp = t(position);
191 
192  PTR(Image) im = _undistortedPsf->computeKernelImage(tp, color);
193 
194  // Go to the warped coordinate system with 'p' at the origin
195  auto srcToDest = geom::AffineTransform(t.inverted().getLinear());
196  PTR(afw::detection::Psf::Psf::Image) ret = warpAffine(*im, srcToDest, *_warpingControl);
197 
198  double normFactor = 1.0;
199  //
200  // Normalize the output image to sum 1
201  // FIXME defining a member function Image::getSum() would be convenient here and in other places
202  //
203  normFactor = 0.0;
204  for (int y = 0; y != ret->getHeight(); ++y) {
205  afw::detection::Psf::Image::x_iterator imEnd = ret->row_end(y);
206  for (afw::detection::Psf::Image::x_iterator imPtr = ret->row_begin(y); imPtr != imEnd; imPtr++) {
207  normFactor += *imPtr;
208  }
209  }
210  if (normFactor == 0.0) {
211  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "psf image has sum 0");
212  }
213  *ret /= normFactor;
214  return ret;
215 }

◆ doComputeShape()

afw::geom::ellipses::Quadrupole lsst::meas::algorithms::ImagePsf::doComputeShape ( geom::Point2D const &  position,
afw::image::Color const &  color 
) const
protectedvirtualinherited

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

Definition at line 56 of file ImagePsf.cc.

57  {
58  PTR(Image) image = computeKernelImage(position, color, INTERNAL);
60  *image, geom::Point2D(0.0, 0.0) // image has origin at the center
61  )
62  .getShape();
63 }

◆ dynamicCast() [1/2]

Dynamically cast a shared_ptr.

Dynamically cast a shared pointer and raise on failure.

You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;

Exceptions
lsst::pex::exceptions::LogicErrorif the cast fails

param[in] ptr The pointer to be cast.

Returns
The cast pointer.
Exceptions
lsst::pex::exceptions::TypeErrorIf the dynamic cast fails.

Definition at line 218 of file Persistable.cc.

18  {
19  auto result = std::dynamic_pointer_cast<T>(ptr);
20  if (!result) {
21  throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22  }
23  return result;
24 }

◆ dynamicCast() [2/2]

Dynamically cast a shared_ptr.

Dynamically cast a shared pointer and raise on failure.

You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;

Exceptions
lsst::pex::exceptions::LogicErrorif the cast fails

param[in] ptr The pointer to be cast.

Returns
The cast pointer.
Exceptions
lsst::pex::exceptions::TypeErrorIf the dynamic cast fails.

Definition at line 218 of file Persistable.cc.

18  {
19  auto result = std::dynamic_pointer_cast<T>(ptr);
20  if (!result) {
21  throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22  }
23  return result;
24 }

◆ equals()

bool lsst::afw::typehandling::Storable::equals ( Storable const &  other) const
virtualnoexceptinherited

Compare this object to another Storable.

Subclasses that implement equality comparison must override this method to give results consistent with operator== for all inputs that are accepted by both.

Returns
This implementation returns whether the two objects are the same.
Warning
This method compares an object to any type of Storable, although cross-class comparisons should usually return false. If cross-class comparisons are valid, implementers should take care that they are symmetric and will give the same result no matter what the compile-time types of the left- and right-hand sides are.
See also
singleClassEquals
Note
When called on Python classes, this method delegates to __eq__ if it exists.

Reimplemented in lsst::afw::image::PhotoCalib, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, lsst::afw::image::Filter, lsst::afw::image::VisitInfo, and lsst::afw::typehandling::StorableHelper< Base >.

Definition at line 48 of file Storable.cc.

48 { return this == &other; }

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

233 { return image::Color(); }

◆ getAveragePosition()

geom::Point2D lsst::meas::algorithms::WarpedPsf::getAveragePosition ( ) const
virtual

Return the average of the positions of the stars that went into this Psf.

For WarpedPsf, this is just the transform of the undistorted Psf's average position.

Reimplemented from lsst::afw::detection::Psf.

Definition at line 172 of file WarpedPsf.cc.

172  {
173  return _distortion->applyForward(_undistortedPsf->getAveragePosition());
174 }

◆ getCacheCapacity()

std::size_t Psf::getCacheCapacity ( ) const
inherited

Return the capacity of the caches.

Both the image and kernel image caches have the same capacity.

Definition at line 170 of file Psf.cc.

170 { return _kernelImageCache->capacity(); }

◆ getLocalKernel()

std::shared_ptr< math::Kernel const > Psf::getLocalKernel ( lsst::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.

Definition at line 134 of file Psf.cc.

135  {
136  if (isPointNull(position)) position = getAveragePosition();
137  if (color.isIndeterminate()) color = getAverageColor();
138  // FixedKernel ctor will deep copy image, so we can use INTERNAL.
140  return std::make_shared<math::FixedKernel>(*image);
141 }

◆ getPersistenceName()

std::string lsst::afw::table::io::Persistable::getPersistenceName ( ) const
protectedvirtualinherited

◆ getPythonModule()

std::string lsst::afw::table::io::Persistable::getPythonModule ( ) const
protectedvirtualinherited

◆ hash_value()

std::size_t lsst::afw::typehandling::Storable::hash_value ( ) const
virtualinherited

Return a hash of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object is not hashable.
Note
C++ subclass authors are responsible for any associated specializations of std::hash.
When called on Python classes, this method delegates to __hash__ if it exists.

Reimplemented in lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::image::Filter, lsst::afw::geom::polygon::Polygon, lsst::afw::image::VisitInfo, and lsst::afw::image::FilterLabel.

Definition at line 44 of file Storable.cc.

44  {
45  throw LSST_EXCEPT(UnsupportedOperationException, "Hashes are not supported.");
46 }

◆ isPersistable()

virtual bool lsst::afw::table::io::Persistable::isPersistable ( ) const
inlinevirtualnoexceptinherited

◆ readFits() [1/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.

183  {
184  return dynamicCast(Persistable::_readFits(fitsfile));
185  }

◆ readFits() [2/6]

static std::shared_ptr<ImagePsf > lsst::afw::table::io::PersistableFacade< ImagePsf >::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.

183  {
184  return dynamicCast(Persistable::_readFits(fitsfile));
185  }

◆ readFits() [3/6]

static std::shared_ptr<ImagePsf > lsst::afw::table::io::PersistableFacade< ImagePsf >::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.

205  {
206  return dynamicCast(Persistable::_readFits(manager, hdu));
207  }

◆ readFits() [4/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.

205  {
206  return dynamicCast(Persistable::_readFits(manager, hdu));
207  }

◆ readFits() [5/6]

static std::shared_ptr<ImagePsf > lsst::afw::table::io::PersistableFacade< ImagePsf >::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.

194  {
195  return dynamicCast(Persistable::_readFits(fileName, hdu));
196  }

◆ readFits() [6/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.

194  {
195  return dynamicCast(Persistable::_readFits(fileName, hdu));
196  }

◆ recenterKernelImage()

std::shared_ptr< image::Image< double > > Psf::recenterKernelImage ( std::shared_ptr< Image im,
lsst::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).

Definition at line 86 of file Psf.cc.

89  {
90  // "ir" : (integer, residual)
91  std::pair<int, double> const irX = image::positionToIndex(position.getX(), true);
92  std::pair<int, double> const irY = image::positionToIndex(position.getY(), true);
93 
94  if (irX.second != 0.0 || irY.second != 0.0) {
95  im = math::offsetImage(*im, irX.second, irY.second, warpAlgorithm, warpBuffer);
96  }
97 
98  im->setXY0(irX.first + im->getX0(), irY.first + im->getY0());
99  return im;
100 }

◆ resized()

boost::shared_ptr< afw::detection::Psf > lsst::meas::algorithms::WarpedPsf::resized ( int  width,
int  height 
) const
virtual

Return a clone with specified kernel dimensions.

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

Definition at line 180 of file WarpedPsf.cc.

180  {
181  // For a given set of requested dimensions and distortion, it is not guaranteed that a
182  // _undistortedPsf would exist to manifest those dimensions after distortion
183  // Not possible to implement with member data currently in WarpedPsf
184  throw LSST_EXCEPT(pex::exceptions::LogicError, "Not Implemented");
185 }

◆ setCacheCapacity()

void Psf::setCacheCapacity ( std::size_t  capacity)
inherited

Set the capacity of the caches.

Both the image and kernel image caches will be set to this capacity.

Definition at line 172 of file Psf.cc.

172  {
173  _imageCache->reserve(capacity);
174  _kernelImageCache->reserve(capacity);
175 }

◆ singleClassEquals()

template<class T >
static bool lsst::afw::typehandling::Storable::singleClassEquals ( T const &  lhs,
Storable const &  rhs 
)
inlinestaticprotectedinherited

Test if a Storable is of a particular class and equal to another object.

This method template simplifies implementations of equals that delegate to operator== without supporting cross-class comparisons.

Template Parameters
TThe class expected of the two objects to be compared.
Parameters
lhs,rhsThe objects to compare. Note that rhs need not be a T, while lhs must be.
Returns
true if rhs is a T and lhs == rhs; false otherwise.
Exception Safety
Provides the same level of exception safety as operator==. Most implementations of operator== do not throw.
Note
This method template calls operator== with both arguments of compile-time type T const&. Its use is not recommended if there would be any ambiguity as to which operator== gets picked by overload resolution.

This method template is typically called from equals as:

bool MyType::equals(Storable const& other) const noexcept {
    return singleClassEquals(*this, other);
}

Definition at line 151 of file Storable.h.

151  {
152  auto typedRhs = dynamic_cast<T const*>(&rhs);
153  if (typedRhs != nullptr) {
154  return lhs == *typedRhs;
155  } else {
156  return false;
157  }
158  }

◆ toString()

std::string lsst::afw::typehandling::Storable::toString ( ) const
virtualinherited

Create a string representation of this object (optional operation).

Exceptions
UnsupportedOperationExceptionThrown if this object does not have a string representation.
Note
When called on Python classes, this method delegates to __repr__.

Reimplemented in lsst::afw::image::PhotoCalib, lsst::afw::geom::SkyWcs, lsst::afw::geom::polygon::Polygon, lsst::afw::image::VisitInfo, lsst::afw::image::FilterLabel, and lsst::afw::typehandling::StorableHelper< Base >.

Definition at line 40 of file Storable.cc.

40  {
41  throw LSST_EXCEPT(UnsupportedOperationException, "No string representation available.");
42 }

◆ write()

void lsst::afw::table::io::Persistable::write ( OutputArchiveHandle handle) const
protectedvirtualinherited

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 in lsst::afw::image::FilterLabel, lsst::afw::math::LinearCombinationKernel, lsst::afw::math::DeltaFunctionKernel, lsst::afw::math::AnalyticKernel, lsst::afw::math::FixedKernel, lsst::afw::image::PhotoCalib, lsst::afw::geom::SkyWcs, lsst::meas::modelfit::Mixture, lsst::afw::detection::Footprint, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::polygon::Polygon, lsst::afw::image::Filter, lsst::afw::math::ChebyshevBoundedField, lsst::afw::image::VisitInfo, lsst::meas::algorithms::CoaddPsf, lsst::afw::cameraGeom::DetectorCollection, lsst::afw::cameraGeom::Camera, lsst::afw::detection::HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT >, lsst::meas::algorithms::CoaddBoundedField, lsst::afw::math::PixelAreaBoundedField, lsst::afw::image::CoaddInputs, lsst::afw::detection::GaussianPsf, lsst::afw::math::TransformBoundedField, lsst::afw::math::ProductBoundedField, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::DoubleGaussianPsf, lsst::meas::algorithms::SingleGaussianPsf, lsst::meas::extensions::psfex::PsfexPsf, lsst::afw::math::Chebyshev1Function2< ReturnT >, lsst::afw::math::PolynomialFunction2< ReturnT >, lsst::afw::math::DoubleGaussianFunction2< ReturnT >, and lsst::afw::math::GaussianFunction2< ReturnT >.

Definition at line 38 of file Persistable.cc.

38  {
39  assert(!isPersistable());
40  throw LSST_EXCEPT(pex::exceptions::LogicError,
41  "afw::table-based persistence is not supported for this object.");
42 }

◆ writeFits() [1/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.

Definition at line 18 of file Persistable.cc.

18  {
19  OutputArchive archive;
20  archive.put(this);
21  archive.writeFits(fitsfile);
22 }

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

Definition at line 29 of file Persistable.cc.

29  {
30  fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
31  writeFits(fitsfile);
32 }

◆ writeFits() [3/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.

Definition at line 24 of file Persistable.cc.

24  {
25  fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
26  writeFits(fitsfile);
27 }

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream os,
Storable const &  storable 
)
related

Output operator for Storable.

Parameters
osthe desired output stream
storablethe object to print
Returns
a reference to os
Exceptions
UnsupportedOperationExceptionThrown if storable does not have an implementation of Storable::toString.

Definition at line 174 of file Storable.h.

174  {
175  return os << storable.toString();
176 }

Member Data Documentation

◆ _distortion

boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > lsst::meas::algorithms::WarpedPsf::_distortion
protected

Definition at line 84 of file WarpedPsf.h.

◆ _undistortedPsf

boost::shared_ptr< afw::detection::Psf const > lsst::meas::algorithms::WarpedPsf::_undistortedPsf
protected

Definition at line 83 of file WarpedPsf.h.


The documentation for this class was generated from the following files:
y
int y
Definition: SpanSet.cc:49
lsst::meas::algorithms::ImagePsf::ImagePsf
ImagePsf(bool isFixed=false)
Definition: ImagePsf.h:42
lsst::afw::detection::Psf::getAveragePosition
virtual lsst::geom::Point2D getAveragePosition() const
Return the average position of the stars used to construct the Psf.
Definition: Psf.cc:168
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::table::io::Persistable::writeFits
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.
Definition: Persistable.cc:24
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::detection::Psf::INTERNAL
@ INTERNAL
An internal image will be returned without copying.
Definition: Psf.h:88
lsst::afw::image::positionToIndex
int positionToIndex(double pos)
Convert image position to nearest integer index.
Definition: ImageUtils.h:69
std::pair
lsst::afw::detection::Psf::clone
virtual std::shared_ptr< Psf > clone() const =0
Polymorphic deep-copy.
lsst::afw::geom::linearizeTransform
lsst::geom::AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)
Approximate a Transform by its local linearization.
Definition: transformFactory.cc:132
lsst::geom::AffineTransform::inverted
AffineTransform const inverted() const
Return the inverse transform.
Definition: AffineTransform.cc:53
lsst::afw::image::Color::isIndeterminate
bool isIndeterminate() const noexcept
Whether the color is the special value that indicates that it is unspecified.
Definition: Color.h:37
lsst.pipe.tasks.processCcdWithFakes.radius
radius
Definition: processCcdWithFakes.py:345
lsst::afw::table::io::Persistable::isPersistable
virtual bool isPersistable() const noexcept
Return true if this particular object can be persisted using afw::table::io.
Definition: Persistable.h:102
PTR
#define PTR(...)
Definition: base.h:41
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
lsst::meas::base::SdssShapeAlgorithm::computeAdaptiveMoments
static Result computeAdaptiveMoments(ImageT const &image, geom::Point2D const &position, bool negative=false, Control const &ctrl=Control())
Compute the adaptive Gaussian-weighted moments of an image.
image
afw::table::Key< afw::table::Array< ImagePixelT > > image
Definition: HeavyFootprint.cc:216
lsst::afw::detection::Psf::Image
image::Image< Pixel > Image
Image type returned by computeImage.
Definition: Psf.h:83
lsst::afw::fits::Fits::AUTO_CHECK
@ AUTO_CHECK
Definition: fits.h:308
lsst::afw::fits::Fits::AUTO_CLOSE
@ AUTO_CLOSE
Definition: fits.h:307
lsst::meas::algorithms::WarpedPsf::_undistortedPsf
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:83
lsst::geom::AffineTransform::getLinear
LinearTransform const & getLinear() const noexcept
Definition: AffineTransform.h:155
other
ItemVariant const * other
Definition: Schema.cc:56
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
lsst::afw::detection::Psf::COPY
@ COPY
The image will be copied before returning; caller will own it.
Definition: Psf.h:87
result
py::object result
Definition: _schema.cc:429
lsst::afw::image::ImageBase< Pixel >::x_iterator
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: ImageBase.h:133
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::meas::base::ApertureFluxAlgorithm::computeSincFlux
static Result computeSincFlux(afw::image::Image< T > const &image, afw::geom::ellipses::Ellipse const &ellipse, Control const &ctrl=Control())
Compute the instFlux (and optionally, uncertanties) within an aperture using Sinc photometry.
Definition: ApertureFlux.cc:146
os
std::ostream * os
Definition: Schema.cc:746
lsst::afw::image::ImageBase::getX0
int getX0() const
Return the image's column-origin.
Definition: ImageBase.h:304
lsst::afw::detection::Psf::getAverageColor
image::Color getAverageColor() const
Return the average Color of the stars used to construct the Psf.
Definition: Psf.h:233
lsst::afw::table::io::PersistableFacade< Psf >::dynamicCast
static std::shared_ptr< Psf > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18
key
Key< U > key
Definition: Schema.cc:281
lsst::geom::Point< double, 2 >
lsst::afw::math::offsetImage
std::shared_ptr< ImageT > offsetImage(ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
Return an image offset by (dx, dy) using the specified algorithm.
Definition: offsetImage.cc:41
lsst::meas::base::ShapeResult::getShape
Shape const getShape() const
Return an afw::geom::ellipses object corresponding to xx, yy, xy.
Definition: ShapeUtilities.cc:41
lsst::afw::detection::Psf::recenterKernelImage
static std::shared_ptr< Image > recenterKernelImage(std::shared_ptr< Image > im, lsst::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,...
Definition: Psf.cc:86
lsst::afw::image::ImageBase::setXY0
void setXY0(lsst::geom::Point2I const origin)
Set the ImageBase's origin.
Definition: ImageBase.h:432
lsst::afw::image::ImageBase::getY0
int getY0() const
Return the image's row-origin.
Definition: ImageBase.h:312
lsst::afw::detection::Psf::computeKernelImage
std::shared_ptr< Image > computeKernelImage(lsst::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.
Definition: Psf.cc:115
lsst::afw::detection::Psf::doComputeImage
virtual std::shared_ptr< Image > doComputeImage(lsst::geom::Point2D const &position, image::Color const &color) const
This virtual member is protected (rather than private) so that python-implemented derived classes may...
Definition: Psf.cc:162
lsst::afw::image::Color
Describe the colour of a source.
Definition: Color.h:26
lsst::meas::algorithms::WarpedPsf::_distortion
boost::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > _distortion
Definition: WarpedPsf.h:84