25 #ifndef LSST_AFW_IMAGE_WCS_H
26 #define LSST_AFW_IMAGE_WCS_H
30 #include "lsst/base.h"
31 #include "lsst/daf/base/Persistable.h"
32 #include "lsst/daf/base/Citizen.h"
50 namespace formatters {
104 class Wcs :
public lsst::daf::base::Persistable,
105 public lsst::daf::base::Citizen,
114 friend std::shared_ptr<Wcs>
makeWcs(std::shared_ptr<lsst::daf::base::PropertySet>
const& fitsMetadata,
133 Eigen::Matrix2d
const& CD, std::string
const&
ctype1 =
"RA---TAN",
134 std::string
const&
ctype2 =
"DEC--TAN",
double equinox = 2000, std::string
const& raDecSys =
"ICRS",
135 std::string
const& cunits1 =
"deg", std::string
const& cunits2 =
"deg");
138 virtual std::shared_ptr<Wcs>
clone(
void)
const;
144 std::shared_ptr<lsst::afw::coord::Coord>
getSkyOrigin()
const;
159 virtual std::shared_ptr<lsst::daf::base::PropertyList>
getFitsMetadata()
const;
187 std::shared_ptr<coord::Coord>
pixelToSky(
double pix1,
double pix2)
const;
354 void initWcsLib(geom::
Point2D const& crval, geom::
Point2D const& crpix, Eigen::Matrix2d const& CD,
356 std::
string const& raDecSys, std::
string const& cunits1, std::
string const& cunits2);
387 Wcs(std::shared_ptr<daf::base::PropertySet const>
const& fitsMetadata);
437 void initWcsLibFromFits(std::shared_ptr<lsst::daf::base::PropertySet const>
const& fitsMetadata);
471 std::shared_ptr<Wcs>
makeWcs(std::shared_ptr<lsst::daf::base::PropertySet>
const& fitsMetadata,
472 bool stripMetadata =
false);
487 double CD21,
double CD22);
491 std::shared_ptr<lsst::daf::base::PropertySet>
const& metadata,
492 std::shared_ptr<Wcs const>
const& wcs
508 virtual std::shared_ptr<afw::geom::XYTransform>
invert()
const;
511 virtual std::shared_ptr<afw::geom::XYTransform>
clone()
const;
516 std::shared_ptr<Wcs const>
_dst;
517 std::shared_ptr<Wcs const>
_src;
524 #endif // LSST_AFW_IMAGE_WCS_H
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 coordina...
table::Key< std::string > ctype2
afw::table::PointKey< int > dimensions
virtual bool hasDistortion() const
bool operator==(Wcs const &other) const
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.
virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const
Worker routine for skyToPixel.
virtual std::shared_ptr< Wcs > clone(void) const
An object passed to Persistable::write to allow it to persist itself.
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 coordina...
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
friend 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.
AngleUnit constexpr degrees
constant with units of degrees
Wcs & operator=(const Wcs &)
virtual bool _isSubset(Wcs const &other) const
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Implementation of the WCS standard for a any projection.
afw::coord::CoordSystem getCoordSystem() const
geom::Point2D skyToIntermediateWorldCoord(coord::Coord const &coord) const
Convert from sky coordinates (e.g.
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.
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 thi...
bool _mayBePersistable() const
Perform basic checks on whether *this might be persistable.
A class used to convert scalar POD types such as double to Angle.
virtual void rotateImageBy90(int nQuarter, lsst::afw::geom::Extent2I dimensions) const
Rotate image by nQuarter times 90 degrees.
double pixArea(lsst::afw::geom::Point2D pix00) const
Sky area covered by a pixel at position pix00 in units of square degrees.
A base class for objects that can be persisted via afw::table::io Archive classes.
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
A class representing an angle.
int stripWcsKeywords(std::shared_ptr< lsst::daf::base::PropertySet > const &metadata, std::shared_ptr< Wcs const > const &wcs)
Point< double, 2 > Point2D
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...
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g.
Eigen::Matrix2d getCDMatrix() const
Returns the CD matrix.
virtual void shiftReferencePixel(double dx, double dy)
Move the pixel reference position by (dx, dy)
Wcs()
Construct an invalid Wcs given no arguments.
virtual void flipImage(int flipLR, int flipTB, lsst::afw::geom::Extent2I dimensions) const
Flip CD matrix around the y-axis.
void _initWcs()
Set some internal variables that we need to refer to.
bool isSameSkySystem(Wcs const &wcs) const
Return true if a WCS has the same coordinate system and equinox as this one.
geom::Angle pixelScale() const
Returns the pixel scale [Angle/pixel].
std::shared_ptr< lsst::afw::coord::Coord > getSkyOrigin() const
Returns CRVAL. This need not be the centre of the image.
bool operator!=(Wcs const &other) const
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 C...
lsst::afw::geom::Point2D getPixelOrigin() const
Returns CRPIX (corrected to LSST convention).
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
bool _skyAxesSwapped
if true then the sky axes are swapped
Base class for all records.
int _wcshdrCtrl
Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.
int _relax
Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details.
virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const
Worker routine for pixelToSky.
lsst::daf::base::PropertySet PropertySet
table::Key< double > equinox
int _wcsfixCtrl
Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes.
virtual bool isPersistable() const
Whether the Wcs is persistable using afw::table::io archives.
bool isFlipped() const
Does the Wcs follow the convention of North=Up, East=Left?
table::PointKey< int > pixel
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.
std::shared_ptr< lsst::daf::base::PropertyList > createTrivialWcsAsPropertySet(std::string const &wcsName, int const x0=0, int const y0=0)
table::PointKey< double > crval
table::Key< std::string > ctype1
double getEquinox() const
This is the base class for spherical coordinates.
geom::LinearTransform getLinearTransform() const
Return the linear part of the Wcs, the CD matrix in FITS-speak, as an AffineTransform.
std::shared_ptr< Wcs > makeWcs(std::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
Create a Wcs object from a fits header.
A CRTP facade class for subclasses of Persistable.
coord::CoordSystem _coordSystem
geom::Point2I getImageXY0FromMetadata(std::string const &wcsName, lsst::daf::base::PropertySet *metadata)
table::PointKey< double > crpix
virtual void shiftReferencePixel(geom::Extent2D const &d)