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 Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | 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::daf::base::Citizen lsst::daf::base::Persistable lsst::afw::table::io::PersistableFacade< Psf > lsst::afw::table::io::Persistable

Public Member Functions

 WarpedPsf (boost::shared_ptr< afw::detection::Psf const > undistortedPsf, boost::shared_ptr< afw::geom::XYTransform 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::XYTransform const > distortion, std::string const &kernelName="lanczos3", unsigned int cache=10000)
 
virtual afw::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::Psf
clone () const
 Polymorphic deep copy. Usually unnecessary, as Psfs are immutable. More...
 
- Public Member Functions inherited from lsst::afw::detection::Psf
virtual ~Psf ()
 
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...
 
- 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 ()
 

Protected Member Functions

virtual boost::shared_ptr
< afw::detection::Psf::Image
doComputeKernelImage (afw::geom::Point2D const &position, afw::image::Color const &color) const
 
- Protected Member Functions inherited from lsst::meas::algorithms::ImagePsf
 ImagePsf (bool isFixed=false)
 
virtual double doComputeApertureFlux (double radius, afw::geom::Point2D const &position, afw::image::Color const &color) const
 
virtual
afw::geom::ellipses::Quadrupole 
doComputeShape (afw::geom::Point2D const &position, afw::image::Color const &color) const
 
- Protected Member Functions inherited from lsst::afw::detection::Psf
 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)
 

Protected Attributes

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

Private Member Functions

void _init ()
 

Private Attributes

boost::shared_ptr
< afw::math::WarpingControl
const > 
_warpingControl
 

Additional Inherited Members

- Public Types inherited from lsst::afw::detection::Psf
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
 
- Static Public Member Functions inherited from lsst::afw::table::io::PersistableFacade< ImagePsf >
static boost::shared_ptr
< ImagePsf > 
readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static boost::shared_ptr
< ImagePsf > 
readFits (std::string const &fileName, int hdu=0)
 Read an object from a regular FITS file. More...
 
static boost::shared_ptr
< ImagePsf > 
readFits (fits::MemFileManager &manager, int hdu=0)
 Read an object from a FITS file in memory. More...
 
- Static Public Member Functions inherited from lsst::afw::detection::Psf
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 Types inherited from lsst::afw::table::io::Persistable
typedef io::OutputArchiveHandle OutputArchiveHandle
 

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 49 of file WarpedPsf.h.

Constructor & Destructor Documentation

lsst::meas::algorithms::WarpedPsf::WarpedPsf ( boost::shared_ptr< afw::detection::Psf const >  undistortedPsf,
boost::shared_ptr< afw::geom::XYTransform 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.forwardTransform(p)

Definition at line 128 of file WarpedPsf.cc.

132  :
133  ImagePsf(false),
134  _undistortedPsf(undistortedPsf),
135  _distortion(distortion),
136  _warpingControl(control)
137 {
138  _init();
139 }
boost::shared_ptr< afw::math::WarpingControl const > _warpingControl
Definition: WarpedPsf.h:92
ImagePsf(bool isFixed=false)
Definition: ImagePsf.h:40
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:87
boost::shared_ptr< afw::geom::XYTransform const > _distortion
Definition: WarpedPsf.h:88
lsst::meas::algorithms::WarpedPsf::WarpedPsf ( boost::shared_ptr< afw::detection::Psf const >  undistortedPsf,
boost::shared_ptr< afw::geom::XYTransform const >  distortion,
std::string const &  kernelName = "lanczos3",
unsigned int  cache = 10000 
)

Definition at line 141 of file WarpedPsf.cc.

146  :
147  ImagePsf(false),
148  _undistortedPsf(undistortedPsf),
149  _distortion(distortion),
150  _warpingControl(new afw::math::WarpingControl(kernelName, "", cache))
151 {
152  _init();
153 }
boost::shared_ptr< afw::math::WarpingControl const > _warpingControl
Definition: WarpedPsf.h:92
ImagePsf(bool isFixed=false)
Definition: ImagePsf.h:40
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:87
boost::shared_ptr< afw::geom::XYTransform const > _distortion
Definition: WarpedPsf.h:88

Member Function Documentation

void lsst::meas::algorithms::WarpedPsf::_init ( )
private

Definition at line 155 of file WarpedPsf.cc.

156 {
157  if (!_undistortedPsf) {
158  throw LSST_EXCEPT(
159  pex::exceptions::LogicError,
160  "Undistorted Psf passed to WarpedPsf must not be None/NULL"
161  );
162  }
163  if (!_distortion) {
164  throw LSST_EXCEPT(
165  pex::exceptions::LogicError,
166  "XYTransform passed to WarpedPsf must not be None/NULL"
167  );
168  }
169  if (!_warpingControl) {
170  throw LSST_EXCEPT(
171  pex::exceptions::LogicError,
172  "WarpingControl passed to WarpedPsf must not be None/NULL"
173  );
174  }
175 }
boost::shared_ptr< afw::math::WarpingControl const > _warpingControl
Definition: WarpedPsf.h:92
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:87
boost::shared_ptr< afw::geom::XYTransform const > _distortion
Definition: WarpedPsf.h:88
boost::shared_ptr< afw::detection::Psf > lsst::meas::algorithms::WarpedPsf::clone ( void  ) const
virtual

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

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

Definition at line 181 of file WarpedPsf.cc.

181  {
182  return boost::make_shared<WarpedPsf>(_undistortedPsf->clone(), _distortion->clone(), _warpingControl);
183 }
boost::shared_ptr< afw::math::WarpingControl const > _warpingControl
Definition: WarpedPsf.h:92
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:87
boost::shared_ptr< afw::geom::XYTransform const > _distortion
Definition: WarpedPsf.h:88
boost::shared_ptr< afw::detection::Psf::Image > lsst::meas::algorithms::WarpedPsf::doComputeKernelImage ( afw::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 185 of file WarpedPsf.cc.

187  {
188  afw::geom::AffineTransform t = _distortion->linearizeReverseTransform(position);
189  afw::geom::Point2D tp = t(position);
190 
191  PTR(Image) im = _undistortedPsf->computeKernelImage(tp, color);
192 
193  // Go to the warped coordinate system with 'p' at the origin
194  PTR(afw::detection::Psf::Psf::Image) ret
195  = warpAffine(*im, afw::geom::AffineTransform(t.invert().getLinear()), *_warpingControl);
196 
197  double normFactor = 1.0;
198  //
199  // Normalize the output image to sum 1
200  // FIXME defining a member function Image::getSum() would be convenient here and in other places
201  //
202  normFactor = 0.0;
203  for (int y = 0; y != ret->getHeight(); ++y) {
204  afw::detection::Psf::Image::x_iterator imEnd = ret->row_end(y);
205  for (afw::detection::Psf::Image::x_iterator imPtr = ret->row_begin(y); imPtr != imEnd; imPtr++) {
206  normFactor += *imPtr;
207  }
208  }
209  if (normFactor == 0.0) {
210  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "psf image has sum 0");
211  }
212  *ret /= normFactor;
213  return ret;
214 }
int y
boost::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.
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
Definition: saturated.cc:82
boost::shared_ptr< afw::math::WarpingControl const > _warpingControl
Definition: WarpedPsf.h:92
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: Image.h:151
#define PTR(...)
Definition: base.h:41
Point< double, 2 > Point2D
Definition: Point.h:286
Psf(bool isFixed=false)
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:87
image::Image< Pixel > Image
Image type returned by computeImage.
Definition: Psf.h:79
boost::shared_ptr< afw::geom::XYTransform const > _distortion
Definition: WarpedPsf.h:88
afw::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 177 of file WarpedPsf.cc.

177  {
178  return _distortion->forwardTransform(_undistortedPsf->getAveragePosition());
179 }
boost::shared_ptr< afw::detection::Psf const > _undistortedPsf
Definition: WarpedPsf.h:87
boost::shared_ptr< afw::geom::XYTransform const > _distortion
Definition: WarpedPsf.h:88

Member Data Documentation

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

Definition at line 88 of file WarpedPsf.h.

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

Definition at line 87 of file WarpedPsf.h.

boost::shared_ptr< afw::math::WarpingControl const> lsst::meas::algorithms::WarpedPsf::_warpingControl
private

Definition at line 92 of file WarpedPsf.h.


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