|
lsst.afw
14.0-23-g38c323faa+1
|
Implementation of the WCS standard for a any projection. More...
#include <Wcs.h>
Public Types | |
| typedef std::shared_ptr< Persistable > | Ptr |
| typedef unsigned long | memId |
| typedef memId(* | memNewCallback) (const memId cid) |
| typedef memId(* | memCallback) (const Citizen *ptr) |
Public Member Functions | |
| Wcs (lsst::afw::geom::Point2D const &crval, lsst::afw::geom::Point2D const &crpix, Eigen::Matrix2d const &CD, std::string const &ctype1="RA---TAN", std::string const &ctype2="DEC--TAN", double equinox=2000, std::string const &raDecSys="ICRS", std::string const &cunits1="deg", std::string const &cunits2="deg") | |
| Create a Wcs object with some known information. More... | |
| virtual | ~Wcs () |
| virtual std::shared_ptr< Wcs > | clone (void) const |
| bool | operator== (Wcs const &other) const |
| bool | operator!= (Wcs const &other) const |
| std::shared_ptr< lsst::afw::coord::Coord > | getSkyOrigin () const |
| Returns CRVAL. This need not be the centre of the image. More... | |
| lsst::afw::geom::Point2D | getPixelOrigin () const |
| Returns CRPIX (corrected to LSST convention). More... | |
| Eigen::Matrix2d | getCDMatrix () const |
| Returns the CD matrix. More... | |
| virtual void | flipImage (int flipLR, int flipTB, lsst::afw::geom::Extent2I dimensions) const |
| Flip CD matrix around the y-axis. More... | |
| virtual void | rotateImageBy90 (int nQuarter, lsst::afw::geom::Extent2I dimensions) const |
| Rotate image by nQuarter times 90 degrees. More... | |
| virtual std::shared_ptr< lsst::daf::base::PropertyList > | getFitsMetadata () const |
| Return a PropertyList containing FITS header keywords that can be used to save the Wcs.x. More... | |
| bool | isFlipped () const |
| Does the Wcs follow the convention of North=Up, East=Left? More... | |
| double | pixArea (lsst::afw::geom::Point2D pix00) const |
Sky area covered by a pixel at position pix00 in units of square degrees. More... | |
| geom::Angle | pixelScale () const |
| Returns the pixel scale [Angle/pixel]. More... | |
| std::shared_ptr< coord::Coord > | pixelToSky (double pix1, double pix2) const |
| Convert from pixel position to sky coordinates (e.g. More... | |
| std::shared_ptr< coord::Coord > | pixelToSky (lsst::afw::geom::Point2D const &pixel) const |
| Convert from pixel position to sky coordinates (e.g. More... | |
| void | pixelToSky (double pixel1, double pixel2, geom::Angle &sky1, geom::Angle &sky2) const |
| Convert from pixel position to sky coordinates (e.g. More... | |
| geom::Point2D | skyToPixel (geom::Angle sky1, geom::Angle sky2) const |
| Convert from sky coordinates (e.g. More... | |
| geom::Point2D | skyToPixel (coord::Coord const &coord) const |
| Convert from sky coordinates (e.g. RA/dec) to pixel positions. More... | |
| geom::Point2D | skyToIntermediateWorldCoord (coord::Coord const &coord) const |
| Convert from sky coordinates (e.g. More... | |
| virtual bool | hasDistortion () const |
| afw::coord::CoordSystem | getCoordSystem () const |
| double | getEquinox () const |
| bool | isSameSkySystem (Wcs const &wcs) const |
| Return true if a WCS has the same coordinate system and equinox as this one. More... | |
| geom::LinearTransform | getLinearTransform () const |
| Return the linear part of the Wcs, the CD matrix in FITS-speak, as an AffineTransform. More... | |
| geom::AffineTransform | linearizePixelToSky (coord::Coord const &coord, geom::AngleUnit skyUnit=geom::degrees) const |
| Return the local linear approximation to Wcs::pixelToSky at a point given in sky coordinates. More... | |
| geom::AffineTransform | linearizePixelToSky (geom::Point2D const &pix, geom::AngleUnit skyUnit=geom::degrees) const |
| Return the local linear approximation to Wcs::pixelToSky at a point given in pixel coordinates. More... | |
| geom::AffineTransform | linearizeSkyToPixel (coord::Coord const &coord, geom::AngleUnit skyUnit=geom::degrees) const |
| Return the local linear approximation to Wcs::skyToPixel at a point given in sky coordinates. More... | |
| geom::AffineTransform | linearizeSkyToPixel (geom::Point2D const &pix, geom::AngleUnit skyUnit=geom::degrees) const |
| Return the local linear approximation to Wcs::skyToPixel at a point given in pixel coordinates. More... | |
| virtual void | shiftReferencePixel (double dx, double dy) |
| Move the pixel reference position by (dx, dy) More... | |
| virtual void | shiftReferencePixel (geom::Extent2D const &d) |
| virtual bool | isPersistable () const |
| Whether the Wcs is persistable using afw::table::io archives. More... | |
| void | serialize (Archive &, unsigned int const) |
| std::string | repr () const |
| void | markPersistent (void) |
| memId | getId () 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 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< Wcs > | readFits (fits::Fits &fitsfile) |
| Read an object from an already open FITS object. More... | |
| static std::shared_ptr< Wcs > | readFits (std::string const &fileName, int hdu=INT_MIN) |
| Read an object from a regular FITS file. More... | |
| static std::shared_ptr< Wcs > | readFits (fits::MemFileManager &manager, int hdu=INT_MIN) |
| Read an object from a FITS file in memory. More... | |
Public Attributes | |
| magicSentinel | |
Protected Types | |
| typedef io::OutputArchiveHandle | OutputArchiveHandle |
Protected Member Functions | |
| bool | _mayBePersistable () const |
| Perform basic checks on whether *this might be persistable. 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... | |
| virtual bool | _isSubset (Wcs const &other) const |
| bool | _isIcrs () const |
| Wcs () | |
| Construct an invalid Wcs given no arguments. More... | |
| Wcs (std::shared_ptr< daf::base::PropertySet const > const &fitsMetadata) | |
| Create a Wcs from a fits header. More... | |
| Wcs (afw::table::BaseRecord const &record) | |
| Wcs (Wcs const &rhs) | |
| Copy constructor. More... | |
| Wcs & | operator= (const Wcs &) |
| virtual void | pixelToSkyImpl (double pixel1, double pixel2, geom::Angle skyTmp[2]) const |
| Worker routine for pixelToSky. More... | |
| virtual geom::Point2D | skyToPixelImpl (geom::Angle sky1, geom::Angle sky2) const |
| Worker routine for skyToPixel. More... | |
| std::shared_ptr< afw::coord::Coord > | makeCorrectCoord (geom::Angle sky0, geom::Angle sky1) const |
| Given a sky position, use the values stored in ctype and radesys to return the correct sub-class of Coord. More... | |
| std::shared_ptr< afw::coord::Coord > | convertCoordToSky (coord::Coord const &coord) const |
| Given a Coord (as a shared pointer), return the sky position in the correct coordinate system for this Wcs. More... | |
| virtual geom::AffineTransform | linearizePixelToSkyInternal (geom::Point2D const &pix, coord::Coord const &coord, geom::AngleUnit skyUnit) const |
| Implementation for the overloaded public linearizePixelToSky methods, requiring both a pixel coordinate and the corresponding sky coordinate. More... | |
| virtual geom::AffineTransform | linearizeSkyToPixelInternal (geom::Point2D const &pix, coord::Coord const &coord, geom::AngleUnit skyUnit) const |
| Implementation for the overloaded public linearizeSkyToPixel methods, requiring both a pixel coordinate and the corresponding sky coordinate. More... | |
| void | initWcsLibFromFits (std::shared_ptr< lsst::daf::base::PropertySet const > const &fitsMetadata) |
| Parse a fits header, extract the relevant metadata and create a Wcs object. More... | |
| void | _initWcs () |
| Set some internal variables that we need to refer to. More... | |
| void | _setWcslibParams () |
Protected Attributes | |
| struct wcsprm * | _wcsInfo |
| int | _nWcsInfo |
| int | _relax |
| Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details. More... | |
| int | _wcsfixCtrl |
| Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes. More... | |
| int | _wcshdrCtrl |
| Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details. More... | |
| int | _nReject |
| coord::CoordSystem | _coordSystem |
| bool | _skyAxesSwapped |
| if true then the sky axes are swapped More... | |
Friends | |
| class | WcsFactory |
| std::shared_ptr< Wcs > | makeWcs (std::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata) |
| Create a Wcs of the correct class using a FITS header. More... | |
Implementation of the WCS standard for a any projection.
Implements a single representation of the World Coordinate System of a two dimensional image The standard is defined in two papers
In its simplest sense, Wcs is used to convert from position in the sky (in right ascension and declination) to pixel position on an image (and back again). It is, however, much more general than that and can understand a myriad of different coordinate systems.
A wcs can be constructed from a reference position (crval, crpix) and a translation matrix. Alternatively, if you have the header from a FITS file, you can create a Wcs object with the makeWcs() function. This function determines whether your Wcs is one the subset of projection systems that is dealt with specially by LSST, and creates an object of the correct class. Otherwise, a pointer to a Wcs object is returned. Most astronomical images use tangent plane projection, so makeWcs() returns a TanWcs object pointer
import lsst.afw.image as afwImg
fitsHeader = afwImg.readMetadata(filename)
if 0:
#This doesn't work
wcs = afwImg.Wcs(fitsHeader)
wcs = afwImg.makeWcs(fitsHeader)
pixelPosition = wcs.skyToPixel(ra, dec)
skyPosition = wcs.skyToPixel(xPosition, yPosition)
o[ This class is implemented in by calls to the wcslib library by Mark Calabretta http://www.atnf.csiro.au/people/mcalabre/WCS/
Note that we violate the WCS standard in one minor way. The standard states that none of the CRPIX or CRVAL keywords are required, for the header to be valid, and the appropriate values should be set to 0.0 if the keywords are absent. This is a recipe for painful bugs in analysis, so we violate the standard by insisting that the keywords CRPIX[1,2] and CRVAL[1,2] are present when reading a header (keywords CRPIX1a etc are also accepted)
|
protectedinherited |
Definition at line 107 of file Persistable.h.
| lsst::afw::image::Wcs::Wcs | ( | lsst::afw::geom::Point2D const & | crval, |
| lsst::afw::geom::Point2D const & | crpix, | ||
| Eigen::Matrix2d const & | CD, | ||
| std::string const & | ctype1 = "RA---TAN", |
||
| std::string const & | ctype2 = "DEC--TAN", |
||
| double | equinox = 2000, |
||
| std::string const & | raDecSys = "ICRS", |
||
| std::string const & | cunits1 = "deg", |
||
| std::string const & | cunits2 = "deg" |
||
| ) |
Create a Wcs object with some known information.
| crval | The sky position of the reference point |
| crpix | The pixel position corresponding to crval in LSST units |
| CD | Matrix describing transformations from pixel to sky positions |
| ctype1 | Projection system used (see description of Wcs) |
| ctype2 | Projection system used (see description of Wcs) |
| equinox | Equinox of coordinate system, eg 2000 (Julian) or 1950 (Besselian) |
| raDecSys | System used to describe right ascension or declination, e.g FK4, FK5 or ICRS |
| cunits1 | Units of sky position. One of deg, arcmin or arcsec |
| cunits2 | Units of sky position. One of deg, arcmin or arcsec |
|
protected |
|
protected |
|
explicitprotected |
|
protected |
|
protected |
|
protectedvirtual |
|
protected |
|
virtual |
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
|
protected |
|
virtual |
Flip CD matrix around the y-axis.
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
| Eigen::Matrix2d lsst::afw::image::Wcs::getCDMatrix | ( | ) | const |
|
inline |
|
virtual |
Return a PropertyList containing FITS header keywords that can be used to save the Wcs.x.
Reimplemented in lsst::afw::image::TanWcs.
| geom::LinearTransform lsst::afw::image::Wcs::getLinearTransform | ( | ) | 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.
| GeomPoint lsst::afw::image::Wcs::getPixelOrigin | ( | ) | 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.
| CoordPtr lsst::afw::image::Wcs::getSkyOrigin | ( | ) | const |
|
inlinevirtual |
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
|
protected |
| bool lsst::afw::image::Wcs::isFlipped | ( | ) | const |
Does the Wcs follow the convention of North=Up, East=Left?
The conventional sense for a WCS image is to have North up and East to the left, or at least to be able to rotate the image to that orientation. It is possible to create a "flipped" WCS, where East points right when the image is rotated such that North is up. Flipping a WCS is akin to producing a mirror image. This function tests whether the image is flipped or not.
|
virtual |
Whether the Wcs is persistable using afw::table::io archives.
Reimplemented from lsst::afw::table::io::Persistable.
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
| bool lsst::afw::image::Wcs::isSameSkySystem | ( | Wcs const & | wcs | ) | const |
| geom::AffineTransform lsst::afw::image::Wcs::linearizePixelToSky | ( | coord::Coord const & | coord, |
| geom::AngleUnit | skyUnit = geom::degrees |
||
| ) | const |
Return the local linear approximation to Wcs::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);
(recall that AffineTransform::operator() is matrix multiplication with the augmented point (x,y,1)).
This is currently implemented as a numerical derivative, but we should specialise the Wcs class (or rather its implementation) to handle "simple" cases such as TAN-SIP analytically
| [in] | coord | Position in sky coordinates where transform is desired. |
| [in] | skyUnit | Units to use for sky coordinates; units of matrix elements will be skyUnits/pixel. |
| geom::AffineTransform lsst::afw::image::Wcs::linearizePixelToSky | ( | geom::Point2D const & | pix, |
| geom::AngleUnit | skyUnit = geom::degrees |
||
| ) | const |
Return the local linear approximation to Wcs::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(pix, skyUnit)(pix) == wcs.pixelToSky(pix).getPosition(skyUnit)
(recall that AffineTransform::operator() is matrix multiplication with the augmented point (x,y,1)).
This is currently implemented as a numerical derivative, but we should specialise the Wcs class (or rather its implementation) to handle "simple" cases such as TAN-SIP analytically
| [in] | pix | Position in pixel coordinates where transform is desired. |
| [in] | skyUnit | Units to use for sky coordinates; units of matrix elements will be skyUnits/pixel. |
|
protectedvirtual |
| geom::AffineTransform lsst::afw::image::Wcs::linearizeSkyToPixel | ( | coord::Coord const & | coord, |
| geom::AngleUnit | skyUnit = geom::degrees |
||
| ) | const |
Return the local linear approximation to Wcs::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)
(recall that AffineTransform::operator() is matrix multiplication with the augmented point (x,y,1)).
This is currently implemented as a numerical derivative, but we should specialise the Wcs class (or rather its implementation) to handle "simple" cases such as TAN-SIP analytically
| [in] | coord | Position in sky coordinates where transform is desired. |
| [in] | skyUnit | Units to use for sky coordinates; units of matrix elements will be pixels/skyUnit. |
| geom::AffineTransform lsst::afw::image::Wcs::linearizeSkyToPixel | ( | geom::Point2D const & | pix, |
| geom::AngleUnit | skyUnit = geom::degrees |
||
| ) | const |
Return the local linear approximation to Wcs::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(pix, skyUnit)(wcs.pixelToSky(pix).getPosition(skyUnit)) == pix
(recall that AffineTransform::operator() is matrix multiplication with the augmented point (x,y,1)).
This is currently implemented as a numerical derivative, but we should specialise the Wcs class (or rather its implementation) to handle "simple" cases such as TAN-SIP analytically
| [in] | pix | Position in pixel coordinates where transform is desired. |
| [in] | skyUnit | Units to use for sky coordinates; units of matrix elements will be pixels/skyUnit. |
|
protectedvirtual |
|
protected |
|
inline |
| bool lsst::afw::image::Wcs::operator== | ( | Wcs const & | other | ) | const |
| double lsst::afw::image::Wcs::pixArea | ( | lsst::afw::geom::Point2D | pix00 | ) | const |
| geom::Angle lsst::afw::image::Wcs::pixelScale | ( | ) | const |
| CoordPtr lsst::afw::image::Wcs::pixelToSky | ( | double | pix1, |
| double | pix2 | ||
| ) | const |
Convert from pixel position to sky coordinates (e.g.
RA/dec)
Convert a pixel position (e.g. x,y) to a celestial coordinate (e.g. RA/dec). The output coordinate system depends on the values of CTYPE used to construct the object. For RA/dec, the CTYPES should be RA—TAN and DEC–TAN.
| CoordPtr lsst::afw::image::Wcs::pixelToSky | ( | lsst::afw::geom::Point2D const & | pixel | ) | const |
Convert from pixel position to sky coordinates (e.g.
RA/dec)
Convert a pixel position (e.g. x,y) to a celestial coordinate (e.g. RA/dec). The output coordinate system depends on the values of CTYPE used to construct the object. For RA/dec, the CTYPES should be RA—TAN and DEC–TAN.
| void lsst::afw::image::Wcs::pixelToSky | ( | double | pixel1, |
| double | pixel2, | ||
| geom::Angle & | sky1, | ||
| geom::Angle & | sky2 | ||
| ) | const |
|
protectedvirtual |
Worker routine for pixelToSky.
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
|
inlinestaticinherited |
Read an object from an already open FITS object.
| [in] | fitsfile | FITS object to read from, already positioned at the desired HDU. |
Definition at line 180 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a regular FITS file.
| [in] | fileName | Name of the file to read. |
| [in] | hdu | HDU to read, where 0 is the primary. The special value of INT_MIN skips the primary HDU if it is empty. |
Definition at line 191 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a FITS file in memory.
| [in] | manager | Manager for the memory to read from. |
| [in] | hdu | HDU to read, where 0 is the primary. The special value of INT_MIN skips the primary HDU if it is empty. |
Definition at line 202 of file Persistable.h.
|
virtual |
Rotate image by nQuarter times 90 degrees.
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
|
virtual |
Move the pixel reference position by (dx, dy)
Used when persisting and retrieving sub-images. The LSST convention is that Wcs returns pixel position (which is based on position in the parent image), but the FITS convention is to return pixel index (which is bases on position in the sub-image). In order that the FITS files we create make sense to other FITS viewers, we change to the FITS convention when writing out images.
Reimplemented in lsst::afw::image::DistortedTanWcs.
|
inlinevirtual |
| GeomPoint lsst::afw::image::Wcs::skyToIntermediateWorldCoord | ( | coord::Coord const & | coord | ) | const |
| GeomPoint lsst::afw::image::Wcs::skyToPixel | ( | geom::Angle | sky1, |
| geom::Angle | sky2 | ||
| ) | const |
Convert from sky coordinates (e.g.
RA/dec) to pixel positions
Convert a sky position (e.g. RA/dec) to a pixel position. The exact meaning of sky1, sky2 and the return value depend on the properties of the wcs (i.e. the values of CTYPE1 and CTYPE2), but the inputs are usually RA/dec. The outputs are x and y pixel position.
ASSUMES the angles are in the appropriate coordinate system for this Wcs.
| GeomPoint lsst::afw::image::Wcs::skyToPixel | ( | coord::Coord const & | coord | ) | const |
|
protectedvirtual |
Worker routine for skyToPixel.
| sky1 | RA (or, more generally, longitude) |
| sky2 | Dec (or latitude) |
Reimplemented in lsst::afw::image::TanWcs, and lsst::afw::image::DistortedTanWcs.
|
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.
|
inherited |
Write the object to a regular FITS file.
| [in] | fileName | Name of the file to write to. |
| [in] | mode | If "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file. |
|
inherited |
Write the object to a FITS image in memory.
| [in] | manager | Name of the file to write to. |
| [in] | mode | If "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file. |
|
inherited |
Write the object to an already-open FITS object.
| [in] | fitsfile | Open FITS object to write to. |
|
friend |
Create a Wcs of the correct class using a FITS header.
Set stripMetadata=true to remove processed keywords from the PropertySet.
It examines the header and determines the most suitable object to return, either a general Wcs object, or a more specific object specialised to a given coordinate system (e.g TanWcs)
| fitsMetadata | input metadata |
| stripMetadata | Remove FITS keywords from metadata? |
Definition at line 37 of file makeWcs.cc.
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
1.8.13