lsst.afw  14.0-60-ga423a1d65+2
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | List of all members
lsst::afw::geom::SkyWcs Class Referencefinal

A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixels. More...

#include <SkyWcs.h>

Inheritance diagram for lsst::afw::geom::SkyWcs:
lsst::afw::table::io::PersistableFacade< SkyWcs > lsst::afw::table::io::Persistable

Public Member Functions

 SkyWcs (SkyWcs const &)=default
 
 SkyWcs (SkyWcs &&)=default
 
SkyWcs & operator= (SkyWcs const &)=delete
 
SkyWcs & operator= (SkyWcs &&)=delete
 
 ~SkyWcs ()=default
 
bool operator== (SkyWcs const &other) const
 Equality is based on the string representations being equal. More...
 
bool operator!= (SkyWcs const &other) const
 
 SkyWcs (daf::base::PropertySet &metadata, bool strip=false)
 Construct a SkyWcs from FITS keywords. More...
 
 SkyWcs (ast::FrameDict const &frameDict)
 Construct a SkyWcs from an ast::FrameDict. More...
 
std::shared_ptr< SkyWcs > copyAtShiftedPixelOrigin (Extent2D const &shift) const
 Return a copy of this SkyWcs with the pixel origin shifted by the specified amount. More...
 
std::shared_ptr< daf::base::PropertyList > getFitsMetadata (bool precise=false) const
 Return the WCS as FITS WCS metadata. More...
 
Angle getPixelScale (Point2D const &pixel) const
 Get the pixel scale at the specified pixel position. More...
 
Angle getPixelScale () const
 Get the pixel scale at the pixel origin. More...
 
Point2D getPixelOrigin () const
 Get the pixel origin, in pixels, using the LSST convention. More...
 
SpherePoint getSkyOrigin () const
 Get the sky origin, the celestial fiducial point. More...
 
Eigen::Matrix2d getCdMatrix (Point2D const &pixel) const
 Get the 2x2 CD matrix at the specified pixel position. More...
 
Eigen::Matrix2d getCdMatrix () const
 Get the 2x2 CD matrix at the pixel origin. More...
 
std::shared_ptr< SkyWcs > getTanWcs (Point2D const &pixel) const
 Get a local TAN WCS approximation to this WCS at the specified pixel position. More...
 
std::shared_ptr< const ast::FrameDict > getFrameDict () const
 Get the contained FrameDict. More...
 
std::shared_ptr< const TransformPoint2ToSpherePoint > getTransform () const
 Get the contained TransformPoint2ToSpherePoint. More...
 
bool isFlipped () const
 Does the WCS follow the convention of North=Up, East=Left? More...
 
bool isPersistable () const override
 Return true if this particular object can be persisted using afw::table::io. More...
 
AffineTransform linearizePixelToSky (SpherePoint const &coord, AngleUnit const &skyUnit) const
 Return the local linear approximation to pixelToSky at a point given in sky coordinates. More...
 
AffineTransform linearizePixelToSky (Point2D const &pixel, AngleUnit const &skyUnit) const
 Return the local linear approximation to pixelToSky at a point given in pixel coordinates. More...
 
AffineTransform linearizeSkyToPixel (SpherePoint const &coord, AngleUnit const &skyUnit) const
 Return the local linear approximation to skyToPixel at a point given in sky coordinates. More...
 
AffineTransform linearizeSkyToPixel (Point2D const &pixel, AngleUnit const &skyUnit) const
 Return the local linear approximation to skyToPixel at a point given in pixel coordinates. More...
 
bool hasFitsApproximation () const
 Does this SkyWcs have an approximate SkyWcs that can be represented as standard FITS WCS? More...
 
bool isFits () const
 Return true getFitsMetadata(true) will succeed, false if not. More...
 
void writeStream (std::ostream &os) const
 Serialize this SkyWcs to an output stream. More...
 
std::string writeString () const
 Serialize this SkyWcs to a string, using the same format as writeStream. 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...
 
SpherePoint pixelToSky (Point2D const &pixel) const
 Compute sky position(s) from pixel position(s) More...
 
SpherePoint pixelToSky (double x, double y) const
 Compute sky position(s) from pixel position(s) More...
 
std::vector< SpherePoint > pixelToSky (std::vector< Point2D > const &pixels) const
 Compute sky position(s) from pixel position(s) More...
 
Point2D skyToPixel (SpherePoint const &sky) const
 Compute pixel position(s) from sky position(s) More...
 
std::vector< Point2D > skyToPixel (std::vector< SpherePoint > const &sky) const
 Compute pixel position(s) from sky position(s) More...
 

Static Public Member Functions

static std::string getShortClassName ()
 
static std::shared_ptr< SkyWcs > readStream (std::istream &is)
 Deserialize a SkyWcs from an input stream. More...
 
static std::shared_ptr< SkyWcs > readString (std::string &str)
 Deserialize a SkyWcs from a string, using the same format as readStream. More...
 
static std::shared_ptr< SkyWcs > readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< SkyWcs > readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< SkyWcs > readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Protected Member Functions

std::string getPersistenceName () const override
 Return the unique name used to persist this object and look up its factory. More...
 
std::string getPythonModule () const override
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
void write (OutputArchiveHandle &handle) const override
 Write the object to one or more catalogs. More...
 

Detailed Description

A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixels.

SkyWcs is an immutable object that can not only represent any standard FITS WCS, but can also contain arbitrary Transforms, e.g. to model optical distortion or pixel imperfections.

In order to make a SkyWcs that models optical distortion, say, it is usually simplest to start with a standard FITS WCS (such as a TAN WCS) as an approximation, then insert a transform that models optical distortion by calling makeModifiedWcs. However, it is also possible to build a SkyWcs entirely from transforms, if you prefer, by building an ast::FrameDict and constructing the SkyWcs from that.

Frames of reference

SkyWcs internally keeps track of the following frames of reference:

Pixel position standards

The LSST standard for pixel position is: 0,0 is the center of the lower left image pixel. The FITS standard for pixel position is: 1,1 is the center of the lower left image pixel.

LSST and FITS also use a different origin for subimages:

Internal details: the contained ast::FrameDict

SkyWcs contains an ast::FrameDict which transforms from pixels to sky (in radians) in the forward direction.

This FrameDict contains the named frames described in frames of reference, e.g. "SKY", "IWC", "PIXELS" and possibly "ACTUAL_PIXELS". "SKY" is the current frame. If "ACTUAL_PIXELS" is present then it is the base frame, otherwise "PIXELS" is the base frame.

The "SKY" frame is of type ast::SkyFrame and has the following attributes:

The other frames are of type ast::Frame and have 2 axes.

Definition at line 113 of file SkyWcs.h.

Member Typedef Documentation

◆ OutputArchiveHandle

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

Definition at line 108 of file Persistable.h.

Constructor & Destructor Documentation

◆ SkyWcs() [1/4]

lsst::afw::geom::SkyWcs::SkyWcs ( SkyWcs const &  )
default

◆ SkyWcs() [2/4]

lsst::afw::geom::SkyWcs::SkyWcs ( SkyWcs &&  )
default

◆ ~SkyWcs()

lsst::afw::geom::SkyWcs::~SkyWcs ( )
default

◆ SkyWcs() [3/4]

lsst::afw::geom::SkyWcs::SkyWcs ( daf::base::PropertySet &  metadata,
bool  strip = false 
)
explicit

Construct a SkyWcs from FITS keywords.

Parameters
[in]metadataFITS header metadata
[in]stripIf true: strip items from metadata used to create the WCS, such as RADESYS, EQUINOX, CTYPE12, CRPIX12, CRVAL12, etc. Always keep keywords that might be wanted for other purpposes, including NAXIS12 and date-related keywords such as "DATE-OBS" and "TIMESYS" (but not "EQUINOX").
Exceptions
lsst::pex::exceptions::TypeErrorif the metadata does not describe a celestial WCS.

◆ SkyWcs() [4/4]

lsst::afw::geom::SkyWcs::SkyWcs ( ast::FrameDict const &  frameDict)
explicit

Construct a SkyWcs from an ast::FrameDict.

This is the most general constructor; it can be used to define any celestial WCS. Note that in many cases the result will not be exactly representable as a FITS WCS.

Parameters
[in]frameDictAn ast::FrameDict that describes the transformation from pixels to sky. It must meet the requirements outlined in the contained ast::FrameDict.
Exceptions
lsst::pex::exceptions::TypeErrorif frameDict is missing any of the required frames of reference.

Member Function Documentation

◆ copyAtShiftedPixelOrigin()

std::shared_ptr<SkyWcs> lsst::afw::geom::SkyWcs::copyAtShiftedPixelOrigin ( Extent2D const &  shift) const

Return a copy of this SkyWcs with the pixel origin shifted by the specified amount.

new pixel origin = the old pixel origin + shift

Parameters
[in]shiftThe amount by which to shift the pixel origin (pixels)

◆ getCdMatrix() [1/2]

Eigen::Matrix2d lsst::afw::geom::SkyWcs::getCdMatrix ( Point2D const &  pixel) const

Get the 2x2 CD matrix at the specified pixel position.

The elements are in degrees

◆ getCdMatrix() [2/2]

Eigen::Matrix2d lsst::afw::geom::SkyWcs::getCdMatrix ( ) const

Get the 2x2 CD matrix at the pixel origin.

The elements are in degrees

◆ getFitsMetadata()

std::shared_ptr<daf::base::PropertyList> lsst::afw::geom::SkyWcs::getFitsMetadata ( bool  precise = false) const

Return the WCS as FITS WCS metadata.

Parameters
[in]preciseFail if the WCS cannot be accurately represented as FITS metadata? If False then return an approximation. For now that approximation is pure TAN but as of DM-13170 it will be a fit TAN-SIP. The required precision is set by constant TIGHT_FITS_TOL in SkyWcs.cc

FITS representations of WCS are described in "Representations of World Coordinates in FITS" by Greisen and Calabretta and several related papers.

The required precision is hard-coded as constant TIGHT_FITS_TOL in SkyWcs.cc

Exceptions
lsst::pex::exceptions::RuntimeErrorif precise is true and AST cannot represent this WCS as a FITS WCS to sufficient precision.

◆ getFrameDict()

std::shared_ptr<const ast::FrameDict> lsst::afw::geom::SkyWcs::getFrameDict ( ) const

Get the contained FrameDict.

The forward transform goes from pixels (using the LSST zero convention) to sky ICRS RA, Dec (in radians)

◆ getPersistenceName()

std::string lsst::afw::geom::SkyWcs::getPersistenceName ( ) const
overrideprotectedvirtual

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.

◆ getPixelOrigin()

Point2D lsst::afw::geom::SkyWcs::getPixelOrigin ( ) const
inline

Get the pixel origin, in pixels, using the LSST convention.

This is CRPIX1 - 1, CRPIX2 -1 in FITS terminology

Definition at line 211 of file SkyWcs.h.

◆ getPixelScale() [1/2]

Angle lsst::afw::geom::SkyWcs::getPixelScale ( Point2D const &  pixel) const

Get the pixel scale at the specified pixel position.

The scale is the square root of the area of the specified pixel on the sky.

Warning
Unlike getPixelScale() the value is not cached, even if pixel = pixel origin.

◆ getPixelScale() [2/2]

Angle lsst::afw::geom::SkyWcs::getPixelScale ( ) const
inline

Get the pixel scale at the pixel origin.

The scale is the square root of the area of the specified pixel on the sky.

The value is cached, so this is a cheap call.

Definition at line 204 of file SkyWcs.h.

◆ getPythonModule()

std::string lsst::afw::geom::SkyWcs::getPythonModule ( ) const
overrideprotectedvirtual

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.

◆ getShortClassName()

static std::string lsst::afw::geom::SkyWcs::getShortClassName ( )
static

◆ getSkyOrigin()

SpherePoint lsst::afw::geom::SkyWcs::getSkyOrigin ( ) const

Get the sky origin, the celestial fiducial point.

This is CRVAL1, CRVAL2 in FITS terminology

◆ getTanWcs()

std::shared_ptr<SkyWcs> lsst::afw::geom::SkyWcs::getTanWcs ( Point2D const &  pixel) const

Get a local TAN WCS approximation to this WCS at the specified pixel position.

◆ getTransform()

std::shared_ptr<const TransformPoint2ToSpherePoint> lsst::afw::geom::SkyWcs::getTransform ( ) const
inline

Get the contained TransformPoint2ToSpherePoint.

Definition at line 250 of file SkyWcs.h.

◆ hasFitsApproximation()

bool lsst::afw::geom::SkyWcs::hasFitsApproximation ( ) const
inline

Does this SkyWcs have an approximate SkyWcs that can be represented as standard FITS WCS?

This feature is not yet implemented, so hasFitsApproximation is always false.

Definition at line 347 of file SkyWcs.h.

◆ isFits()

bool lsst::afw::geom::SkyWcs::isFits ( ) const

Return true getFitsMetadata(true) will succeed, false if not.

In other words, true indicates that the WCS can be accurately represented using FITS WCS metadata.

◆ isFlipped()

bool lsst::afw::geom::SkyWcs::isFlipped ( ) const

Does the WCS follow the convention of North=Up, East=Left?

Returns
False/true if E is along -X/+X when the N/E axes are rotated so that N is along image +Y.
Exceptions
lsst::pex::exceptions::RuntimeErrorif the parity cannot be determined because the CD matrix is singular.

◆ isPersistable()

bool lsst::afw::geom::SkyWcs::isPersistable ( ) const
inlineoverridevirtual

Return true if this particular object can be persisted using afw::table::io.

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

Definition at line 261 of file SkyWcs.h.

◆ linearizePixelToSky() [1/2]

AffineTransform lsst::afw::geom::SkyWcs::linearizePixelToSky ( SpherePoint const &  coord,
AngleUnit const &  skyUnit 
) const

Return the local linear approximation to pixelToSky at a point given in sky coordinates.

The local linear approximation is defined such the following is true (ignoring floating-point errors):

wcs.linearizePixelToSky(sky, skyUnit)(wcs.skyToPixel(sky)) == sky.getPosition(skyUnit);

(AffineTransform::operator() applies the transform in the forward direction)

Parameters
[in]coordPosition in sky coordinates where transform is desired.
[in]skyUnitUnits to use for sky coordinates; units of matrix elements will be skyUnits/pixel.

◆ linearizePixelToSky() [2/2]

AffineTransform lsst::afw::geom::SkyWcs::linearizePixelToSky ( Point2D const &  pixel,
AngleUnit const &  skyUnit 
) const

Return the local linear approximation to pixelToSky at a point given in pixel coordinates.

The local linear approximation is defined such the following is true (ignoring floating-point errors):

wcs.linearizePixelToSky(pixel, skyUnit)(pixel) == wcs.pixelToSky(pixel).getPosition(skyUnit)

(AffineTransform::operator() applies the transform in the forward direction)

Parameters
[in]pixelPosition in pixel coordinates where transform is desired.
[in]skyUnitUnits to use for sky coordinates; units of matrix elements will be skyUnits/pixel.

◆ linearizeSkyToPixel() [1/2]

AffineTransform lsst::afw::geom::SkyWcs::linearizeSkyToPixel ( SpherePoint const &  coord,
AngleUnit const &  skyUnit 
) const

Return the local linear approximation to skyToPixel at a point given in sky coordinates.

The local linear approximation is defined such the following is true (ignoring floating-point errors):

wcs.linearizeSkyToPixel(sky, skyUnit)(sky.getPosition(skyUnit)) == wcs.skyToPixel(sky)

(AffineTransform::operator() applies the transform in the forward direction)

Parameters
[in]coordPosition in sky coordinates where transform is desired.
[in]skyUnitUnits to use for sky coordinates; units of matrix elements will be pixels/skyUnit.

◆ linearizeSkyToPixel() [2/2]

AffineTransform lsst::afw::geom::SkyWcs::linearizeSkyToPixel ( Point2D const &  pixel,
AngleUnit const &  skyUnit 
) const

Return the local linear approximation to skyToPixel at a point given in pixel coordinates.

The local linear approximation is defined such the following is true (ignoring floating-point errors):

wcs.linearizeSkyToPixel(pixel, skyUnit)(wcs.pixelToSky(pixel).getPosition(skyUnit)) == pixel

(AffineTransform::operator() applies the transform in the forward direction)

Parameters
[in]pixelPosition in pixel coordinates where transform is desired.
[in]skyUnitUnits to use for sky coordinates; units of matrix elements will be pixels/skyUnit.

◆ operator!=()

bool lsst::afw::geom::SkyWcs::operator!= ( SkyWcs const &  other) const
inline

Definition at line 132 of file SkyWcs.h.

◆ operator=() [1/2]

SkyWcs& lsst::afw::geom::SkyWcs::operator= ( SkyWcs const &  )
delete

◆ operator=() [2/2]

SkyWcs& lsst::afw::geom::SkyWcs::operator= ( SkyWcs &&  )
delete

◆ operator==()

bool lsst::afw::geom::SkyWcs::operator== ( SkyWcs const &  other) const

Equality is based on the string representations being equal.

Two SkyWcs constructed the same way will be equal, and a SkyWcs that has been saved and restored will be equal to the original. However, it is possible to construct two SkyWcs that behave identically as far as transforming points go, but will compare as unequal due to subtle internal differences, such as a contained ast::Mapping that has a different ID in one SkyWcs than another.

Thus equality is primarily useful for testing persistence.

◆ pixelToSky() [1/3]

SpherePoint lsst::afw::geom::SkyWcs::pixelToSky ( Point2D const &  pixel) const
inline

Compute sky position(s) from pixel position(s)

Definition at line 323 of file SkyWcs.h.

◆ pixelToSky() [2/3]

SpherePoint lsst::afw::geom::SkyWcs::pixelToSky ( double  x,
double  y 
) const
inline

Compute sky position(s) from pixel position(s)

Definition at line 324 of file SkyWcs.h.

◆ pixelToSky() [3/3]

std::vector<SpherePoint> lsst::afw::geom::SkyWcs::pixelToSky ( std::vector< Point2D > const &  pixels) const
inline

Compute sky position(s) from pixel position(s)

Definition at line 325 of file SkyWcs.h.

◆ readFits() [1/3]

static std::shared_ptr<SkyWcs > lsst::afw::table::io::PersistableFacade< SkyWcs >::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/3]

static std::shared_ptr<SkyWcs > lsst::afw::table::io::PersistableFacade< SkyWcs >::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() [3/3]

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

◆ readStream()

static std::shared_ptr<SkyWcs> lsst::afw::geom::SkyWcs::readStream ( std::istream &  is)
static

Deserialize a SkyWcs from an input stream.

Parameters
[in]isinput stream from which to deserialize this SkyWcs

◆ readString()

static std::shared_ptr<SkyWcs> lsst::afw::geom::SkyWcs::readString ( std::string &  str)
static

Deserialize a SkyWcs from a string, using the same format as readStream.

◆ skyToPixel() [1/2]

Point2D lsst::afw::geom::SkyWcs::skyToPixel ( SpherePoint const &  sky) const
inline

Compute pixel position(s) from sky position(s)

Definition at line 334 of file SkyWcs.h.

◆ skyToPixel() [2/2]

std::vector<Point2D> lsst::afw::geom::SkyWcs::skyToPixel ( std::vector< SpherePoint > const &  sky) const
inline

Compute pixel position(s) from sky position(s)

Definition at line 335 of file SkyWcs.h.

◆ write()

void lsst::afw::geom::SkyWcs::write ( OutputArchiveHandle &  handle) const
overrideprotectedvirtual

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.

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

◆ writeStream()

void lsst::afw::geom::SkyWcs::writeStream ( std::ostream &  os) const

Serialize this SkyWcs to an output stream.

Version 1 format is as follows:

If and when fits approximation is supported, the approximate WCS will be written as a second FrameDict immediately following the first.

Parameters
[out]osoutput stream to which to serialize this SkyWcs

◆ writeString()

std::string lsst::afw::geom::SkyWcs::writeString ( ) const

Serialize this SkyWcs to a string, using the same format as writeStream.


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