LSSTApplications  11.0-22-g33de520,13.0+153,14.0+52,14.0+57,14.0-1-g013352c+36,14.0-1-g13ef843+9,14.0-1-g4b114ac+14,14.0-1-g7257b6a+12,14.0-1-g8b7e855+51,14.0-13-g7a60b79+2,14.0-14-g87d16e8+10,14.0-14-gbf7a6f8a,14.0-17-g4f4ea82+5,14.0-2-g319577b+11,14.0-2-ga5af9b6+10,14.0-22-gc48c03f+3,14.0-3-g20413be+3,14.0-46-g76222d5f+3,14.0-47-g0a51fac97,14.0-5-g744ff5f+2,14.0-5-g86eb1bd+31,14.0-6-gd5b81a9+6,14.0-6-ge2c9487+42,14.0-8-g7f6dd6b+6,14.0-8-gb81b6e9+4,14.0-9-g11010eb,14.0-9-g330837b+5
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
lsst::afw::image::DistortedTanWcs Class Reference

Combination of a TAN WCS and a distortion model. More...

#include <DistortedTanWcs.h>

Inheritance diagram for lsst::afw::image::DistortedTanWcs:
lsst::afw::image::TanWcs lsst::afw::table::io::PersistableFacade< TanWcs > lsst::afw::image::Wcs lsst::daf::base::Persistable lsst::daf::base::Citizen lsst::afw::table::io::PersistableFacade< Wcs > lsst::afw::table::io::Persistable

Public Types

using Transform = geom::Transform< geom::Point2Endpoint, geom::Point2Endpoint >
 
typedef std::shared_ptr< PersistablePtr
 
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 Member Functions

 DistortedTanWcs (TanWcs const &tanWcs, Transform const &pixelsToTanPixels)
 Construct a DistortedTanWcs. More...
 
 DistortedTanWcs (DistortedTanWcs const &)
 
 DistortedTanWcs (DistortedTanWcs &&)
 
DistortedTanWcsoperator= (DistortedTanWcs const &)=delete
 
DistortedTanWcsoperator= (DistortedTanWcs &&)=delete
 
virtual ~DistortedTanWcs ()=default
 
virtual std::shared_ptr< Wcsclone () const
 Polymorphic deep-copy. More...
 
bool operator== (Wcs const &other) const
 
virtual void flipImage (int flipLR, int flipTB, lsst::afw::geom::Extent2I dimensions) const
 
virtual void rotateImageBy90 (int nQuarter, lsst::afw::geom::Extent2I dimensions) const
 
virtual void shiftReferencePixel (double dx, double dy)
 
bool isPersistable () const
 Whether the Wcs is persistable using afw::table::io archives. More...
 
bool hasDistortion () const
 
std::shared_ptr< WcsgetTanWcs () const
 return the pure tan WCS component More...
 
std::shared_ptr< TransformgetPixelToTanPixel () const
 return the PIXELS to TAN_PIXELS Transform More...
 
geom::Angle pixelScale () const
 Returns the pixel scale, in Angle/pixel. More...
 
geom::Point2D distortPixel (geom::Point2D const &pixel) const
 Applies the SIP AP and BP distortion (used in the skyToPixel direction) More...
 
geom::Point2D undistortPixel (geom::Point2D const &pixel) const
 Applies the SIP A and B un-distortion (used in the pixelToSky direction) More...
 
std::shared_ptr< daf::base::PropertyListgetFitsMetadata () const override
 Return a PropertyList containing FITS header keywords that can be used to save the Wcs.x. More...
 
void setDistortionMatrices (Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB, Eigen::MatrixXd const &sipAp, Eigen::MatrixXd const &sipBp)
 Set the distortion matrices. More...
 
Eigen::MatrixXd const & getSipA () const
 Return the SIP forward distortion matrix for the 1st intermediate world coordinate system axis. More...
 
Eigen::MatrixXd const & getSipB () const
 Return the SIP forward distortion matrix for the 2st intermediate world coordinate system axis. More...
 
Eigen::MatrixXd const & getSipAp () const
 Return the SIP reverse distortion matrix for x pixel coordinates. More...
 
Eigen::MatrixXd const & getSipBp () const
 Return the SIP reverse distortion matrix for y pixel coordinates. More...
 
bool operator!= (Wcs const &other) const
 
std::shared_ptr< lsst::afw::coord::CoordgetSkyOrigin () 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...
 
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...
 
std::shared_ptr< coord::CoordpixelToSky (double pix1, double pix2) const
 Convert from pixel position to sky coordinates (e.g. More...
 
std::shared_ptr< coord::CoordpixelToSky (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...
 
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 (geom::Extent2D const &d)
 
template<class Archive >
void serialize (Archive &, unsigned int const)
 Template boost::serialization function for the base class. More...
 
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...
 
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 void decodeSipHeader (daf::base::PropertySet const &fitsMetadata, std::string const &which, Eigen::MatrixXd &m)
 Decode the SIP headers for a given matrix, if present. More...
 
static std::shared_ptr< TanWcsreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< TanWcsreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< TanWcsreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< WcsreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< WcsreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< WcsreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
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...
 
Census

Provide a list of current Citizens

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

Set callback Ids.

The old Id is returned

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

Set the New/Delete callback functions; in each case the previously installed callback is returned.

These callback functions return a value which is Added to the previously registered id.

The default callback functions are called default{New,Delete}Callback; you may want to set a break point in these callbacks from your favourite debugger

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

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Protected Member Functions

virtual void pixelToSkyImpl (double pixel1, double pixel2, geom::Angle skyTmp[2]) const
 Worker routine for skyToPixel. More...
 
virtual geom::Point2D skyToPixelImpl (geom::Angle sky1, geom::Angle sky2) const
 Worker routine for pixelToSky. More...
 
bool _mayBePersistable () const
 Perform basic checks on whether *this might be persistable. More...
 
virtual std::string getPythonModule () const
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
bool _isIcrs () const
 
std::shared_ptr< afw::coord::CoordmakeCorrectCoord (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::CoordconvertCoordToSky (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...
 

Private Attributes

std::shared_ptr< Transform_pixelsToTanPixelsPtr
 

Detailed Description

Combination of a TAN WCS and a distortion model.

This object represents a common case for raw or minimally processed data; we have estimates for:

Warning
This is not a full-fledged WCS class in several respects:
  • It has no standard FITS WCS representation.
  • It does not support persistence or unpersistence from FITS. The usual use case is to represent the WCS for an exposure that has a plain TAN WCS and a distortion model in its detector; As such, the data is present in two disparate places, making persistence difficult.
  • It cannot be flipped or rotated. This is probably fixable, but does not seem worth the work.

Definition at line 49 of file DistortedTanWcs.h.

Member Typedef Documentation

◆ memCallback

typedef memId(* lsst::daf::base::Citizen::memCallback) (const Citizen *ptr)
inherited

Definition at line 59 of file Citizen.h.

◆ memId

typedef unsigned long lsst::daf::base::Citizen::memId
inherited

Type of the block's ID.

Definition at line 56 of file Citizen.h.

◆ memNewCallback

typedef memId(* lsst::daf::base::Citizen::memNewCallback) (const memId cid)
inherited

A function used to register a callback.

Definition at line 58 of file Citizen.h.

◆ OutputArchiveHandle

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

Definition at line 108 of file Persistable.h.

◆ Ptr

Definition at line 76 of file Persistable.h.

◆ Transform

Definition at line 51 of file DistortedTanWcs.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
magicSentinel 

Definition at line 86 of file Citizen.h.

Constructor & Destructor Documentation

◆ DistortedTanWcs() [1/3]

lsst::afw::image::DistortedTanWcs::DistortedTanWcs ( TanWcs const &  tanWcs,
Transform const &  pixelsToTanPixels 
)

Construct a DistortedTanWcs.

Parameters
[in]tanWcspure tangent-plane WCS
[in]pixelsToTanPixelsa Transform that converts from PIXELS to TAN_PIXELS coordinates in the forward direction. This can be obtained from an exposure using: detector = exposure.getDetector() pixelsToTanPixels = detector.getTransformMap()[lsst.afw.cameraGeom.TAN_PIXELS]
Exceptions
pex::exceptions::InvalidParameterErrorif tanWcs.hasDistortion()

Definition at line 31 of file DistortedTanWcs.cc.

32  : TanWcs(tanWcs), _pixelsToTanPixelsPtr(std::make_shared<Transform>(pixelsToTanPixels)) {
33  if (tanWcs.hasDistortion()) {
34  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "tanWcs has distortion terms");
35  }
36 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
std::shared_ptr< Transform > _pixelsToTanPixelsPtr

◆ DistortedTanWcs() [2/3]

lsst::afw::image::DistortedTanWcs::DistortedTanWcs ( DistortedTanWcs const &  )
default

◆ DistortedTanWcs() [3/3]

lsst::afw::image::DistortedTanWcs::DistortedTanWcs ( DistortedTanWcs &&  )
default

◆ ~DistortedTanWcs()

virtual lsst::afw::image::DistortedTanWcs::~DistortedTanWcs ( )
virtualdefault

Member Function Documentation

◆ _initWcs()

void lsst::afw::image::Wcs::_initWcs ( )
protectedinherited

Set some internal variables that we need to refer to.

Definition at line 114 of file Wcs.cc.

114  {
115  // first four characters of CTYPE1 (name of first axis)
116  std::string ctype1 = std::string(_wcsInfo->ctype[0]).substr(0, 4);
117 
118  if (_wcsInfo) {
119  if (ctype1[0] == 'G') {
121  _skyAxesSwapped = (ctype1[2] == 'A'); // GLAT instead of GLON
122  } else if (ctype1[0] == 'E') {
124  _skyAxesSwapped = (ctype1[2] == 'A'); // ELAT instead of ELON
125  } else {
127  _skyAxesSwapped = (ctype1[0] == 'D'); // DEC instead of RA
128  }
129 
130  // tell WCSlib that values have been updated
131  _wcsInfo->flag = 0;
132  // and then tell it to do its internal magic.
133  int status = wcsset(_wcsInfo);
134  if (status != 0) {
136  (boost::format("Failed to setup wcs structure with wcsset. Status %d: %s") %
137  status % wcs_errmsg[status])
138  .str());
139  }
140  }
141 }
STL class.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
bool _skyAxesSwapped
if true then the sky axes are swapped
Definition: Wcs.h:453
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
T substr(T... args)
CoordSystem makeCoordEnum(std::string const system)
A utility function to get the enum value of a coordinate system from a string name.
Definition: Coord.cc:112
table::Key< std::string > ctype1
Definition: Wcs.cc:937
struct wcsprm * _wcsInfo
Definition: Wcs.h:446
coord::CoordSystem _coordSystem
Definition: Wcs.h:452

◆ _isIcrs()

bool lsst::afw::image::Wcs::_isIcrs ( ) const
inlineprotectedinherited

Definition at line 371 of file Wcs.h.

371  {
372  return (getCoordSystem() == afw::coord::ICRS) ||
373  ((getCoordSystem() == afw::coord::FK5) && (getEquinox() == 2000));
374  }
afw::coord::CoordSystem getCoordSystem() const
Definition: Wcs.h:229
double getEquinox() const
Definition: Wcs.cc:789

◆ _mayBePersistable()

bool lsst::afw::image::Wcs::_mayBePersistable ( ) const
protectedinherited

Perform basic checks on whether *this might be persistable.

Definition at line 1003 of file Wcs.cc.

1003  {
1004  if (_wcsInfo[0].naxis != 2) return false;
1005  if (std::strcmp(_wcsInfo[0].cunit[0], "deg") != 0) return false;
1006  if (std::strcmp(_wcsInfo[0].cunit[1], "deg") != 0) return false;
1007 
1008  return true;
1009 }
T strcmp(T... args)
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ _setWcslibParams()

void lsst::afw::image::Wcs::_setWcslibParams ( )
protectedinherited

Definition at line 68 of file Wcs.cc.

68  {
69  _wcsfixCtrl = // ctrl for wcsfix
70  2; // Translate "H" to "h"
71  _wcshdrCtrl = // ctrl for wcspih
72  2; // Report each rejected keyrecord and the reason why it was rejected
73  _relax = // relax parameter for wcspih;
74  WCSHDR_all; // Accept all extensions recognized by the parser
75 }
int _wcshdrCtrl
Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.
Definition: Wcs.h:450
int _relax
Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details.
Definition: Wcs.h:448
int _wcsfixCtrl
Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes.
Definition: Wcs.h:449

◆ census() [1/3]

int lsst::daf::base::Citizen::census ( int  ,
memId  startingMemId = 0 
)
staticinherited

How many active Citizens are there?

Parameters
startingMemIdDon't print Citizens with lower IDs

Definition at line 267 of file Citizen.cc.

270  {
271  if (startingMemId == 0) { // easy
272  ReadGuard guard(citizenLock);
273  return _activeCitizens.size();
274  }
275 
276  int n = 0;
277  ReadGuard guard(citizenLock);
278  for (table::iterator cur = _activeCitizens.begin();
279  cur != _activeCitizens.end(); cur++) {
280  if (cur->first->_CitizenId >= startingMemId) {
281  n++;
282  }
283  }
284 
285  return n;
286 }
T end(T... args)
static table _activeCitizens
Definition: Citizen.h:102
T size(T... args)
T begin(T... args)

◆ census() [2/3]

void lsst::daf::base::Citizen::census ( std::ostream stream,
memId  startingMemId = 0 
)
staticinherited

Print a list of all active Citizens to stream, sorted by ID.

Parameters
streamstream to print to
startingMemIdDon't print Citizens with lower IDs

Definition at line 290 of file Citizen.cc.

293  {
294  ReadGuard guard(citizenLock);
295 
297 
298  for (std::vector<Citizen const *>::const_iterator citizen = leaks->begin(), end = leaks->end();
299  citizen != end; ++citizen) {
300  if ((*citizen)->getId() >= startingMemId) {
301  stream << (*citizen)->repr() << "\n";
302  }
303  }
304 }
int end
STL class.
STL class.
T begin(T... args)
static const std::vector< const Citizen * > * census()
Return a (newly allocated) std::vector of active Citizens sorted by ID.
Definition: Citizen.cc:322

◆ census() [3/3]

std::vector< dafBase::Citizen const * > const * lsst::daf::base::Citizen::census ( )
staticinherited

Return a (newly allocated) std::vector of active Citizens sorted by ID.

You are responsible for deleting it; or you can say std::unique_ptr<std::vector<Citizen const*> const> leaks(Citizen::census()); and not bother (that becomes std::unique_ptr in C++11)

Definition at line 322 of file Citizen.cc.

322  {
325  ReadGuard guard(citizenLock);
326  vec->reserve(_activeCitizens.size());
327 
328  for (table::iterator cur = _activeCitizens.begin();
329  cur != _activeCitizens.end(); cur++) {
330  vec->push_back(dynamic_cast<Citizen const*>(cur->first));
331  }
332 
333  std::sort(vec->begin(), vec->end(), cmpId);
334 
335  return vec;
336 }
T end(T... args)
static table _activeCitizens
Definition: Citizen.h:102
T push_back(T... args)
T size(T... args)
STL class.
T begin(T... args)
T sort(T... args)
T reserve(T... args)

◆ clone()

std::shared_ptr< Wcs > lsst::afw::image::DistortedTanWcs::clone ( void  ) const
virtual

Polymorphic deep-copy.

Reimplemented from lsst::afw::image::Wcs.

Definition at line 41 of file DistortedTanWcs.cc.

41  {
42  return std::shared_ptr<Wcs>(new DistortedTanWcs(*this));
43 }
DistortedTanWcs(TanWcs const &tanWcs, Transform const &pixelsToTanPixels)
Construct a DistortedTanWcs.

◆ convertCoordToSky()

std::shared_ptr< coord::Coord > lsst::afw::image::Wcs::convertCoordToSky ( coord::Coord const &  coord) const
protectedinherited

Given a Coord (as a shared pointer), return the sky position in the correct coordinate system for this Wcs.

Definition at line 741 of file Wcs.cc.

741  {
742  return coord.convert(_coordSystem, _wcsInfo->equinox);
743 }
struct wcsprm * _wcsInfo
Definition: Wcs.h:446
coord::CoordSystem _coordSystem
Definition: Wcs.h:452

◆ decodeSipHeader()

static void lsst::afw::image::TanWcs::decodeSipHeader ( daf::base::PropertySet const &  fitsMetadata,
std::string const &  which,
Eigen::MatrixXd &  m 
)
staticinherited

Decode the SIP headers for a given matrix, if present.

◆ distortPixel()

geom::Point2D lsst::afw::image::TanWcs::distortPixel ( geom::Point2D const &  pixel) const
inherited

Applies the SIP AP and BP distortion (used in the skyToPixel direction)

◆ flipImage()

void lsst::afw::image::DistortedTanWcs::flipImage ( int  flipLR,
int  flipTB,
lsst::afw::geom::Extent2I  dimensions 
) const
virtual
Warning
not implemented

Reimplemented from lsst::afw::image::Wcs.

Definition at line 49 of file DistortedTanWcs.cc.

49  {
50  throw LSST_EXCEPT(pex::exceptions::LogicError, "flipImage is not implemented");
51 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ getCDMatrix()

Eigen::Matrix2d lsst::afw::image::Wcs::getCDMatrix ( ) const
inherited

Returns the CD matrix.

Definition at line 550 of file Wcs.cc.

550  {
551  assert(_wcsInfo);
552  int const naxis = _wcsInfo->naxis;
553 
554  // If naxis != 2, I'm not sure if any of what follows is correct
555  assert(naxis == 2);
556 
557  Eigen::Matrix2d C;
558 
559  for (int i = 0; i < naxis; ++i) {
560  for (int j = 0; j < naxis; ++j) {
561  C(i, j) = _wcsInfo->cd[(i * naxis) + j];
562  }
563  }
564 
565  return C;
566 }
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ getCoordSystem()

afw::coord::CoordSystem lsst::afw::image::Wcs::getCoordSystem ( ) const
inlineinherited

Definition at line 229 of file Wcs.h.

229 { return _coordSystem; };
coord::CoordSystem _coordSystem
Definition: Wcs.h:452

◆ getEquinox()

double lsst::afw::image::Wcs::getEquinox ( ) const
inherited

Definition at line 789 of file Wcs.cc.

789  {
790  if (_wcsInfo == nullptr) {
792  }
793  return _wcsInfo->equinox;
794 }
T quiet_NaN(T... args)
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ getFitsMetadata()

std::shared_ptr<daf::base::PropertyList> lsst::afw::image::TanWcs::getFitsMetadata ( ) const
overridevirtualinherited

Return a PropertyList containing FITS header keywords that can be used to save the Wcs.x.

Reimplemented from lsst::afw::image::Wcs.

◆ getId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getId ( ) const
inherited

Return the Citizen's ID.

Definition at line 224 of file Citizen.cc.

224  {
225  return _CitizenId;
226 }

◆ getLinearTransform()

geom::LinearTransform lsst::afw::image::Wcs::getLinearTransform ( ) const
inherited

Return the linear part of the Wcs, the CD matrix in FITS-speak, as an AffineTransform.

Definition at line 916 of file Wcs.cc.

916 { return geom::LinearTransform(getCDMatrix()); }
A 2D linear coordinate transformation.
Eigen::Matrix2d getCDMatrix() const
Returns the CD matrix.
Definition: Wcs.cc:550

◆ getNextMemId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getNextMemId ( )
staticinherited

Return the memId of the next object to be allocated.

Definition at line 229 of file Citizen.cc.

229  {
230  return _nextMemId();
231 }
static memId _nextMemId(void)
Return the memId of the next object to be allocated.
Definition: Citizen.cc:234

◆ getPixelOrigin()

GeomPoint lsst::afw::image::Wcs::getPixelOrigin ( ) const
inherited

Returns CRPIX (corrected to LSST convention).

Definition at line 542 of file Wcs.cc.

542  {
543  assert(_wcsInfo);
544  // Convert from fits units back to lsst units
545  double p1 = _wcsInfo->crpix[0] + fitsToLsstPixels;
546  double p2 = _wcsInfo->crpix[1] + fitsToLsstPixels;
547  return geom::Point2D(p1, p2);
548 }
Point< double, 2 > Point2D
Definition: Point.h:300
const int fitsToLsstPixels
Definition: Wcs.cc:78
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ getPixelToTanPixel()

std::shared_ptr<Transform> lsst::afw::image::DistortedTanWcs::getPixelToTanPixel ( ) const
inline

return the PIXELS to TAN_PIXELS Transform

Definition at line 96 of file DistortedTanWcs.h.

96  {
97  return std::make_shared<Transform>(*_pixelsToTanPixelsPtr);
98  }

◆ getPythonModule()

std::string lsst::afw::image::Wcs::getPythonModule ( ) const
protectedvirtualinherited

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.

Definition at line 982 of file Wcs.cc.

982 { return "lsst.afw.image"; }

◆ getSipA()

Eigen::MatrixXd const& lsst::afw::image::TanWcs::getSipA ( ) const
inlineinherited

Return the SIP forward distortion matrix for the 1st intermediate world coordinate system axis.

Definition at line 149 of file TanWcs.h.

149 { return _sipA; }
Eigen::MatrixXd _sipA
Definition: TanWcs.h:201

◆ getSipAp()

Eigen::MatrixXd const& lsst::afw::image::TanWcs::getSipAp ( ) const
inlineinherited

Return the SIP reverse distortion matrix for x pixel coordinates.

Definition at line 155 of file TanWcs.h.

155 { return _sipAp; }
Eigen::MatrixXd _sipAp
Definition: TanWcs.h:201

◆ getSipB()

Eigen::MatrixXd const& lsst::afw::image::TanWcs::getSipB ( ) const
inlineinherited

Return the SIP forward distortion matrix for the 2st intermediate world coordinate system axis.

Definition at line 152 of file TanWcs.h.

152 { return _sipB; }
Eigen::MatrixXd _sipB
Definition: TanWcs.h:201

◆ getSipBp()

Eigen::MatrixXd const& lsst::afw::image::TanWcs::getSipBp ( ) const
inlineinherited

Return the SIP reverse distortion matrix for y pixel coordinates.

Definition at line 158 of file TanWcs.h.

158 { return _sipBp; }
Eigen::MatrixXd _sipBp
Definition: TanWcs.h:201

◆ getSkyOrigin()

CoordPtr lsst::afw::image::Wcs::getSkyOrigin ( ) const
inherited

Returns CRVAL. This need not be the centre of the image.

Definition at line 537 of file Wcs.cc.

537  {
538  assert(_wcsInfo);
539  return makeCorrectCoord(_wcsInfo->crval[0] * geom::degrees, _wcsInfo->crval[1] * geom::degrees);
540 }
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
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...
Definition: Wcs.cc:846
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ getTanWcs()

std::shared_ptr<Wcs> lsst::afw::image::DistortedTanWcs::getTanWcs ( ) const
inline

return the pure tan WCS component

Definition at line 93 of file DistortedTanWcs.h.

93 { return TanWcs::clone(); }
std::shared_ptr< Wcs > clone() const override
Polymorphic deep-copy.

◆ hasBeenCorrupted()

bool lsst::daf::base::Citizen::hasBeenCorrupted ( )
staticinherited

Check all allocated blocks for corruption.

Definition at line 353 of file Citizen.cc.

353  {
354  ReadGuard guard(citizenLock);
355  for (table::iterator cur = _activeCitizens.begin();
356  cur != _activeCitizens.end(); cur++) {
357  if (cur->first->_hasBeenCorrupted()) {
358  return true;
359  }
360  }
361  for (table::iterator cur = _persistentCitizens.begin();
362  cur != _persistentCitizens.end(); cur++) {
363  if (cur->first->_hasBeenCorrupted()) {
364  return true;
365  }
366  }
367 
368  return false;
369 }
T end(T... args)
static table _activeCitizens
Definition: Citizen.h:102
static table _persistentCitizens
Definition: Citizen.h:103
T begin(T... args)

◆ hasDistortion()

bool lsst::afw::image::DistortedTanWcs::hasDistortion ( ) const
inlinevirtual

Reimplemented from lsst::afw::image::Wcs.

Definition at line 90 of file DistortedTanWcs.h.

90 { return true; }

◆ init()

int lsst::daf::base::Citizen::init ( )
staticinherited

Called once when the memory system is being initialised.

Definition at line 214 of file Citizen.cc.

214  {
215  volatile int dummy = 1;
216  return dummy;
217 }

◆ initWcsLibFromFits()

void lsst::afw::image::Wcs::initWcsLibFromFits ( std::shared_ptr< lsst::daf::base::PropertySet const > const &  fitsMetadata)
protectedinherited

Parse a fits header, extract the relevant metadata and create a Wcs object.

Definition at line 160 of file Wcs.cc.

160  {
161  /*
162  * Access control for the input header
163  *
164  * We want to hack up the input, and in order to do so we need to do a deep copy on it.
165  * We only want to do that copy once, and would like to avoid doing it altogether.
166  */
167  class HeaderAccess {
168  public:
169  // Return a readable version of the metadata
170  std::shared_ptr<daf::base::PropertySet const> const& toRead() { return _constHeader; }
171  // Return a writable version of the metadata
172  std::shared_ptr<daf::base::PropertySet> const& toWrite() {
173  if (!_hackHeader) {
174  _hackHeader = _constHeader->deepCopy();
175  _constHeader = _hackHeader;
176  }
177  return _hackHeader;
178  }
179 
180  // Ctor
181  HeaderAccess(std::shared_ptr<daf::base::PropertySet const> const& header)
182  : _constHeader(header), _hackHeader() {}
183 
184  private:
187  };
188 
189  HeaderAccess access(header);
190 
191  // Some headers (e.g. SDSS ones from FNAL) have EQUINOX as a string. Fix this,
192  // as wcslib 4.4.4 refuses to handle it. Furthermore, some headers (e.g. Skymapper)
193  // use a string but prepend 'J': "J2000.0" -- if we don't handle this, we deduce
194  // an equinox of 0.0
195  {
196  std::string const& key = "EQUINOX";
197  if (access.toRead()->exists(key) && access.toRead()->typeOf(key) == typeid(std::string)) {
198  auto equinoxStr = access.toRead()->getAsString(key).c_str();
199  double equinox = ::atof(equinoxStr[0] == 'J' ? equinoxStr + 1 : equinoxStr);
200  access.toWrite()->set(key, equinox);
201  }
202  }
203 
204  //Check header isn't empty
205  int nCards = lsst::afw::formatters::countFitsHeaderCards(*(access.toRead()));
206  if (nCards <= 0) {
207  string msg = "Could not parse FITS WCS: no header cards found";
209  }
210 
211  // While the standard does not insist on CRVAL and CRPIX being present, it
212  // is almost certain their absence indicates a problem.
213  // Check for CRPIX
214  if (!access.toRead()->exists("CRPIX1") && !access.toRead()->exists("CRPIX1a")) {
215  string msg = "Neither CRPIX1 not CRPIX1a found";
217  }
218 
219  if (!access.toRead()->exists("CRPIX2") && !access.toRead()->exists("CRPIX2a")) {
220  string msg = "Neither CRPIX2 not CRPIX2a found";
222  }
223 
224  // And the same for CRVAL
225  if (!access.toRead()->exists("CRVAL1") && !access.toRead()->exists("CRVAL1a")) {
226  string msg = "Neither CRVAL1 not CRVAL1a found";
228  }
229 
230  if (!access.toRead()->exists("CRVAL2") && !access.toRead()->exists("CRVAL2a")) {
231  string msg = "Neither CRVAL2 not CRVAL2a found";
233  }
234  /*
235  * According to Greisen and Calabretta (A&A 395, 1061–1075 (2002)) it's illegal to mix PCi_j and CDi_j
236  * headers; unfortunately Subaru puts both in its headers. It actually uses PC001002 instead of PC1_2
237  * (dating to a proposed FITS standard from 1996) and at least sometimes fails to include CDELT[12],
238  * so the CD and PC matrices are inconsistent
239  *
240  * If we detect any part of a CD matrix, delete all PC matrices
241  */
242  if (access.toRead()->exists("CD1_1") || access.toRead()->exists("CD1_2") ||
243  access.toRead()->exists("CD2_1") || access.toRead()->exists("CD2_2")) {
244  for (int i = 1; i <= 2; ++i) {
245  for (int j = 1; j <= 2; ++j) {
246  std::string key = (boost::format("PC%i_%i") % j % i).str();
247  if (access.toRead()->exists(key)) {
248  double const val = access.toRead()->getAsDouble(key);
249  access.toWrite()->remove(key);
250  access.toWrite()->add("X_" + key, val);
251  }
252 
253  key = (boost::format("PC%03d%03d") % j % i).str();
254  if (access.toRead()->exists(key)) {
255  double const val = access.toRead()->getAsDouble(key);
256  access.toWrite()->remove(key);
257  access.toWrite()->add("X_" + key, val);
258  }
259  }
260  }
261  }
262 
263  //Pass the header into wcslib's formatter to extract & setup the Wcs. First need
264  //to convert to a C style string, so the compile doesn't complain about constness
265  std::string metadataStr = formatters::formatFitsProperties(*(access.toRead()));
266  // We own the data, and wcslib is slack about constness, so no qualms with casting away const
267  char* hdrString = const_cast<char*>(metadataStr.c_str());
268  // printf("wcspih string:\n%s\n", hdrString);
269 
270  nCards = formatters::countFitsHeaderCards(*(access.toRead())); // we may have dropped some
271  int pihStatus = wcspih(hdrString, nCards, _relax, _wcshdrCtrl, &_nReject, &_nWcsInfo, &_wcsInfo);
272 
273  if (pihStatus != 0) {
275  (boost::format("Could not parse FITS WCS: wcspih status = %d (%s)") % pihStatus %
276  wcs_errmsg[pihStatus])
277  .str());
278  }
279 
280  // Run wcsfix on _wcsInfo to try and fix any problems it knows about.
281  const int* naxes = NULL; // should be {NAXIS1, NAXIS2, ...} to check cylindrical projections
282  int stats[NWCSFIX]; // status returns from wcsfix
283  int fixStatus = wcsfix(_wcsfixCtrl, naxes, _wcsInfo, stats);
284  if (fixStatus != 0) {
285  std::stringstream errStream;
286  errStream << "Could not parse FITS WCS: wcsfix failed " << std::endl;
287  for (int ii = 0; ii < NWCSFIX; ++ii) {
288  if (stats[ii] >= 0) {
289  errStream << "\t" << ii << ": " << stats[ii] << " " << wcsfix_errmsg[stats[ii]] << std::endl;
290  } else {
291  errStream << "\t" << ii << ": " << stats[ii] << std::endl;
292  }
293  }
294  }
295 
296  // The Wcs standard requires a default value for RADESYS if the keyword
297  // doesn't exist in header, but wcslib doesn't set it. So we do so here. This code
298  // conforms to Calabretta & Greisen 2002 \S 3.1
299  if (!(access.toRead()->exists("RADESYS") || access.toRead()->exists("RADESYSa"))) {
300  // If RADECSYS exists, use that (counter to Calabretta & Greisen 2002 \S 3.1, but commonly used).
301  // If equinox exist and < 1984, use FK4. If >= 1984, use FK5
302  if (access.toRead()->exists("RADECSYS")) {
303  strncpy(_wcsInfo->radesys, access.toRead()->getAsString("RADECSYS").c_str(), STRLEN);
304  } else if (access.toRead()->exists("EQUINOX") || access.toRead()->exists("EQUINOXa")) {
305  std::string const EQUINOX = access.toRead()->exists("EQUINOX") ? "EQUINOX" : "EQUINOXa";
306  double const equinox = access.toRead()->getAsDouble(EQUINOX);
307  if (equinox < 1984) {
308  strncpy(_wcsInfo->radesys, "FK4", STRLEN);
309  } else {
310  strncpy(_wcsInfo->radesys, "FK5", STRLEN);
311  }
312  } else {
313  // If Equinox doesn't exist, default to ICRS
314  strncpy(_wcsInfo->radesys, "ICRS", STRLEN);
315  }
316  }
317  // strip trailing whitespace
318  {
319  for (int i = strlen(_wcsInfo->radesys) - 1; i >= 0; i--) {
320  if (isspace(_wcsInfo->radesys[i])) {
321  _wcsInfo->radesys[i] = '\0';
322  }
323  }
324  }
325  //
326  // If there are no CDi_j cards in the header, set CDi_j from PCi_j
327  // CDi_j == CDELTi*PCi_j
328  //
329  if ((_wcsInfo->altlin & 2) == 0) { // no CDi_j cards were found in the header
330  double const* cdelt = _wcsInfo->cdelt;
331  double const* pc = _wcsInfo->pc;
332  double* cd = _wcsInfo->cd;
333 
334  cd[0] = cdelt[0] * pc[0]; // 1_1
335  cd[1] = cdelt[0] * pc[1]; // 1_2
336  cd[2] = cdelt[1] * pc[2]; // 2_1
337  cd[3] = cdelt[1] * pc[3]; // 2_2
338  }
339 }
std::string formatFitsProperties(lsst::daf::base::PropertySet const &prop, std::set< std::string > const &excludeNames={})
Format a PropertySet into a single FITS header string.
Definition: Utils.cc:267
T endl(T... args)
STL class.
T strncpy(T... args)
T strlen(T... args)
table::Key< double > equinox
Definition: Wcs.cc:939
const int STRLEN
Definition: Wcs.cc:61
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
int countFitsHeaderCards(lsst::daf::base::PropertySet const &prop)
Definition: Utils.cc:279
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
int _wcshdrCtrl
Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.
Definition: Wcs.h:450
int _relax
Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details.
Definition: Wcs.h:448
T c_str(T... args)
int _wcsfixCtrl
Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes.
Definition: Wcs.h:449
table::Key< table::Array< double > > cd
Definition: Wcs.cc:936
ImageT val
Definition: CR.cc:158
T isspace(T... args)
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ isFlipped()

bool lsst::afw::image::Wcs::isFlipped ( ) const
inherited

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.

Definition at line 648 of file Wcs.cc.

648  {
649  // We calculate the determinant of the CD (i.e the rotation and scaling)
650  // matrix. If this determinant is positive, then the image can be rotated
651  // to a position where increasing the right ascension and declination
652  // increases the horizontal and vertical pixel position. In this case the
653  // image is flipped.
654  assert(_wcsInfo);
655  double det = (_wcsInfo->cd[0] * _wcsInfo->cd[3]) - (_wcsInfo->cd[1] * _wcsInfo->cd[2]);
656 
657  if (det == 0) {
658  throw(LSST_EXCEPT(except::RuntimeError, "Wcs CD matrix is singular"));
659  }
660 
661  return (det > 0);
662 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ isPersistable()

bool lsst::afw::image::DistortedTanWcs::isPersistable ( ) const
inlinevirtual

Whether the Wcs is persistable using afw::table::io archives.

Reimplemented from lsst::afw::image::Wcs.

Definition at line 88 of file DistortedTanWcs.h.

88 { return false; }

◆ isSameSkySystem()

bool lsst::afw::image::Wcs::isSameSkySystem ( Wcs const &  wcs) const
inherited

Return true if a WCS has the same coordinate system and equinox as this one.

There are two special cases:

  • Equinox is ignored if the coordinate system is ICRS
  • FK5 J2000 is considered the same as ICRS

Definition at line 796 of file Wcs.cc.

796  {
797  if (_isIcrs() && wcs._isIcrs()) {
798  return true;
799  }
800  return (getCoordSystem() == wcs.getCoordSystem()) && (getEquinox() == wcs.getEquinox());
801 }
bool _isIcrs() const
Definition: Wcs.h:371
afw::coord::CoordSystem getCoordSystem() const
Definition: Wcs.h:229
tbl::Key< int > wcs
double getEquinox() const
Definition: Wcs.cc:789

◆ linearizePixelToSky() [1/2]

geom::AffineTransform lsst::afw::image::Wcs::linearizePixelToSky ( coord::Coord const &  coord,
geom::AngleUnit  skyUnit = geom::degrees 
) const
inherited

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

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.

Definition at line 868 of file Wcs.cc.

868  {
869  return linearizePixelToSkyInternal(skyToPixel(coord), coord, skyUnit);
870 }
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g.
Definition: Wcs.cc:745
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...
Definition: Wcs.cc:875

◆ linearizePixelToSky() [2/2]

geom::AffineTransform lsst::afw::image::Wcs::linearizePixelToSky ( geom::Point2D const &  pix,
geom::AngleUnit  skyUnit = geom::degrees 
) const
inherited

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

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

Definition at line 871 of file Wcs.cc.

871  {
872  return linearizePixelToSkyInternal(pix, *pixelToSky(pix), skyUnit);
873 }
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:827
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...
Definition: Wcs.cc:875

◆ linearizePixelToSkyInternal()

geom::AffineTransform lsst::afw::image::Wcs::linearizePixelToSkyInternal ( geom::Point2D const &  pix,
coord::Coord const &  coord,
geom::AngleUnit  skyUnit 
) const
protectedvirtualinherited

Implementation for the overloaded public linearizePixelToSky methods, requiring both a pixel coordinate and the corresponding sky coordinate.

Definition at line 875 of file Wcs.cc.

876  {
877  //
878  // Figure out the (0, 0), (0, 1), and (1, 0) ra/dec coordinates of the corners of a square drawn in pixel
879  // It'd be better to centre the square at sky00, but that would involve another conversion between sky and
880  // pixel coordinates so I didn't bother
881  //
882  const double side = 10; // length of the square's sides in pixels
883  GeomPoint const sky00 = coord.getPosition(skyUnit);
884  typedef std::pair<geom::Angle, geom::Angle> AngleAngle;
885  AngleAngle const dsky10 = coord.getTangentPlaneOffset(*pixelToSky(pix00 + geom::Extent2D(side, 0)));
886  AngleAngle const dsky01 = coord.getTangentPlaneOffset(*pixelToSky(pix00 + geom::Extent2D(0, side)));
887 
888  Eigen::Matrix2d m;
889  m(0, 0) = dsky10.first.asAngularUnits(skyUnit) / side;
890  m(0, 1) = dsky01.first.asAngularUnits(skyUnit) / side;
891  m(1, 0) = dsky10.second.asAngularUnits(skyUnit) / side;
892  m(1, 1) = dsky01.second.asAngularUnits(skyUnit) / side;
893 
894  Eigen::Vector2d sky00v;
895  sky00v << sky00.getX(), sky00.getY();
896  Eigen::Vector2d pix00v;
897  pix00v << pix00.getX(), pix00.getY();
898  // return geom::AffineTransform(m, geom::Extent2D(sky00v - m * pix00v));
899  return geom::AffineTransform(m, (sky00v - m * pix00v));
900 }
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:827
An affine coordinate transformation consisting of a linear transformation and an offset.

◆ linearizeSkyToPixel() [1/2]

geom::AffineTransform lsst::afw::image::Wcs::linearizeSkyToPixel ( coord::Coord const &  coord,
geom::AngleUnit  skyUnit = geom::degrees 
) const
inherited

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

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.

Definition at line 902 of file Wcs.cc.

902  {
903  return linearizeSkyToPixelInternal(skyToPixel(coord), coord, skyUnit);
904 }
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...
Definition: Wcs.cc:910
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g.
Definition: Wcs.cc:745

◆ linearizeSkyToPixel() [2/2]

geom::AffineTransform lsst::afw::image::Wcs::linearizeSkyToPixel ( geom::Point2D const &  pix,
geom::AngleUnit  skyUnit = geom::degrees 
) const
inherited

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

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

Definition at line 906 of file Wcs.cc.

906  {
907  return linearizeSkyToPixelInternal(pix, *pixelToSky(pix), skyUnit);
908 }
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...
Definition: Wcs.cc:910
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:827

◆ linearizeSkyToPixelInternal()

geom::AffineTransform lsst::afw::image::Wcs::linearizeSkyToPixelInternal ( geom::Point2D const &  pix,
coord::Coord const &  coord,
geom::AngleUnit  skyUnit 
) const
protectedvirtualinherited

Implementation for the overloaded public linearizeSkyToPixel methods, requiring both a pixel coordinate and the corresponding sky coordinate.

Definition at line 910 of file Wcs.cc.

911  {
912  geom::AffineTransform inverse = linearizePixelToSkyInternal(pix00, coord, skyUnit);
913  return inverse.invert();
914 }
An affine coordinate transformation consisting of a linear transformation and an offset.
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...
Definition: Wcs.cc:875
AffineTransform const invert() const
Return the inverse transform.

◆ makeCorrectCoord()

CoordPtr lsst::afw::image::Wcs::makeCorrectCoord ( geom::Angle  sky0,
geom::Angle  sky1 
) const
protectedinherited

Given a sky position, use the values stored in ctype and radesys to return the correct sub-class of Coord.

Definition at line 846 of file Wcs.cc.

846  {
847  auto coordSystem = getCoordSystem();
848  if ((coordSystem == coord::ICRS) || (coordSystem == coord::GALACTIC)) {
849  // equinox not relevant
850  if (_skyAxesSwapped) {
851  return coord::makeCoord(coordSystem, sky1, sky0);
852  } else {
853  return coord::makeCoord(coordSystem, sky0, sky1);
854  }
855  } else if ((coordSystem == coord::FK5) || (coordSystem == coord::ECLIPTIC)) {
856  if (_skyAxesSwapped) {
857  return coord::makeCoord(coordSystem, sky1, sky0, _wcsInfo->equinox);
858  } else {
859  return coord::makeCoord(coordSystem, sky0, sky1, _wcsInfo->equinox);
860  }
861  }
862  throw LSST_EXCEPT(
864  (boost::format("Can't create Coord object: Unrecognised coordinate system %s") % coordSystem)
865  .str());
866 }
std::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:846
afw::coord::CoordSystem getCoordSystem() const
Definition: Wcs.h:229
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
bool _skyAxesSwapped
if true then the sky axes are swapped
Definition: Wcs.h:453
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ markPersistent()

void lsst::daf::base::Citizen::markPersistent ( void  )
inherited

Mark a Citizen as persistent and not destroyed until process end.

Definition at line 254 of file Citizen.cc.

254  {
255  WriteGuard guard(citizenLock);
256  _persistentCitizens[this] = _activeCitizens[this];
257  _activeCitizens.erase(this);
258 }
static table _activeCitizens
Definition: Citizen.h:102
T erase(T... args)
static table _persistentCitizens
Definition: Citizen.h:103

◆ operator!=()

bool lsst::afw::image::Wcs::operator!= ( Wcs const &  other) const
inlineinherited

Definition at line 141 of file Wcs.h.

141 { return !(*this == other); }

◆ operator=() [1/2]

DistortedTanWcs& lsst::afw::image::DistortedTanWcs::operator= ( DistortedTanWcs const &  )
delete

◆ operator=() [2/2]

DistortedTanWcs& lsst::afw::image::DistortedTanWcs::operator= ( DistortedTanWcs &&  )
delete

◆ operator==()

bool lsst::afw::image::DistortedTanWcs::operator== ( Wcs const &  other) const
Warning
not implemented (because Transform operator== is not implemented)

Definition at line 45 of file DistortedTanWcs.cc.

45  {
46  throw LSST_EXCEPT(pex::exceptions::LogicError, "== is not implemented");
47 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ pixArea()

double lsst::afw::image::Wcs::pixArea ( lsst::afw::geom::Point2D  pix00) const
inherited

Sky area covered by a pixel at position pix00 in units of square degrees.

Parameters
pix00The pixel point where the area is desired

Definition at line 666 of file Wcs.cc.

666  {
667  //
668  // Figure out the (0, 0), (0, 1), and (1, 0) ra/dec coordinates of the corners of a square drawn in pixel
669  // It'd be better to centre the square at sky00, but that would involve another conversion between sky and
670  // pixel coordinates so I didn't bother
671  //
672  const double side = 1; // length of the square's sides in pixels
673 
674  // Work in 3-space to avoid RA wrapping and pole issues.
675  geom::Point3D v0 = pixelToSky(pix00)->getVector();
676 
677  // Step by "side" in x and y pixel directions...
678  GeomPoint px(pix00);
679  GeomPoint py(pix00);
680  px.shift(geom::Extent2D(side, 0));
681  py.shift(geom::Extent2D(0, side));
682  // Push the points through the WCS, and find difference in 3-space.
683  geom::Extent3D dx = pixelToSky(px)->getVector() - v0;
684  geom::Extent3D dy = pixelToSky(py)->getVector() - v0;
685 
686  // Compute |cross product| = area of parallelogram with sides dx,dy
687  // FIXME -- this is slightly incorrect -- it's making the small-angle
688  // approximation, taking the distance *through* the unit sphere
689  // rather than over its surface.
690  // This is in units of ~radians^2
691  double area = sqrt(square(dx[1] * dy[2] - dx[2] * dy[1]) + square(dx[2] * dy[0] - dx[0] * dy[2]) +
692  square(dx[0] * dy[1] - dx[1] * dy[0]));
693 
694  return area / square(side) * square(180. / geom::PI);
695 }
A coordinate class intended to represent absolute positions.
double constexpr PI
The ratio of a circle&#39;s circumference to diameter.
Definition: Angle.h:21
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:827
T sqrt(T... args)

◆ pixelScale()

geom::Angle lsst::afw::image::TanWcs::pixelScale ( ) const
inherited

Returns the pixel scale, in Angle/pixel.

◆ pixelToSky() [1/3]

CoordPtr lsst::afw::image::Wcs::pixelToSky ( double  pix1,
double  pix2 
) const
inherited

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.

Definition at line 827 of file Wcs.cc.

827  {
828  assert(_wcsInfo);
829 
830  geom::Angle skyTmp[2];
831  pixelToSkyImpl(pixel1, pixel2, skyTmp);
832  return makeCorrectCoord(skyTmp[0], skyTmp[1]);
833 }
A class representing an angle.
Definition: Angle.h:102
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...
Definition: Wcs.cc:846
virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const
Worker routine for pixelToSky.
Definition: Wcs.cc:803
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ pixelToSky() [2/3]

CoordPtr lsst::afw::image::Wcs::pixelToSky ( lsst::afw::geom::Point2D const &  pixel) const
inherited

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.

Definition at line 825 of file Wcs.cc.

825 { return pixelToSky(pixel.getX(), pixel.getY()); }
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:827
table::PointKey< int > pixel

◆ pixelToSky() [3/3]

void lsst::afw::image::Wcs::pixelToSky ( double  pixel1,
double  pixel2,
geom::Angle sky1,
geom::Angle sky2 
) const
inherited

Convert from pixel position to sky coordinates (e.g.

RA/dec)

Note
This routine is designed for the knowledgeable user in need of performance; it's safer to call the version that returns a std::shared_ptr<Coord>.

Definition at line 835 of file Wcs.cc.

835  {
836  geom::Angle skyTmp[2];
837  // HACK -- we shouldn't need to initialize these -- pixelToSkyImpl() sets them unless an
838  // exception is thrown -- but be safe.
839  skyTmp[0] = 0. * geom::radians;
840  skyTmp[1] = 0. * geom::radians;
841  pixelToSkyImpl(pixel1, pixel2, skyTmp);
842  sky1 = skyTmp[0];
843  sky2 = skyTmp[1];
844 }
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
A class representing an angle.
Definition: Angle.h:102
virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const
Worker routine for pixelToSky.
Definition: Wcs.cc:803

◆ pixelToSkyImpl()

void lsst::afw::image::DistortedTanWcs::pixelToSkyImpl ( double  pixel1,
double  pixel2,
geom::Angle  skyTmp[2] 
) const
protectedvirtual

Worker routine for skyToPixel.

Parameters
[in]pixel1pixel position, x
[in]pixel2pixel position, y
[in]skyTmpsky position, longitude, latitude (e.g. RA, Dec)

Reimplemented from lsst::afw::image::Wcs.

Definition at line 66 of file DistortedTanWcs.cc.

66  {
67  auto const pos = geom::Point2D(pixel1, pixel2);
68  auto const tanPos = _pixelsToTanPixelsPtr->applyForward(pos);
69  TanWcs::pixelToSkyImpl(tanPos[0], tanPos[1], sky);
70 }
void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const override
Worker routine for pixelToSky.
Point< double, 2 > Point2D
Definition: Point.h:300
std::shared_ptr< Transform > _pixelsToTanPixelsPtr

◆ readFits() [1/6]

static std::shared_ptr<TanWcs > lsst::afw::table::io::PersistableFacade< TanWcs >::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 std::dynamic_pointer_cast<T>(Persistable::_readFits(fitsfile));
185  }
T dynamic_pointer_cast(T... args)

◆ readFits() [2/6]

static std::shared_ptr<Wcs > lsst::afw::table::io::PersistableFacade< Wcs >::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 std::dynamic_pointer_cast<T>(Persistable::_readFits(fitsfile));
185  }
T dynamic_pointer_cast(T... args)

◆ readFits() [3/6]

static std::shared_ptr<Wcs > lsst::afw::table::io::PersistableFacade< Wcs >::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 std::dynamic_pointer_cast<T>(Persistable::_readFits(fileName, hdu));
196  }
T dynamic_pointer_cast(T... args)

◆ readFits() [4/6]

static std::shared_ptr<TanWcs > lsst::afw::table::io::PersistableFacade< TanWcs >::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 std::dynamic_pointer_cast<T>(Persistable::_readFits(fileName, hdu));
196  }
T dynamic_pointer_cast(T... args)

◆ readFits() [5/6]

static std::shared_ptr<TanWcs > lsst::afw::table::io::PersistableFacade< TanWcs >::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 std::dynamic_pointer_cast<T>(Persistable::_readFits(manager, hdu));
207  }
T dynamic_pointer_cast(T... args)

◆ readFits() [6/6]

static std::shared_ptr<Wcs > lsst::afw::table::io::PersistableFacade< Wcs >::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 std::dynamic_pointer_cast<T>(Persistable::_readFits(manager, hdu));
207  }
T dynamic_pointer_cast(T... args)

◆ repr()

std::string lsst::daf::base::Citizen::repr ( ) const
inherited

Return a string representation of a Citizen.

Definition at line 245 of file Citizen.cc.

245  {
246  return boost::str(boost::format("%d: %08x %s")
247  % _CitizenId
248  % this
250  );
251 }
std::string demangleType(std::string const _typeName)
Definition: Demangle.cc:113
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
const char * _typeName
Definition: Citizen.h:94

◆ rotateImageBy90()

void lsst::afw::image::DistortedTanWcs::rotateImageBy90 ( int  nQuarter,
lsst::afw::geom::Extent2I  dimensions 
) const
virtual
Warning
not implemented

Reimplemented from lsst::afw::image::Wcs.

Definition at line 53 of file DistortedTanWcs.cc.

53  {
54  throw LSST_EXCEPT(pex::exceptions::LogicError, "rotateImageBy90 is not implemented");
55 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ serialize()

template<class Archive >
void lsst::daf::base::Persistable::serialize ( Archive &  ,
unsigned int  const 
)
inlineinherited

Template boost::serialization function for the base class.

Doesn't actually do anything, since there is no data associated with the base. Inline to allow expansion wherever needed.

Definition at line 86 of file Persistable.h.

86 { }

◆ setCorruptionCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setCorruptionCallback ( Citizen::memCallback  func)
staticinherited

Set the CorruptionCallback function.

Parameters
funcfunction be called when block is found to be corrupted

Definition at line 432 of file Citizen.cc.

434  {
436  _corruptionCallback = func;
437 
438  return old;
439 }
memId(* memCallback)(const Citizen *ptr)
Definition: Citizen.h:59
static memCallback _corruptionCallback
Definition: Citizen.h:113

◆ setDeleteCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setDeleteCallback ( Citizen::memCallback  func)
staticinherited

Set the DeleteCallback function.

Parameters
funcfunction be called when desired block is deleted

Definition at line 422 of file Citizen.cc.

424  {
426  _deleteCallback = func;
427 
428  return old;
429 }
static memCallback _deleteCallback
Definition: Citizen.h:112
memId(* memCallback)(const Citizen *ptr)
Definition: Citizen.h:59

◆ setDeleteCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setDeleteCallbackId ( Citizen::memId  id)
staticinherited

Call the current DeleteCallback when block is deleted.

Parameters
idDesired ID

Definition at line 387 of file Citizen.cc.

389  {
390  WriteGuard guard(citizenLock);
391  Citizen::memId oldId = _deleteId;
392  _deleteId = id;
393 
394  return oldId;
395 }
unsigned long memId
Type of the block&#39;s ID.
Definition: Citizen.h:56
int id
Definition: CR.cc:155
static memId _deleteId
Definition: Citizen.h:109

◆ setDistortionMatrices()

void lsst::afw::image::TanWcs::setDistortionMatrices ( Eigen::MatrixXd const &  sipA,
Eigen::MatrixXd const &  sipB,
Eigen::MatrixXd const &  sipAp,
Eigen::MatrixXd const &  sipBp 
)
inherited

Set the distortion matrices.

Parameters
sipAForward distortion matrix for 1st axis
sipBForward distortion matrix for 2nd axis
sipApReverse distortion matrix for 1st axis
sipBpReverse distortion matrix for 2nd axis

Because the base class provides the option of creating a Wcs without distortion coefficients we supply a way of setting them here. This also help make code neater by breaking an enormous constructor (above) into two small pieces.

◆ setNewCallback()

dafBase::Citizen::memNewCallback lsst::daf::base::Citizen::setNewCallback ( Citizen::memNewCallback  func)
staticinherited

Set the NewCallback function.

Parameters
funcThe new function to be called when a designated block is allocated

Definition at line 412 of file Citizen.cc.

414  {
416  _newCallback = func;
417 
418  return old;
419 }
memId(* memNewCallback)(const memId cid)
A function used to register a callback.
Definition: Citizen.h:58
static memNewCallback _newCallback
Definition: Citizen.h:111

◆ setNewCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setNewCallbackId ( Citizen::memId  id)
staticinherited

Call the NewCallback when block is allocated.

Parameters
idDesired ID

Definition at line 376 of file Citizen.cc.

378  {
379  WriteGuard guard(citizenLock);
380  Citizen::memId oldId = _newId;
381  _newId = id;
382 
383  return oldId;
384 }
unsigned long memId
Type of the block&#39;s ID.
Definition: Citizen.h:56
static memId _newId
Definition: Citizen.h:108
int id
Definition: CR.cc:155

◆ shiftReferencePixel() [1/2]

void lsst::afw::image::DistortedTanWcs::shiftReferencePixel ( double  dx,
double  dy 
)
virtual
Warning
not implemented

Reimplemented from lsst::afw::image::Wcs.

Definition at line 57 of file DistortedTanWcs.cc.

57  {
58  throw LSST_EXCEPT(pex::exceptions::LogicError, "shiftReferencePixel is not implemented");
59 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ shiftReferencePixel() [2/2]

virtual void lsst::afw::image::Wcs::shiftReferencePixel ( geom::Extent2D const &  d)
inlinevirtualinherited

Definition at line 333 of file Wcs.h.

333 { shiftReferencePixel(d.getX(), d.getY()); }
virtual void shiftReferencePixel(double dx, double dy)
Move the pixel reference position by (dx, dy)
Definition: Wcs.cc:1057

◆ skyToIntermediateWorldCoord()

GeomPoint lsst::afw::image::Wcs::skyToIntermediateWorldCoord ( coord::Coord const &  coord) const
inherited

Convert from sky coordinates (e.g.

RA/dec) to intermediate world coordinates

Intermediate world coordinates are in DEGREES.

Definition at line 747 of file Wcs.cc.

747  {
748  assert(_wcsInfo);
749 
751  double skyTmp[2];
752  double imgcrd[2];
753  double phi, theta;
754  double pixTmp[2];
755 
756  /*
757  printf("skyToIWC: _coordSystem = %i\n", (int)_coordSystem);
758  printf("coord (%.3f, %.3f)\n", coord->getLongitude().asDegrees(), coord->getLatitude().asDegrees());
759  printf("->sky (%.3f, %.3f)\n", sky->getLongitude().asDegrees(), sky->getLatitude().asDegrees());
760  */
761 
762  skyTmp[_wcsInfo->lng] = sky->getLongitude().asDegrees();
763  skyTmp[_wcsInfo->lat] = sky->getLatitude().asDegrees();
764 
765  // Estimate pixel coordinates
766  int stat[1];
767  int status = 0;
768  imgcrd[0] = imgcrd[1] = -1e6;
769  /*
770  printf(" skyTmp[] = (%.3f, %.3f)\n", skyTmp[0], skyTmp[1]);
771  printf(" _wcsInfo->lng,lat = %i, %i\n", _wcsInfo->lng, _wcsInfo->lat);
772  */
773  status = wcss2p(_wcsInfo, 1, 2, skyTmp, &phi, &theta, imgcrd, pixTmp, stat);
774  if (status > 0) {
776  (boost::format("Error: wcslib returned a status code of %d at sky %s, %s deg: %s") %
777  status % skyTmp[0] % skyTmp[1] % wcs_errmsg[status])
778  .str());
779  }
780  /*
781  printf("->iwc (%.3f, %.3f)\n", imgcrd[0], imgcrd[1]);
782  printf("-> pix (%.2f, %.2f)\n", pixTmp[0], pixTmp[1]);
783  std::shared_ptr<coord::Coord> crval = getSkyOrigin();
784  printf("(crval is (%.3f, %.3f))\n", crval->getLongitude().asDegrees(), crval->getLatitude().asDegrees());
785  */
786  return GeomPoint(imgcrd[0], imgcrd[1]);
787 }
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...
Definition: Wcs.cc:741
lsst::afw::geom::Point2D GeomPoint
Definition: Wcs.cc:57
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ skyToPixel() [1/2]

GeomPoint lsst::afw::image::Wcs::skyToPixel ( geom::Angle  sky1,
geom::Angle  sky2 
) const
inherited

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.

Definition at line 745 of file Wcs.cc.

745 { return skyToPixelImpl(sky1, sky2); }
virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const
Worker routine for skyToPixel.
Definition: Wcs.cc:699

◆ skyToPixel() [2/2]

GeomPoint lsst::afw::image::Wcs::skyToPixel ( coord::Coord const &  coord) const
inherited

Convert from sky coordinates (e.g. RA/dec) to pixel positions.

Definition at line 736 of file Wcs.cc.

736  {
738  return skyToPixelImpl(sky->getLongitude(), sky->getLatitude());
739 }
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...
Definition: Wcs.cc:741
virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const
Worker routine for skyToPixel.
Definition: Wcs.cc:699

◆ skyToPixelImpl()

geom::Point2D lsst::afw::image::DistortedTanWcs::skyToPixelImpl ( geom::Angle  sky1,
geom::Angle  sky2 
) const
protectedvirtual

Worker routine for pixelToSky.

Parameters
[out]sky1sky position, longitude (e.g. RA)
[out]sky2sky position, latitude (e.g. Dec)

Reimplemented from lsst::afw::image::Wcs.

Definition at line 61 of file DistortedTanWcs.cc.

61  {
62  auto const tanPos = TanWcs::skyToPixelImpl(sky1, sky2);
63  return _pixelsToTanPixelsPtr->applyInverse(tanPos);
64 }
geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const override
Worker routine for skyToPixel.
std::shared_ptr< Transform > _pixelsToTanPixelsPtr

◆ undistortPixel()

geom::Point2D lsst::afw::image::TanWcs::undistortPixel ( geom::Point2D const &  pixel) const
inherited

Applies the SIP A and B un-distortion (used in the pixelToSky direction)

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

Member Data Documentation

◆ _coordSystem

coord::CoordSystem lsst::afw::image::Wcs::_coordSystem
protectedinherited

Definition at line 452 of file Wcs.h.

◆ _nReject

int lsst::afw::image::Wcs::_nReject
protectedinherited

Definition at line 451 of file Wcs.h.

◆ _nWcsInfo

int lsst::afw::image::Wcs::_nWcsInfo
protectedinherited

Definition at line 447 of file Wcs.h.

◆ _pixelsToTanPixelsPtr

std::shared_ptr<Transform> lsst::afw::image::DistortedTanWcs::_pixelsToTanPixelsPtr
private

Definition at line 119 of file DistortedTanWcs.h.

◆ _relax

int lsst::afw::image::Wcs::_relax
protectedinherited

Degree of permissiveness for wcspih (0 for strict); see wcshdr.h for details.

Definition at line 448 of file Wcs.h.

◆ _skyAxesSwapped

bool lsst::afw::image::Wcs::_skyAxesSwapped
protectedinherited

if true then the sky axes are swapped

Definition at line 453 of file Wcs.h.

◆ _wcsfixCtrl

int lsst::afw::image::Wcs::_wcsfixCtrl
protectedinherited

Do potentially unsafe translations of non-standard unit strings? 0/1 = no/yes.

Definition at line 449 of file Wcs.h.

◆ _wcshdrCtrl

int lsst::afw::image::Wcs::_wcshdrCtrl
protectedinherited

Controls messages to stderr from wcshdr (0 for none); see wcshdr.h for details.

Definition at line 450 of file Wcs.h.

◆ _wcsInfo

struct wcsprm* lsst::afw::image::Wcs::_wcsInfo
protectedinherited

Definition at line 446 of file Wcs.h.


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