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 Member Functions | Private Attributes | List of all members
lsst::meas::algorithms::BinnedWcs Class Reference

#include <BinnedWcs.h>

Inheritance diagram for lsst::meas::algorithms::BinnedWcs:
lsst::afw::image::Wcs std::enable_shared_from_this< BinnedWcs > lsst::daf::base::Persistable lsst::daf::base::Citizen lsst::afw::table::io::PersistableFacade< Wcs > lsst::afw::table::io::Persistable

Public Types

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

 BinnedWcs (boost::shared_ptr< afw::image::Wcs > parent, unsigned int xBin, unsigned int yBin, afw::geom::Point2I xy0)
 
virtual ~BinnedWcs ()
 
virtual boost::shared_ptr< afw::image::Wcsclone () const
 
boost::shared_ptr< afw::image::Wcsupcast ()
 
boost::shared_ptr< afw::image::WcsgetParent () const
 
unsigned int getXBin () const
 
unsigned int getYBin () const
 
afw::geom::Point2I getXY0 () const
 
virtual bool hasDistortion () const
 
virtual bool isPersistable () const
 Whether the Wcs is persistable using afw::table::io archives. More...
 
virtual void flipImage (int flipLR, int flipTB, afw::geom::Extent2I dimensions) const
 Flip CD matrix around the y-axis. More...
 
virtual void rotateImageBy90 (int nQuarter, afw::geom::Extent2I dimensions) const
 Rotate image by nQuarter times 90 degrees. More...
 
virtual boost::shared_ptr< daf::base::PropertyListgetFitsMetadata () const
 Return a PropertyList containing FITS header keywords that can be used to save the Wcs.x. More...
 
afw::geom::AffineTransform getBinnedToOriginal () const
 
afw::geom::AffineTransform getOriginalToBinned () const
 
bool operator== (Wcs const &other) const
 
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...
 
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...
 
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)
 
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...
 
shared_from_this (T... args)
 

Static Public Member Functions

static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static 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...
 
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, afw::geom::Angle skyTmp[2]) const
 Worker routine for pixelToSky. More...
 
virtual afw::geom::Point2D skyToPixelImpl (afw::geom::Angle sky1, afw::geom::Angle sky2) const
 Worker routine for skyToPixel. More...
 
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
 
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 Member Functions

void notImplemented () const
 

Private Attributes

boost::shared_ptr< afw::image::Wcs > const _parent
 
unsigned int const _xBin
 
unsigned int const _yBin
 
afw::geom::Point2I const _xy0
 
afw::geom::AffineTransform const _binnedToOriginal
 
afw::geom::AffineTransform const _originalToBinned
 

Detailed Description

Definition at line 41 of file BinnedWcs.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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
magicSentinel 

Definition at line 86 of file Citizen.h.

Constructor & Destructor Documentation

◆ BinnedWcs()

lsst::meas::algorithms::BinnedWcs::BinnedWcs ( boost::shared_ptr< afw::image::Wcs parent,
unsigned int  xBin,
unsigned int  yBin,
afw::geom::Point2I  xy0 
)

Definition at line 29 of file BinnedWcs.cc.

34  :
35  afw::image::Wcs(*parent), // We have to inherit the implementation as well as the interface...
36  _parent(parent), _xBin(xBin), _yBin(yBin), _xy0(xy0),
40 {
41  // Correct CRPIX
42  afw::geom::Point2D const crpix = _originalToBinned(parent->getPixelOrigin());
43  _wcsInfo->crpix[0] = crpix.getX() + 1; // convert LSST --> FITS
44  _wcsInfo->crpix[1] = crpix.getY() + 1; // convert LSST --> FITS
45 }
afw::geom::Point2I const _xy0
Definition: BinnedWcs.h:83
unsigned int const _xBin
Definition: BinnedWcs.h:82
Extent< double, 2 > Extent2D
Definition: Extent.h:383
afw::geom::AffineTransform const _binnedToOriginal
Definition: BinnedWcs.h:84
boost::shared_ptr< afw::image::Wcs > const _parent
Definition: BinnedWcs.h:81
Point< double, 2 > Point2D
Definition: Point.h:300
afw::geom::AffineTransform const _originalToBinned
Definition: BinnedWcs.h:84
static AffineTransform makeTranslation(Extent2D translation)
Construct a new AffineTransform that represents a pure translation.
static AffineTransform makeScaling(double s)
Construct a new AffineTransform that represents a uniform scaling.
AffineTransform const invert() const
Return the inverse transform.
unsigned int const _yBin
Definition: BinnedWcs.h:82
struct wcsprm * _wcsInfo
Definition: Wcs.h:446
table::PointKey< double > crpix
Definition: Wcs.cc:935

◆ ~BinnedWcs()

virtual lsst::meas::algorithms::BinnedWcs::~BinnedWcs ( )
inlinevirtual

Definition at line 44 of file BinnedWcs.h.

44 {}

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

◆ _isSubset()

bool lsst::afw::image::Wcs::_isSubset ( Wcs const &  other) const
protectedvirtualinherited

Reimplemented in lsst::afw::image::TanWcs.

Definition at line 504 of file Wcs.cc.

504  {
505  CHECK_NULLS(_wcsInfo, rhs._wcsInfo);
506  CHECK_NULLS(_wcsInfo->crval, rhs._wcsInfo->crval);
507  CHECK_NULLS(_wcsInfo->cd, rhs._wcsInfo->cd);
508  CHECK_NULLS(_wcsInfo->crpix, rhs._wcsInfo->crpix);
509  CHECK_NULLS(_wcsInfo->cunit, rhs._wcsInfo->cunit);
510  CHECK_NULLS(_wcsInfo->ctype, rhs._wcsInfo->ctype);
511  return _nWcsInfo == rhs._nWcsInfo && _coordSystem == rhs._coordSystem &&
512  _wcsInfo->naxis == rhs._wcsInfo->naxis && _wcsInfo->equinox == rhs._wcsInfo->equinox &&
513  _wcsInfo->altlin == rhs._wcsInfo->altlin &&
514  compareArrays(_wcsInfo->crval, rhs._wcsInfo->crval, 2) &&
515  compareArrays(_wcsInfo->crpix, rhs._wcsInfo->crpix, 2) &&
516  compareArrays(_wcsInfo->cd, rhs._wcsInfo->cd, 4) &&
517  compareStringArrays(_wcsInfo->cunit, rhs._wcsInfo->cunit, 2) &&
518  compareStringArrays(_wcsInfo->ctype, rhs._wcsInfo->ctype, 2) &&
519  skyToPixel(_wcsInfo->crval[0] * geom::degrees, _wcsInfo->crval[1] * geom::degrees) ==
520  rhs.skyToPixel(_wcsInfo->crval[0] * geom::degrees, _wcsInfo->crval[1] * geom::degrees) &&
521  *pixelToSky(_wcsInfo->crpix[0], _wcsInfo->crpix[1]) ==
522  *rhs.pixelToSky(_wcsInfo->crpix[0], _wcsInfo->crpix[1]);
523 }
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g.
Definition: Wcs.cc:745
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g.
Definition: Wcs.cc:827
#define CHECK_NULLS(a, b)
Definition: Wcs.cc:493
struct wcsprm * _wcsInfo
Definition: Wcs.h:446
coord::CoordSystem _coordSystem
Definition: Wcs.h:452

◆ _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()

virtual boost::shared_ptr< afw::image::Wcs > lsst::meas::algorithms::BinnedWcs::clone ( void  ) const
inlinevirtual

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

Definition at line 46 of file BinnedWcs.h.

46  {
47  return PTR(afw::image::Wcs)(std::make_shared<BinnedWcs>(_parent, _xBin, _yBin, _xy0));
48  }
afw::geom::Point2I const _xy0
Definition: BinnedWcs.h:83
unsigned int const _xBin
Definition: BinnedWcs.h:82
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< afw::image::Wcs > const _parent
Definition: BinnedWcs.h:81
unsigned int const _yBin
Definition: BinnedWcs.h:82

◆ 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

◆ flipImage()

virtual void lsst::meas::algorithms::BinnedWcs::flipImage ( int  flipLR,
int  flipTB,
afw::geom::Extent2I  dimensions 
) const
inlinevirtual

Flip CD matrix around the y-axis.

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

Definition at line 59 of file BinnedWcs.h.

59  {
61  }

◆ getBinnedToOriginal()

afw::geom::AffineTransform lsst::meas::algorithms::BinnedWcs::getBinnedToOriginal ( ) const
inline

Definition at line 70 of file BinnedWcs.h.

70 { return _binnedToOriginal; }
afw::geom::AffineTransform const _binnedToOriginal
Definition: BinnedWcs.h:84

◆ 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()

virtual boost::shared_ptr< daf::base::PropertyList > lsst::meas::algorithms::BinnedWcs::getFitsMetadata ( ) const
inlinevirtual

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

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

Definition at line 65 of file BinnedWcs.h.

65  {
67  return PTR(daf::base::PropertyList)(); // unreached
68  }
lsst::daf::base::PropertyList PropertyList
Definition: Wcs.cc:56
#define PTR(...)
Definition: base.h:41

◆ 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

◆ getOriginalToBinned()

afw::geom::AffineTransform lsst::meas::algorithms::BinnedWcs::getOriginalToBinned ( ) const
inline

Definition at line 71 of file BinnedWcs.h.

71 { return _originalToBinned; }
afw::geom::AffineTransform const _originalToBinned
Definition: BinnedWcs.h:84

◆ getParent()

boost::shared_ptr< afw::image::Wcs > lsst::meas::algorithms::BinnedWcs::getParent ( ) const
inline

Definition at line 51 of file BinnedWcs.h.

51 { return _parent; }
boost::shared_ptr< afw::image::Wcs > const _parent
Definition: BinnedWcs.h:81

◆ getPersistenceName()

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

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.

Reimplemented in lsst::afw::image::TanWcs.

Definition at line 980 of file Wcs.cc.

980 { return getWcsPersistenceName(); }

◆ 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

◆ 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"; }

◆ 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

◆ getXBin()

unsigned int lsst::meas::algorithms::BinnedWcs::getXBin ( ) const
inline

Definition at line 52 of file BinnedWcs.h.

52 { return _xBin; }
unsigned int const _xBin
Definition: BinnedWcs.h:82

◆ getXY0()

afw::geom::Point2I lsst::meas::algorithms::BinnedWcs::getXY0 ( ) const
inline

Definition at line 54 of file BinnedWcs.h.

54 { return _xy0; }
afw::geom::Point2I const _xy0
Definition: BinnedWcs.h:83

◆ getYBin()

unsigned int lsst::meas::algorithms::BinnedWcs::getYBin ( ) const
inline

Definition at line 53 of file BinnedWcs.h.

53 { return _yBin; }
unsigned int const _yBin
Definition: BinnedWcs.h:82

◆ 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()

virtual bool lsst::meas::algorithms::BinnedWcs::hasDistortion ( ) const
inlinevirtual

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

Definition at line 56 of file BinnedWcs.h.

56 { return _parent->hasDistortion(); }
boost::shared_ptr< afw::image::Wcs > const _parent
Definition: BinnedWcs.h:81

◆ 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()

virtual bool lsst::meas::algorithms::BinnedWcs::isPersistable ( ) const
inlinevirtual

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

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

Definition at line 57 of file BinnedWcs.h.

57 { 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

◆ notImplemented()

void lsst::meas::algorithms::BinnedWcs::notImplemented ( ) const
inlineprivate

Definition at line 78 of file BinnedWcs.h.

78  {
79  throw LSST_EXCEPT(NotImplementedException, "Feature has not been implemented");
80  }
#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

◆ 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==()

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

Definition at line 468 of file Wcs.cc.

468  {
469  if (&other == this) return true;
470  // We do a bidirectional test with a virtual member function in case one of us is a derived
471  // class with members we don't know about here.
472  // This is not the most efficient possible implementation, but I think it's the easiest one
473  // with which to ensure correctness, and I think that's more important in this case.
474  return this->_isSubset(other) && other._isSubset(*this);
475 }
virtual bool _isSubset(Wcs const &other) const
Definition: Wcs.cc:504

◆ 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::Wcs::pixelScale ( ) const
inherited

Returns the pixel scale [Angle/pixel].

Definition at line 697 of file Wcs.cc.

697 { return sqrt(pixArea(getPixelOrigin())) * geom::degrees; }
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
double pixArea(lsst::afw::geom::Point2D pix00) const
Sky area covered by a pixel at position pix00 in units of square degrees.
Definition: Wcs.cc:666
lsst::afw::geom::Point2D getPixelOrigin() const
Returns CRPIX (corrected to LSST convention).
Definition: Wcs.cc:542
T sqrt(T... args)

◆ 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::meas::algorithms::BinnedWcs::pixelToSkyImpl ( double  pixel1,
double  pixel2,
afw::geom::Angle  skyTmp[2] 
) const
protectedvirtual

Worker routine for pixelToSky.

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

Definition at line 48 of file BinnedWcs.cc.

49 {
51  skyTmp[0] = coord->getLongitude();
52  skyTmp[1] = coord->getLatitude();
53 }
lsst::afw::coord::Coord Coord
Definition: misc.h:33
#define PTR(...)
Definition: base.h:41
afw::geom::AffineTransform const _binnedToOriginal
Definition: BinnedWcs.h:84
boost::shared_ptr< afw::image::Wcs > const _parent
Definition: BinnedWcs.h:81
Point< double, 2 > Point2D
Definition: Point.h:300
double x

◆ readFits() [1/3]

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() [2/3]

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() [3/3]

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()

virtual void lsst::meas::algorithms::BinnedWcs::rotateImageBy90 ( int  nQuarter,
afw::geom::Extent2I  dimensions 
) const
inlinevirtual

Rotate image by nQuarter times 90 degrees.

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

Definition at line 62 of file BinnedWcs.h.

62  {
64  }

◆ 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

◆ 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::Wcs::shiftReferencePixel ( double  dx,
double  dy 
)
virtualinherited

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.

Definition at line 1057 of file Wcs.cc.

1057  {
1058  assert(_wcsInfo);
1059  _wcsInfo->crpix[0] += dx;
1060  _wcsInfo->crpix[1] += dy;
1061 
1062  // tells libwcs to invalidate cached data, since transformation has been modified
1063  _wcsInfo->flag = 0;
1064 }
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ 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()

afw::geom::Point2D lsst::meas::algorithms::BinnedWcs::skyToPixelImpl ( afw::geom::Angle  sky1,
afw::geom::Angle  sky2 
) const
protectedvirtual

Worker routine for skyToPixel.

Parameters
sky1RA (or, more generally, longitude)
sky2Dec (or latitude)

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

Definition at line 55 of file BinnedWcs.cc.

56 {
57  return _originalToBinned(_parent->skyToPixel(*makeCorrectCoord(sky1, sky2)));
58 }
boost::shared_ptr< afw::image::Wcs > const _parent
Definition: BinnedWcs.h:81
afw::geom::AffineTransform const _originalToBinned
Definition: BinnedWcs.h:84
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

◆ upcast()

boost::shared_ptr< afw::image::Wcs > lsst::meas::algorithms::BinnedWcs::upcast ( )
inline

Definition at line 49 of file BinnedWcs.h.

◆ write()

void lsst::afw::image::Wcs::write ( OutputArchiveHandle handle) const
protectedvirtualinherited

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.

Reimplemented in lsst::afw::image::TanWcs.

Definition at line 984 of file Wcs.cc.

984  {
985  WcsPersistenceHelper const& keys = WcsPersistenceHelper::get();
986  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
987  std::shared_ptr<afw::table::BaseRecord> record = catalog.addNew();
988  record->set(keys.crval.getX(), _wcsInfo[0].crval[0]);
989  record->set(keys.crval.getY(), _wcsInfo[0].crval[1]);
990  record->set(keys.crpix, getPixelOrigin());
991  Eigen::Matrix2d cdIn = getCDMatrix();
992  Eigen::Map<Eigen::Matrix2d> cdOut((*record)[keys.cd].getData());
993  cdOut = cdIn;
994  record->set(keys.ctype1, std::string(_wcsInfo[0].ctype[0]));
995  record->set(keys.ctype2, std::string(_wcsInfo[0].ctype[1]));
996  record->set(keys.equinox, _wcsInfo[0].equinox);
997  record->set(keys.radesys, std::string(_wcsInfo[0].radesys));
998  record->set(keys.cunit1, std::string(_wcsInfo[0].cunit[0]));
999  record->set(keys.cunit2, std::string(_wcsInfo[0].cunit[1]));
1000  handle.saveCatalog(catalog);
1001 }
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
STL class.
lsst::afw::geom::Point2D getPixelOrigin() const
Returns CRPIX (corrected to LSST convention).
Definition: Wcs.cc:542
Eigen::Matrix2d getCDMatrix() const
Returns the CD matrix.
Definition: Wcs.cc:550
struct wcsprm * _wcsInfo
Definition: Wcs.h:446

◆ 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

◆ _binnedToOriginal

afw::geom::AffineTransform const lsst::meas::algorithms::BinnedWcs::_binnedToOriginal
private

Definition at line 84 of file BinnedWcs.h.

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

◆ _originalToBinned

afw::geom::AffineTransform const lsst::meas::algorithms::BinnedWcs::_originalToBinned
private

Definition at line 84 of file BinnedWcs.h.

◆ _parent

boost::shared_ptr< afw::image::Wcs > const lsst::meas::algorithms::BinnedWcs::_parent
private

Definition at line 81 of file BinnedWcs.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.

◆ _xBin

unsigned int const lsst::meas::algorithms::BinnedWcs::_xBin
private

Definition at line 82 of file BinnedWcs.h.

◆ _xy0

afw::geom::Point2I const lsst::meas::algorithms::BinnedWcs::_xy0
private

Definition at line 83 of file BinnedWcs.h.

◆ _yBin

unsigned int const lsst::meas::algorithms::BinnedWcs::_yBin
private

Definition at line 82 of file BinnedWcs.h.


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