LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Namespaces | Classes | Typedefs | Enumerations | Functions
lsst::afw::geom Namespace Reference

Namespaces

 _calculateSipWcsHeader
 
 _hpxUtils
 
 _python
 
 detail
 
 details
 
 ellipses
 
 polygon
 
 skyWcs
 
 testUtils
 
 transform
 
 transformConfig
 
 transformFactory
 
 transformFromString
 
 utils
 
 wcsUtils
 

Classes

class  BaseEndpoint
 Virtual base class for endpoints, which are helper classes for Transform. More...
 
class  BaseVectorEndpoint
 Base class for endpoints with Array = std::vector<Point> where Point has 2 dimensions. More...
 
class  GenericEndpoint
 A generic endpoint for data in the format used by ast::Mapping. More...
 
class  Point2Endpoint
 An endpoint for lsst::geom::Point2D. More...
 
class  SpherePointEndpoint
 An endpoint for lsst::geom::SpherePoint. More...
 
class  SipApproximation
 A fitter and results class for approximating a general Transform in a form compatible with FITS WCS persistence. More...
 
class  SkyWcs
 A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixels. More...
 
class  Span
 A range of pixels within one row of an Image. More...
 
class  SpanPixelIterator
 An iterator that yields lsst::geom::Point2I and increases in the x direction. More...
 
class  SpanSet
 A compact representation of a collection of pixels. More...
 
class  Transform
 Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint, using an AST mapping. More...
 

Typedefs

using TransformPoint2ToPoint2 = Transform< Point2Endpoint, Point2Endpoint >
 
using TransformPoint2ToGeneric = Transform< Point2Endpoint, GenericEndpoint >
 
using TransformPoint2ToSpherePoint = Transform< Point2Endpoint, SpherePointEndpoint >
 

Enumerations

enum class  Stencil { CIRCLE , BOX , MANHATTAN }
 An enumeration class which describes the shapes. More...
 

Functions

std::ostreamoperator<< (std::ostream &os, GenericEndpoint const &endpoint)
 Print "GenericEndpoint(_n_)" to the ostream where _n_ is the number of axes, e.g. "GenericAxes(4)". More...
 
std::ostreamoperator<< (std::ostream &os, Point2Endpoint const &endpoint)
 Print "Point2Endpoint()" to the ostream. More...
 
std::ostreamoperator<< (std::ostream &os, SpherePointEndpoint const &endpoint)
 Print "SpherePointEndpoint()" to the ostream. More...
 
Eigen::Matrix2d makeCdMatrix (lsst::geom::Angle const &scale, lsst::geom::Angle const &orientation=0 *lsst::geom::degrees, bool flipX=false)
 Make a WCS CD matrix. More...
 
std::shared_ptr< SkyWcsmakeFlippedWcs (SkyWcs const &wcs, bool flipLR, bool flipTB, lsst::geom::Point2D const &center)
 Return a copy of a FITS-WCS with pixel positions flipped around a specified center. More...
 
std::shared_ptr< SkyWcsmakeModifiedWcs (TransformPoint2ToPoint2 const &pixelTransform, SkyWcs const &wcs, bool modifyActualPixels)
 Create a new SkyWcs whose pixels are transformed by pixelTransform, as described below. More...
 
std::shared_ptr< SkyWcsmakeSkyWcs (daf::base::PropertySet &metadata, bool strip=false)
 Construct a SkyWcs from FITS keywords. More...
 
std::shared_ptr< SkyWcsmakeSkyWcs (lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, std::string const &projection="TAN")
 Construct a simple FITS SkyWcs with no distortion. More...
 
std::shared_ptr< SkyWcsmakeSkyWcs (TransformPoint2ToPoint2 const &pixelsToFieldAngle, lsst::geom::Angle const &orientation, bool flipX, lsst::geom::SpherePoint const &boresight, std::string const &projection="TAN")
 Construct a FITS SkyWcs from camera geometry. More...
 
std::shared_ptr< SkyWcsmakeTanSipWcs (lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB)
 Construct a TAN-SIP SkyWcs with forward SIP distortion terms and an iterative inverse. More...
 
std::shared_ptr< SkyWcsmakeTanSipWcs (lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB, Eigen::MatrixXd const &sipAp, Eigen::MatrixXd const &sipBp)
 Construct a TAN WCS with forward and inverse SIP distortion terms. More...
 
std::shared_ptr< TransformPoint2ToPoint2makeWcsPairTransform (SkyWcs const &src, SkyWcs const &dst)
 A Transform obtained by putting two SkyWcs objects "back to back". More...
 
std::shared_ptr< TransformPoint2ToSpherePointgetIntermediateWorldCoordsToSky (SkyWcs const &wcs, bool simplify=true)
 Return a transform from intermediate world coordinates to sky. More...
 
std::shared_ptr< TransformPoint2ToPoint2getPixelToIntermediateWorldCoords (SkyWcs const &wcs, bool simplify=true)
 Return a transform from pixel coordinates to intermediate world coordinates. More...
 
std::ostreamoperator<< (std::ostream &os, SkyWcs const &wcs)
 Print a SkyWcs to an ostream (delegates to SkyWcs.toString()). More...
 
template<class FromEndpoint , class ToEndpoint >
std::ostreamoperator<< (std::ostream &os, Transform< FromEndpoint, ToEndpoint > const &transform)
 Print a Transform to an ostream. More...
 
lsst::geom::AffineTransform linearizeTransform (TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)
 Approximate a Transform by its local linearization. More...
 
std::shared_ptr< TransformPoint2ToPoint2makeTransform (lsst::geom::AffineTransform const &affine)
 Wrap an lsst::geom::AffineTransform as a Transform. More...
 
std::shared_ptr< TransformPoint2ToPoint2makeRadialTransform (std::vector< double > const &coeffs)
 A purely radial polynomial distortion. More...
 
std::shared_ptr< TransformPoint2ToPoint2makeRadialTransform (std::vector< double > const &forwardCoeffs, std::vector< double > const &inverseCoeffs)
 A purely radial polynomial distortion. More...
 
std::shared_ptr< TransformPoint2ToPoint2makeIdentityTransform ()
 Trivial Transform x → x. More...
 
std::shared_ptr< daf::base::PropertyListcreateTrivialWcsMetadata (std::string const &wcsName, lsst::geom::Point2I const &xy0)
 
void deleteBasicWcsMetadata (daf::base::PropertySet &metadata, std::string const &wcsName)
 
Eigen::Matrix2d getCdMatrixFromMetadata (daf::base::PropertySet &metadata)
 Read a CD matrix from FITS WCS metadata. More...
 
lsst::geom::Point2I getImageXY0FromMetadata (daf::base::PropertySet &metadata, std::string const &wcsName, bool strip=false)
 
Eigen::MatrixXd getSipMatrixFromMetadata (daf::base::PropertySet const &metadata, std::string const &name)
 
bool hasSipMatrix (daf::base::PropertySet const &metadata, std::string const &name)
 
std::shared_ptr< daf::base::PropertyListmakeSipMatrixMetadata (Eigen::MatrixXd const &matrix, std::string const &name)
 
std::shared_ptr< daf::base::PropertyListmakeSimpleWcsMetadata (lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, std::string const &projection="TAN")
 Make FITS metadata for a simple FITS WCS (one with no distortion). More...
 
std::shared_ptr< daf::base::PropertyListmakeTanSipMetadata (lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB)
 Make metadata for a TAN-SIP WCS without inverse matrices. More...
 
std::shared_ptr< daf::base::PropertyListmakeTanSipMetadata (lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB, Eigen::MatrixXd const &sipAp, Eigen::MatrixXd const &sipBp)
 Make metadata for a TAN-SIP WCS. More...
 
void wrapEndpoint (lsst::utils::python::WrapperCollection &wrappers)
 
void wrapSipApproximation (lsst::utils::python::WrapperCollection &)
 
void wrapSkyWcs (lsst::utils::python::WrapperCollection &)
 
void wrapSpan (lsst::utils::python::WrapperCollection &)
 
void wrapSpanSet (lsst::utils::python::WrapperCollection &)
 
void wrapTransform (lsst::utils::python::WrapperCollection &)
 
void wrapTransformFactory (lsst::utils::python::WrapperCollection &)
 
void wrapWcsUtils (lsst::utils::python::WrapperCollection &)
 
 PYBIND11_MODULE (_geom, mod)
 
template void SpanSet::setImage< std::uint16_t > (image::Image< std::uint16_t > &image, std::uint16_t val, lsst::geom::Box2I const &region=lsst::geom::Box2I(), bool doClip=false) const
 
template void SpanSet::setImage< std::uint64_t > (image::Image< std::uint64_t > &image, std::uint64_t val, lsst::geom::Box2I const &region=lsst::geom::Box2I(), bool doClip=false) const
 
template void SpanSet::setMask< image::MaskPixel > (image::Mask< image::MaskPixel > &target, image::MaskPixel bitmask) const
 
template void SpanSet::clearMask< image::MaskPixel > (image::Mask< image::MaskPixel > &target, image::MaskPixel bitmask) const
 
template std::shared_ptr< SpanSetSpanSet::intersect< image::MaskPixel > (image::Mask< image::MaskPixel > const &other, image::MaskPixel bitmask) const
 
template std::shared_ptr< SpanSetSpanSet::intersectNot< image::MaskPixel > (image::Mask< image::MaskPixel > const &other, image::MaskPixel bitmask) const
 
template std::shared_ptr< SpanSetSpanSet::union_< image::MaskPixel > (image::Mask< image::MaskPixel > const &other, image::MaskPixel bitmask) const
 
template std::ostreamoperator<<< GenericEndpoint, GenericEndpoint > (std::ostream &os, Transform< GenericEndpoint, GenericEndpoint > const &transform)
 
template std::ostreamoperator<<< GenericEndpoint, Point2Endpoint > (std::ostream &os, Transform< GenericEndpoint, Point2Endpoint > const &transform)
 
template std::ostreamoperator<<< GenericEndpoint, SpherePointEndpoint > (std::ostream &os, Transform< GenericEndpoint, SpherePointEndpoint > const &transform)
 
template std::ostreamoperator<<< Point2Endpoint, GenericEndpoint > (std::ostream &os, Transform< Point2Endpoint, GenericEndpoint > const &transform)
 
template std::ostreamoperator<<< Point2Endpoint, Point2Endpoint > (std::ostream &os, Transform< Point2Endpoint, Point2Endpoint > const &transform)
 
template std::ostreamoperator<<< Point2Endpoint, SpherePointEndpoint > (std::ostream &os, Transform< Point2Endpoint, SpherePointEndpoint > const &transform)
 
template std::ostreamoperator<<< SpherePointEndpoint, GenericEndpoint > (std::ostream &os, Transform< SpherePointEndpoint, GenericEndpoint > const &transform)
 
template std::ostreamoperator<<< SpherePointEndpoint, Point2Endpoint > (std::ostream &os, Transform< SpherePointEndpoint, Point2Endpoint > const &transform)
 
template std::ostreamoperator<<< SpherePointEndpoint, SpherePointEndpoint > (std::ostream &os, Transform< SpherePointEndpoint, SpherePointEndpoint > const &transform)
 

Typedef Documentation

◆ TransformPoint2ToGeneric

Definition at line 301 of file Transform.h.

◆ TransformPoint2ToPoint2

Definition at line 300 of file Transform.h.

◆ TransformPoint2ToSpherePoint

Definition at line 302 of file Transform.h.

Enumeration Type Documentation

◆ Stencil

An enumeration class which describes the shapes.

A stencil is a shape used in creating SpanSets, erosion kernels, or dilation kernels. CIRCLE creates a circle shape, BOX creates a box shape, and MANHATTAN creates a diamond shape.

Enumerator
CIRCLE 
BOX 
MANHATTAN 

Definition at line 66 of file SpanSet.h.

Function Documentation

◆ createTrivialWcsMetadata()

std::shared_ptr< daf::base::PropertyList > lsst::afw::geom::createTrivialWcsMetadata ( std::string const &  wcsName,
lsst::geom::Point2I const &  xy0 
)

Definition at line 48 of file wcsUtils.cc.

49  {
50  std::shared_ptr<daf::base::PropertyList> wcsMetaData(new daf::base::PropertyList);
51 
52  wcsMetaData->set("CTYPE1" + wcsName, "LINEAR", "Type of projection");
53  wcsMetaData->set("CTYPE2" + wcsName, "LINEAR", "Type of projection");
54  wcsMetaData->set("CRPIX1" + wcsName, static_cast<double>(1), "Column Pixel Coordinate of Reference");
55  wcsMetaData->set("CRPIX2" + wcsName, static_cast<double>(1), "Row Pixel Coordinate of Reference");
56  wcsMetaData->set("CRVAL1" + wcsName, static_cast<double>(xy0[0]), "Column pixel of Reference Pixel");
57  wcsMetaData->set("CRVAL2" + wcsName, static_cast<double>(xy0[1]), "Row pixel of Reference Pixel");
58  wcsMetaData->set("CUNIT1" + wcsName, "PIXEL", "Column unit");
59  wcsMetaData->set("CUNIT2" + wcsName, "PIXEL", "Row unit");
60 
61  return wcsMetaData;
62 }

◆ deleteBasicWcsMetadata()

void lsst::afw::geom::deleteBasicWcsMetadata ( daf::base::PropertySet metadata,
std::string const &  wcsName 
)

Definition at line 64 of file wcsUtils.cc.

64  {
65  std::vector<std::string> const names = {"CRPIX1", "CRPIX2", "CRVAL1", "CRVAL2", "CTYPE1",
66  "CTYPE2", "CUNIT1", "CUNIT2", "CD1_1", "CD1_2",
67  "CD2_1", "CD2_2", "WCSAXES"};
68  for (auto const& name : names) {
69  if (metadata.exists(name + wcsName)) {
70  metadata.remove(name + wcsName);
71  }
72  }
73 }
table::Key< std::string > name
Definition: Amplifier.cc:116

◆ getCdMatrixFromMetadata()

Eigen::Matrix2d lsst::afw::geom::getCdMatrixFromMetadata ( daf::base::PropertySet metadata)

Read a CD matrix from FITS WCS metadata.

The elements of the returned matrix are in degrees

Exceptions
pex::exceptions::TypeErrorif no CD matrix coefficients found (missing coefficients are set to 0, as usual, but they cannot all be missing).

Definition at line 75 of file wcsUtils.cc.

75  {
76  Eigen::Matrix2d matrix;
77  bool found{false};
78  for (int i = 0; i < 2; ++i) {
79  for (int j = 0; j < 2; ++j) {
80  std::string const cardName = "CD" + std::to_string(i + 1) + "_" + std::to_string(j + 1);
81  if (metadata.exists(cardName)) {
82  matrix(i, j) = metadata.getAsDouble(cardName);
83  found = true;
84  } else {
85  matrix(i, j) = 0.0;
86  }
87  }
88  }
89  if (!found) {
90  throw LSST_EXCEPT(pex::exceptions::TypeError, "No CD matrix coefficients found");
91  }
92  return matrix;
93 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T to_string(T... args)

◆ getImageXY0FromMetadata()

lsst::geom::Point2I lsst::afw::geom::getImageXY0FromMetadata ( daf::base::PropertySet metadata,
std::string const &  wcsName,
bool  strip = false 
)

Definition at line 95 of file wcsUtils.cc.

96  {
97  int x0 = 0; // Our value of X0
98  int y0 = 0; // Our value of Y0
99 
100  if (metadata.exists("CRPIX1" + wcsName) && metadata.exists("CRPIX2" + wcsName) &&
101  metadata.exists("CRVAL1" + wcsName) && metadata.exists("CRVAL2" + wcsName) &&
102  (metadata.getAsDouble("CRPIX1" + wcsName) == 1.0) &&
103  (metadata.getAsDouble("CRPIX2" + wcsName) == 1.0)) {
104  x0 = static_cast<int>(std::lround(metadata.getAsDouble("CRVAL1" + wcsName)));
105  y0 = static_cast<int>(std::lround(metadata.getAsDouble("CRVAL2" + wcsName)));
106  if (strip) {
107  deleteBasicWcsMetadata(metadata, wcsName);
108  }
109  }
110  return lsst::geom::Point2I(x0, y0);
111 }
bool strip
Definition: fits.cc:911
void deleteBasicWcsMetadata(daf::base::PropertySet &metadata, std::string const &wcsName)
Definition: wcsUtils.cc:64
Point< int, 2 > Point2I
Definition: Point.h:321
T lround(T... args)

◆ getIntermediateWorldCoordsToSky()

std::shared_ptr< TransformPoint2ToSpherePoint > lsst::afw::geom::getIntermediateWorldCoordsToSky ( SkyWcs const &  wcs,
bool  simplify = true 
)

Return a transform from intermediate world coordinates to sky.

Definition at line 553 of file SkyWcs.cc.

554  {
555  auto iwcToSky = wcs.getFrameDict()->getMapping("IWC", "SKY");
556  return std::make_shared<TransformPoint2ToSpherePoint>(*iwcToSky, simplify);
557 }
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:66

◆ getPixelToIntermediateWorldCoords()

std::shared_ptr< TransformPoint2ToPoint2 > lsst::afw::geom::getPixelToIntermediateWorldCoords ( SkyWcs const &  wcs,
bool  simplify = true 
)

Return a transform from pixel coordinates to intermediate world coordinates.

The pixel frame is is the base frame: cameraGeom::ACTUAL_PIXELS, if present, else cameraGeom::PIXELS.

Definition at line 559 of file SkyWcs.cc.

559  {
560  auto pixelToIwc = wcs.getFrameDict()->getMapping(ast::FrameSet::BASE, "IWC");
561  return std::make_shared<TransformPoint2ToPoint2>(*pixelToIwc, simplify);
562 }
static constexpr int BASE
index of base frame
Definition: FrameSet.h:104

◆ getSipMatrixFromMetadata()

Eigen::MatrixXd lsst::afw::geom::getSipMatrixFromMetadata ( daf::base::PropertySet const &  metadata,
std::string const &  name 
)

Definition at line 113 of file wcsUtils.cc.

113  {
114  std::string cardName = name + "_ORDER";
115  if (!metadata.exists(cardName)) {
117  "metadata does not contain SIP matrix " + name + ": " + cardName + " not found");
118  };
119  int order = metadata.getAsInt(cardName);
120  if (order < 0) {
122  "matrix order = " + std::to_string(order) + " < 0");
123  }
124  Eigen::MatrixXd matrix(order + 1, order + 1);
125  auto const coeffName = name + "_";
126  for (int i = 0; i <= order; ++i) {
127  for (int j = 0; j <= order; ++j) {
128  std::string const cardName = getSipCoeffCardName(coeffName, i, j);
129  if (metadata.exists(cardName)) {
130  matrix(i, j) = metadata.getAsDouble(cardName);
131  } else {
132  matrix(i, j) = 0.0;
133  }
134  }
135  }
136  return matrix;
137 }
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167
table::Key< int > order

◆ hasSipMatrix()

bool lsst::afw::geom::hasSipMatrix ( daf::base::PropertySet const &  metadata,
std::string const &  name 
)

Definition at line 139 of file wcsUtils.cc.

139  {
140  std::string cardName = name + "_ORDER";
141  if (!metadata.exists(cardName)) {
142  return false;
143  }
144  return metadata.getAsInt(cardName) >= 0;
145 }

◆ linearizeTransform()

lsst::geom::AffineTransform lsst::afw::geom::linearizeTransform ( TransformPoint2ToPoint2 const &  original,
lsst::geom::Point2D const &  inPoint 
)

Approximate a Transform by its local linearization.

Template Parameters
FromEndpoint,ToEndpointThe endpoints of the transform.
Parameters
originalthe Transform to linearize
inPointthe point at which a linear approximation is desired
Returns
an lsst::geom::AffineTransform whose value and Jacobian at inPoint match those of original. It may be invertible; in general, linearizations are invertible if the Jacobian at inPoint is invertible.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if original does not have a well-defined value and Jacobian at inPoint
Exception Safety
Not exception safe.

Definition at line 132 of file transformFactory.cc.

133  {
134  auto outPoint = original.applyForward(inPoint);
135  Eigen::Matrix2d jacobian = original.getJacobian(inPoint);
136  for (int i = 0; i < 2; ++i) {
137  if (!std::isfinite(outPoint[i])) {
138  std::ostringstream buffer;
139  buffer << "Transform ill-defined: " << inPoint << " -> " << outPoint;
140  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, buffer.str());
141  }
142  }
143  if (!jacobian.allFinite()) {
144  std::ostringstream buffer;
145  buffer << "Transform not continuous at " << inPoint << ": J = " << jacobian;
146  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, buffer.str());
147  }
148 
149  // y(x) = J (x - x0) + y0 = J x + (y0 - J x0)
150  auto offset = outPoint.asEigen() - jacobian * inPoint.asEigen();
151  return lsst::geom::AffineTransform(jacobian, offset);
152 }
An affine coordinate transformation consisting of a linear transformation and an offset.
T isfinite(T... args)
T str(T... args)

◆ makeCdMatrix()

Eigen::Matrix2d lsst::afw::geom::makeCdMatrix ( lsst::geom::Angle const &  scale,
lsst::geom::Angle const &  orientation = 0 * lsst::geom::degrees,
bool  flipX = false 
)

Make a WCS CD matrix.

Parameters
[in]scalePixel scale as an angle on sky/pixels
[in]orientationPosition angle of pixel +Y, measured from N through E. At 0 degrees, +Y is along N and +X is along W/E if flipX false/true At 90 degrees, +Y is along E and +X is along N/S if flipX false/true
[in]flipXFlip x axis? See orientation for details.
Returns
the CD matrix, where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]

Definition at line 133 of file SkyWcs.cc.

134  {
135  Eigen::Matrix2d cdMatrix;
136  double orientRad = orientation.asRadians();
137  double scaleDeg = scale.asDegrees();
138  double xmult = flipX ? 1.0 : -1.0;
139  cdMatrix(0, 0) = std::cos(orientRad) * scaleDeg * xmult;
140  cdMatrix(0, 1) = std::sin(orientRad) * scaleDeg;
141  cdMatrix(1, 0) = -std::sin(orientRad) * scaleDeg * xmult;
142  cdMatrix(1, 1) = std::cos(orientRad) * scaleDeg;
143  return cdMatrix;
144 }
T cos(T... args)
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108
int orientation(UnitVector3d const &a, UnitVector3d const &b, UnitVector3d const &c)
orientation computes and returns the orientations of 3 unit vectors a, b and c.
Definition: orientation.cc:135
T sin(T... args)

◆ makeFlippedWcs()

std::shared_ptr< SkyWcs > lsst::afw::geom::makeFlippedWcs ( SkyWcs const &  wcs,
bool  flipLR,
bool  flipTB,
lsst::geom::Point2D const &  center 
)

Return a copy of a FITS-WCS with pixel positions flipped around a specified center.

Parameters
[in]wcsThe initial WCS
[in]flipLRFlip pixel positions left/right about center
[in]flipTBFlip pixel positions top/bottom about center
[in]centerCenter pixel position of flip

Definition at line 467 of file SkyWcs.cc.

468  {
469  double const dx = 1000; // any "reasonable" number of pixels will do
470  std::vector<double> inLL = {center[0] - dx, center[1] - dx};
471  std::vector<double> inUR = {center[0] + dx, center[1] + dx};
472  std::vector<double> outLL(inLL);
473  std::vector<double> outUR(inUR);
474  if (flipLR) {
475  outLL[0] = inUR[0];
476  outUR[0] = inLL[0];
477  }
478  if (flipTB) {
479  outLL[1] = inUR[1];
480  outUR[1] = inLL[1];
481  }
482  auto const flipPix = TransformPoint2ToPoint2(ast::WinMap(inLL, inUR, outLL, outUR));
483  return makeModifiedWcs(flipPix, wcs, true);
484 }
A WinMap is a linear Mapping which transforms a rectangular window in one coordinate system into a si...
Definition: WinMap.h:45
std::shared_ptr< SkyWcs > makeModifiedWcs(TransformPoint2ToPoint2 const &pixelTransform, SkyWcs const &wcs, bool modifyActualPixels)
Create a new SkyWcs whose pixels are transformed by pixelTransform, as described below.
Definition: SkyWcs.cc:486
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300

◆ makeIdentityTransform()

std::shared_ptr< TransformPoint2ToPoint2 > lsst::afw::geom::makeIdentityTransform ( )

Trivial Transform x → x.

Returns
a Transform mapping any lsst::geom::Point2D to itself. The Transform's inverse shall be itself.
Exception Safety
Provides basic exception safety.

Definition at line 214 of file transformFactory.cc.

214  {
215  return std::make_shared<TransformPoint2ToPoint2>(ast::UnitMap(2));
216 }
A UnitMap is a unit (null) Mapping that has no effect on the coordinates supplied to it.
Definition: UnitMap.h:44

◆ makeModifiedWcs()

std::shared_ptr< SkyWcs > lsst::afw::geom::makeModifiedWcs ( TransformPoint2ToPoint2 const &  pixelTransform,
SkyWcs const &  wcs,
bool  modifyActualPixels 
)

Create a new SkyWcs whose pixels are transformed by pixelTransform, as described below.

If modifyActualPixels is true and the cameraGeom::ACTUAL_PIXELS frame exists then pixelTransform is inserted just after the cameraGeom::ACTUAL_PIXELS frame:

newActualPixelsToPixels = pixelTransform -> oldActualPixelsToPixels

This is appropriate for shifting a WCS, e.g. when writing FITS metadata for a subimage.

If modifyActualPixels is false or the cameraGeom::ACTUAL_PIXELS frame does not exist then pixelTransform is inserted just after the cameraGeom::PIXELS frame:

newPixelsToIwc = pixelTransform -> oldPixelsToIwc

This is appropriate for inserting a model for optical distortion.

Other than the change described above, the new SkyWcs will be just like the old one.

Parameters
[in]pixelTransformTransform to insert
[in]wcsInput WCS
[in]modifyActualPixelsLocation at which to insert the transform; if true and the cameraGeom::ACTUAL_PIXELS frame is present then insert just after the cameraGeom::ACTUAL_PIXELS frame, else insert just after the cameraGeom::PIXELS frame.
Returns
the new WCS

Definition at line 486 of file SkyWcs.cc.

487  {
488  auto const pixelMapping = pixelTransform.getMapping();
489  auto oldFrameDict = wcs.getFrameDict();
490  bool const hasActualPixels = oldFrameDict->hasDomain("ACTUAL_PIXELS");
491  auto const pixelFrame = oldFrameDict->getFrame("PIXELS", false);
492  auto const iwcFrame = oldFrameDict->getFrame("IWC", false);
493  auto const skyFrame = oldFrameDict->getFrame("SKY", false);
494  auto const oldPixelToIwc = oldFrameDict->getMapping("PIXELS", "IWC");
495  auto const iwcToSky = oldFrameDict->getMapping("IWC", "SKY");
496 
497  std::shared_ptr<ast::FrameDict> newFrameDict;
498  std::shared_ptr<ast::Mapping> newPixelToIwc;
499  if (hasActualPixels) {
500  auto const actualPixelFrame = oldFrameDict->getFrame("ACTUAL_PIXELS", false);
501  auto const oldActualPixelToPixels = oldFrameDict->getMapping("ACTUAL_PIXELS", "PIXELS");
502  std::shared_ptr<ast::Mapping> newActualPixelsToPixels;
503  if (modifyActualPixels) {
504  newActualPixelsToPixels = pixelMapping->then(*oldActualPixelToPixels).simplified();
505  newPixelToIwc = oldPixelToIwc;
506  } else {
507  newActualPixelsToPixels = oldActualPixelToPixels;
508  newPixelToIwc = pixelMapping->then(*oldPixelToIwc).simplified();
509  }
510  newFrameDict =
511  std::make_shared<ast::FrameDict>(*actualPixelFrame, *newActualPixelsToPixels, *pixelFrame);
512  newFrameDict->addFrame("PIXELS", *newPixelToIwc, *iwcFrame);
513  } else {
514  newPixelToIwc = pixelMapping->then(*oldPixelToIwc).simplified();
515  newFrameDict = std::make_shared<ast::FrameDict>(*pixelFrame, *newPixelToIwc, *iwcFrame);
516  }
517  newFrameDict->addFrame("IWC", *iwcToSky, *skyFrame);
518  return std::make_shared<SkyWcs>(*newFrameDict);
519 }
SeriesMap then(Mapping const &next) const
Return a series compound mapping this(first(input)) containing shallow copies of the original.
Definition: Mapping.cc:37
std::shared_ptr< Mapping > simplified() const
Return a simplied version of the mapping (which may be a compound Mapping such as a CmpMap).
Definition: Mapping.h:248

◆ makeRadialTransform() [1/2]

std::shared_ptr< TransformPoint2ToPoint2 > lsst::afw::geom::makeRadialTransform ( std::vector< double > const &  coeffs)

A purely radial polynomial distortion.

The Transform transforms an input \(x\) to

\[ \frac{x}{r} \sum_{i=1}^{N} \mathrm{coeffs[i]} \ r^i \]

where \(r\) is the magnitude of \(x\).

Parameters
coeffsradial polynomial coefficients. May be an empty vector to represent the identity transformation; otherwise must have size > 1, coeffs[0] = 0, and coeffs[1] ≠ 0.
Returns
the radial distortion represented by coeffs. The Transform shall have an inverse, which may be approximate.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if coeffs does not have the required format.
Exception Safety
Provides basic exception safety.

Definition at line 165 of file transformFactory.cc.

165  {
166  if (!areRadialCoefficients(coeffs)) {
167  std::ostringstream buffer;
168  buffer << "Invalid coefficient vector: " << coeffs;
169  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, buffer.str());
170  }
171 
172  if (coeffs.empty()) {
173  return std::make_shared<TransformPoint2ToPoint2>(ast::UnitMap(2));
174  } else {
175  // distortion is a radial polynomial with center at focal plane center;
176  // the polynomial has an iterative inverse
177  std::vector<double> center = {0.0, 0.0};
178  ast::PolyMap const distortion = makeOneDDistortion(coeffs);
179  return std::make_shared<TransformPoint2ToPoint2>(*ast::makeRadialMapping(center, distortion));
180  }
181 }
PolyMap is a Mapping which performs a general polynomial transformation.
Definition: PolyMap.h:49
T empty(T... args)
std::shared_ptr< Mapping > makeRadialMapping(std::vector< double > const &center, Mapping const &mapping1d)
Construct a radially symmetric mapping from a 1-dimensional mapping.
Definition: functional.cc:48

◆ makeRadialTransform() [2/2]

std::shared_ptr< TransformPoint2ToPoint2 > lsst::afw::geom::makeRadialTransform ( std::vector< double > const &  forwardCoeffs,
std::vector< double > const &  inverseCoeffs 
)

A purely radial polynomial distortion.

Similar to makeRadialTransform(std::vector<double> const &), but allows the user to provide an inverse.

Parameters
forwardCoeffsradial polynomial coefficients. May be an empty vector to represent the identity transformation; otherwise must have size > 1, coeffs[0] = 0, and coeffs[1] ≠ 0.
inverseCoeffscoefficients for the inverse transform, as above. Does not need to have the same degree as forwardCoeffs, but either both must be empty or neither must be empty.
Returns
the radial distortion represented by coeffs. The Transform shall have an inverse, whose accuracy is determined by the relationship between forwardCoeffs and inverseCoeffs.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if forwardCoeffs or inverseCoeffs does not have the required format.
Exception Safety
Provides basic exception safety.

Definition at line 183 of file transformFactory.cc.

184  {
185  if (forwardCoeffs.empty() != inverseCoeffs.empty()) {
186  throw LSST_EXCEPT(
187  pex::exceptions::InvalidParameterError,
188  "makeRadialTransform must have either both empty or both non-empty coefficient vectors.");
189  }
190  if (forwardCoeffs.empty()) {
191  // no forward or inverse coefficients, so no distortion
192  return std::make_shared<TransformPoint2ToPoint2>(ast::UnitMap(2));
193  }
194 
195  if (!areRadialCoefficients(forwardCoeffs)) {
196  std::ostringstream buffer;
197  buffer << "Invalid forward coefficient vector: " << forwardCoeffs;
198  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, buffer.str());
199  }
200  if (!areRadialCoefficients(inverseCoeffs)) {
201  std::ostringstream buffer;
202  buffer << "Invalid inverse coefficient vector: " << inverseCoeffs;
203  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, buffer.str());
204  }
205  // distortion is a 1-d radial polynomial centered at focal plane center;
206  // the polynomial has coefficients specified for both the forward and inverse directions
207  std::vector<double> center = {0.0, 0.0};
208  ast::PolyMap const forward = makeOneDDistortion(forwardCoeffs);
209  auto inverse = makeOneDDistortion(inverseCoeffs).inverted();
210  auto distortion = ast::TranMap(forward, *inverse);
211  return std::make_shared<TransformPoint2ToPoint2>(*ast::makeRadialMapping(center, distortion));
212 }
TranMap is a Mapping which combines the forward transformation of a supplied Mapping with the inverse...
Definition: TranMap.h:49
T forward(T... args)

◆ makeSimpleWcsMetadata()

std::shared_ptr< daf::base::PropertyList > lsst::afw::geom::makeSimpleWcsMetadata ( lsst::geom::Point2D const &  crpix,
lsst::geom::SpherePoint const &  crval,
Eigen::Matrix2d const &  cdMatrix,
std::string const &  projection = "TAN" 
)

Make FITS metadata for a simple FITS WCS (one with no distortion).

This can also be used as a starting point for creating metadata for more sophisticated FITS WCS.

Parameters
[in]crpixCenter of projection on the CCD using the LSST convention: 0, 0 is the lower left pixel of the image
[in]crvalCenter of projection on the sky
[in]cdMatrixCD matrix where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]
[in]projectionThe name of the FITS WCS projection, e.g. "TAN" or "STG"

Definition at line 169 of file wcsUtils.cc.

172  {
173  auto pl = std::make_shared<daf::base::PropertyList>();
174  pl->add("RADESYS", "ICRS");
175  pl->add("CTYPE1", "RA---" + projection);
176  pl->add("CTYPE2", "DEC--" + projection);
177  pl->add("CRPIX1", crpix[0] + 1);
178  pl->add("CRPIX2", crpix[1] + 1);
179  pl->add("CRVAL1", crval[0].asDegrees());
180  pl->add("CRVAL2", crval[1].asDegrees());
181  pl->add("CUNIT1", "deg");
182  pl->add("CUNIT2", "deg");
183  for (int i = 0; i < 2; ++i) {
184  for (int j = 0; j < 2; ++j) {
185  if (cdMatrix(i, j) != 0.0) {
186  std::string name = "CD" + std::to_string(i + 1) + "_" + std::to_string(j + 1);
187  pl->add(name, cdMatrix(i, j));
188  }
189  }
190  }
191  return pl;
192 }
table::PointKey< double > crpix
Definition: OldWcs.cc:129
table::PointKey< double > crval
Definition: OldWcs.cc:128

◆ makeSipMatrixMetadata()

std::shared_ptr< daf::base::PropertyList > lsst::afw::geom::makeSipMatrixMetadata ( Eigen::MatrixXd const &  matrix,
std::string const &  name 
)

Definition at line 147 of file wcsUtils.cc.

148  {
149  if (matrix.rows() != matrix.cols() || matrix.rows() < 1) {
151  "Matrix must be square and at least 1 x 1; dimensions = " +
152  std::to_string(matrix.rows()) + " x " + std::to_string(matrix.cols()));
153  }
154  int const order = matrix.rows() - 1;
155  auto metadata = std::make_shared<daf::base::PropertyList>();
156  std::string cardName = name + "_ORDER";
157  metadata->set(cardName, order);
158  auto const coeffName = name + "_";
159  for (int i = 0; i <= order; ++i) {
160  for (int j = 0; j <= order; ++j) {
161  if (matrix(i, j) != 0.0) {
162  metadata->set(getSipCoeffCardName(coeffName, i, j), matrix(i, j));
163  }
164  }
165  }
166  return metadata;
167 }

◆ makeSkyWcs() [1/3]

std::shared_ptr< SkyWcs > lsst::afw::geom::makeSkyWcs ( daf::base::PropertySet metadata,
bool  strip = false 
)

Construct a SkyWcs from FITS keywords.

This function is preferred over calling the SkyWcs metadata constructor directly because it allows us to change SkyWcs to an abstract base class in the future, without affecting code that constructs a WCS from FITS metadata.

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

Definition at line 521 of file SkyWcs.cc.

521  {
522  return std::make_shared<SkyWcs>(metadata, strip);
523 }

◆ makeSkyWcs() [2/3]

std::shared_ptr< SkyWcs > lsst::afw::geom::makeSkyWcs ( lsst::geom::Point2D const &  crpix,
lsst::geom::SpherePoint const &  crval,
Eigen::Matrix2d const &  cdMatrix,
std::string const &  projection = "TAN" 
)

Construct a simple FITS SkyWcs with no distortion.

Parameters
[in]crpixCenter of projection on the CCD using the LSST convention: 0, 0 is the lower left pixel of the parent image
[in]crvalCenter of projection on the sky
[in]cdMatrixCD matrix, where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]. May be computed by calling makeCdMatrix.
[in]projectionThe name of the FITS WCS projection, e.g. "TAN" or "STG"

Definition at line 525 of file SkyWcs.cc.

526  {
527  auto metadata = makeSimpleWcsMetadata(crpix, crval, cdMatrix, projection);
528  return std::make_shared<SkyWcs>(*metadata);
529 }
std::shared_ptr< daf::base::PropertyList > makeSimpleWcsMetadata(lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, std::string const &projection="TAN")
Make FITS metadata for a simple FITS WCS (one with no distortion).
Definition: wcsUtils.cc:169

◆ makeSkyWcs() [3/3]

std::shared_ptr< SkyWcs > lsst::afw::geom::makeSkyWcs ( TransformPoint2ToPoint2 const &  pixelsToFieldAngle,
lsst::geom::Angle const &  orientation,
bool  flipX,
lsst::geom::SpherePoint const &  boresight,
std::string const &  projection = "TAN" 
)

Construct a FITS SkyWcs from camera geometry.

Parameters
[in]pixelsToFieldAngleTransformation from pixels to field angle (in radians).
[in]orientationPosition angle of focal plane +Y, measured from N through E at crval. At 0 degrees, +Y is along N and +X is along W/E if flipX false/true. At 90 degrees, +Y is along E and +X is along N/S if flipX false/true.
[in]flipXFlip x axis? See orientation for details.
[in]boresightICRS sky position at the boresight (field angle (0, 0)).
[in]projectionThe name of the FITS WCS projection, e.g. "TAN" or "STG".
Returns
a SkyWcs whose sky origin is the boresight and pixel origin is focal plane (0, 0).
Note
Unlike makeCdMatrix, orientation is with respect to the focal plane axes, not the CCD axes. This is because field angle is defined with respect to focal plane axes.

Definition at line 531 of file SkyWcs.cc.

533  {
534  auto frameDict = makeSkyWcsFrameDict(pixelsToFieldAngle, orientation, flipX, boresight, projection);
535  return std::make_shared<SkyWcs>(frameDict);
536 }

◆ makeTanSipMetadata() [1/2]

std::shared_ptr< daf::base::PropertyList > lsst::afw::geom::makeTanSipMetadata ( lsst::geom::Point2D const &  crpix,
lsst::geom::SpherePoint const &  crval,
Eigen::Matrix2d const &  cdMatrix,
Eigen::MatrixXd const &  sipA,
Eigen::MatrixXd const &  sipB 
)

Make metadata for a TAN-SIP WCS without inverse matrices.

Parameters
[in]crpixCenter of projection on the CCD using the LSST convention: 0, 0 is the lower left pixel of the parent image
[in]crvalCenter of projection on the sky
[in]cdMatrixCD matrix, where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]. May be computed by calling makeCdMatrix.
[in]sipAForward distortion matrix for axis 1
[in]sipBForward distortion matrix for axis 2

Definition at line 194 of file wcsUtils.cc.

198  {
199  auto metadata = makeSimpleWcsMetadata(crpix, crval, cdMatrix, "TAN-SIP");
200  metadata->combine(makeSipMatrixMetadata(sipA, "A"));
201  metadata->combine(makeSipMatrixMetadata(sipB, "B"));
202  return metadata;
203 }
std::shared_ptr< daf::base::PropertyList > makeSipMatrixMetadata(Eigen::MatrixXd const &matrix, std::string const &name)
Definition: wcsUtils.cc:147

◆ makeTanSipMetadata() [2/2]

std::shared_ptr< daf::base::PropertyList > lsst::afw::geom::makeTanSipMetadata ( lsst::geom::Point2D const &  crpix,
lsst::geom::SpherePoint const &  crval,
Eigen::Matrix2d const &  cdMatrix,
Eigen::MatrixXd const &  sipA,
Eigen::MatrixXd const &  sipB,
Eigen::MatrixXd const &  sipAp,
Eigen::MatrixXd const &  sipBp 
)

Make metadata for a TAN-SIP WCS.

Parameters
[in]crpixCenter of projection on the CCD using the LSST convention: 0, 0 is the lower left pixel of the parent image
[in]crvalCenter of projection on the sky
[in]cdMatrixCD matrix, where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]. May be computed by calling makeCdMatrix.
[in]sipAForward distortion matrix for axis 1
[in]sipBForward distortion matrix for axis 2
[in]sipApReverse distortion matrix for axis 1
[in]sipBpReverse distortion matrix for axis 2

Definition at line 205 of file wcsUtils.cc.

208  {
209  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB);
210  metadata->combine(makeSipMatrixMetadata(sipAp, "AP"));
211  metadata->combine(makeSipMatrixMetadata(sipBp, "BP"));
212  return metadata;
213 }
std::shared_ptr< daf::base::PropertyList > makeTanSipMetadata(lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB)
Make metadata for a TAN-SIP WCS without inverse matrices.
Definition: wcsUtils.cc:194

◆ makeTanSipWcs() [1/2]

std::shared_ptr< SkyWcs > lsst::afw::geom::makeTanSipWcs ( lsst::geom::Point2D const &  crpix,
lsst::geom::SpherePoint const &  crval,
Eigen::Matrix2d const &  cdMatrix,
Eigen::MatrixXd const &  sipA,
Eigen::MatrixXd const &  sipB 
)

Construct a TAN-SIP SkyWcs with forward SIP distortion terms and an iterative inverse.

Parameters
[in]crpixCenter of projection on the CCD using the LSST convention: 0, 0 is the lower left pixel of the parent image
[in]crvalCenter of projection on the sky
[in]cdMatrixCD matrix, where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]. May be computed by calling makeCdMatrix.
[in]sipAForward distortion matrix for axis 1
[in]sipBForward distortion matrix for axis 2

Definition at line 538 of file SkyWcs.cc.

540  {
541  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB);
542  return std::make_shared<SkyWcs>(*metadata);
543 }

◆ makeTanSipWcs() [2/2]

std::shared_ptr< SkyWcs > lsst::afw::geom::makeTanSipWcs ( lsst::geom::Point2D const &  crpix,
lsst::geom::SpherePoint const &  crval,
Eigen::Matrix2d const &  cdMatrix,
Eigen::MatrixXd const &  sipA,
Eigen::MatrixXd const &  sipB,
Eigen::MatrixXd const &  sipAp,
Eigen::MatrixXd const &  sipBp 
)

Construct a TAN WCS with forward and inverse SIP distortion terms.

Parameters
[in]crpixCenter of projection on the CCD using the LSST convention: 0, 0 is the lower left pixel of the parent image
[in]crvalCenter of projection on the sky
[in]cdMatrixCD matrix, where element (i-1, j-1) corresponds to FITS keyword CDi_j and i, j have range [1, 2]. May be computed by calling makeCdMatrix.
[in]sipAForward distortion matrix for axis 1
[in]sipBForward distortion matrix for axis 2
[in]sipApReverse distortion matrix for axis 1
[in]sipBpReverse distortion matrix for axis 2

Definition at line 545 of file SkyWcs.cc.

548  {
549  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB, sipAp, sipBp);
550  return std::make_shared<SkyWcs>(*metadata);
551 }

◆ makeTransform()

std::shared_ptr< TransformPoint2ToPoint2 > lsst::afw::geom::makeTransform ( lsst::geom::AffineTransform const &  affine)

Wrap an lsst::geom::AffineTransform as a Transform.

Parameters
affineThe lsst::geom::AffineTransform to wrap.
Returns
a Transform that that maps any lsst::geom::Point2D x to affine(x). It shall be invertible iff affine is invertible.
Exception Safety
Provides basic exception safety.

Definition at line 154 of file transformFactory.cc.

154  {
155  auto const offset = lsst::geom::Point2D(affine.getTranslation());
156  auto const jacobian = affine.getLinear().getMatrix();
157 
158  Point2Endpoint toEndpoint;
159  auto const map = ast::MatrixMap(toNdArray(jacobian))
160  .then(ast::ShiftMap(toEndpoint.dataFromPoint(offset)))
161  .simplified();
162  return std::make_shared<TransformPoint2ToPoint2>(*map);
163 }
MatrixMap is a form of Mapping which performs a general linear transformation.
Definition: MatrixMap.h:42
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
Definition: ShiftMap.h:40
Point< double, 2 > Point2D
Definition: Point.h:324

◆ makeWcsPairTransform()

std::shared_ptr< TransformPoint2ToPoint2 > lsst::afw::geom::makeWcsPairTransform ( SkyWcs const &  src,
SkyWcs const &  dst 
)

A Transform obtained by putting two SkyWcs objects "back to back".

Parameters
srcthe WCS for the source pixels
dstthe WCS for the destination pixels
Returns
a Transform whose forward transformation converts from src pixels to dst pixels, and whose inverse transformation converts in the opposite direction.
Exception Safety
Provides basic exception safety.

Definition at line 146 of file SkyWcs.cc.

146  {
147  auto const dstInverse = dst.getTransform()->inverted();
148  return src.getTransform()->then(*dstInverse);
149 }
std::shared_ptr< RecordT > src
Definition: Match.cc:48

◆ operator<<() [1/5]

std::ostream & lsst::afw::geom::operator<< ( std::ostream os,
GenericEndpoint const &  endpoint 
)

Print "GenericEndpoint(_n_)" to the ostream where _n_ is the number of axes, e.g. "GenericAxes(4)".

Definition at line 239 of file Endpoint.cc.

239  {
240  os << "GenericEndpoint(" << endpoint.getNAxes() << ")";
241  return os;
242 }
std::ostream * os
Definition: Schema.cc:557

◆ operator<<() [2/5]

std::ostream & lsst::afw::geom::operator<< ( std::ostream os,
Point2Endpoint const &  endpoint 
)

Print "Point2Endpoint()" to the ostream.

Definition at line 244 of file Endpoint.cc.

244  {
245  os << "Point2Endpoint()";
246  return os;
247 }

◆ operator<<() [3/5]

std::ostream & lsst::afw::geom::operator<< ( std::ostream os,
SkyWcs const &  wcs 
)

Print a SkyWcs to an ostream (delegates to SkyWcs.toString()).

Definition at line 564 of file SkyWcs.cc.

564  {
565  os << wcs.toString();
566  return os;
567 };

◆ operator<<() [4/5]

std::ostream & lsst::afw::geom::operator<< ( std::ostream os,
SpherePointEndpoint const &  endpoint 
)

Print "SpherePointEndpoint()" to the ostream.

Definition at line 249 of file Endpoint.cc.

249  {
250  os << "SpherePointEndpoint()";
251  return os;
252 }

◆ operator<<() [5/5]

template<class FromEndpoint , class ToEndpoint >
std::ostream & lsst::afw::geom::operator<< ( std::ostream os,
Transform< FromEndpoint, ToEndpoint > const &  transform 
)

Print a Transform to an ostream.

The format is "Transform<_fromEndpoint_, _toEndpoint_>" where fromEndpoint and toEndpoint are the appropriate endpoint printed to the ostream; for example "Transform<GenericEndpoint(4), Point2Endpoint()>"

Definition at line 188 of file Transform.cc.

188  {
189  os << "Transform<" << transform.getFromEndpoint() << ", " << transform.getToEndpoint() << ">";
190  return os;
191 };
table::Key< int > transform

◆ operator<<< GenericEndpoint, GenericEndpoint >()

template std::ostream& lsst::afw::geom::operator<<< GenericEndpoint, GenericEndpoint > ( std::ostream os,
Transform< GenericEndpoint, GenericEndpoint > const &  transform 
)

◆ operator<<< GenericEndpoint, Point2Endpoint >()

template std::ostream& lsst::afw::geom::operator<<< GenericEndpoint, Point2Endpoint > ( std::ostream os,
Transform< GenericEndpoint, Point2Endpoint > const &  transform 
)

◆ operator<<< GenericEndpoint, SpherePointEndpoint >()

template std::ostream& lsst::afw::geom::operator<<< GenericEndpoint, SpherePointEndpoint > ( std::ostream os,
Transform< GenericEndpoint, SpherePointEndpoint > const &  transform 
)

◆ operator<<< Point2Endpoint, GenericEndpoint >()

template std::ostream& lsst::afw::geom::operator<<< Point2Endpoint, GenericEndpoint > ( std::ostream os,
Transform< Point2Endpoint, GenericEndpoint > const &  transform 
)

◆ operator<<< Point2Endpoint, Point2Endpoint >()

template std::ostream& lsst::afw::geom::operator<<< Point2Endpoint, Point2Endpoint > ( std::ostream os,
Transform< Point2Endpoint, Point2Endpoint > const &  transform 
)

◆ operator<<< Point2Endpoint, SpherePointEndpoint >()

template std::ostream& lsst::afw::geom::operator<<< Point2Endpoint, SpherePointEndpoint > ( std::ostream os,
Transform< Point2Endpoint, SpherePointEndpoint > const &  transform 
)

◆ operator<<< SpherePointEndpoint, GenericEndpoint >()

template std::ostream& lsst::afw::geom::operator<<< SpherePointEndpoint, GenericEndpoint > ( std::ostream os,
Transform< SpherePointEndpoint, GenericEndpoint > const &  transform 
)

◆ operator<<< SpherePointEndpoint, Point2Endpoint >()

template std::ostream& lsst::afw::geom::operator<<< SpherePointEndpoint, Point2Endpoint > ( std::ostream os,
Transform< SpherePointEndpoint, Point2Endpoint > const &  transform 
)

◆ operator<<< SpherePointEndpoint, SpherePointEndpoint >()

template std::ostream& lsst::afw::geom::operator<<< SpherePointEndpoint, SpherePointEndpoint > ( std::ostream os,
Transform< SpherePointEndpoint, SpherePointEndpoint > const &  transform 
)

◆ PYBIND11_MODULE()

lsst::afw::geom::PYBIND11_MODULE ( _geom  ,
mod   
)

Definition at line 46 of file _geom.cc.

46  {
47  lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.geom");
48  wrapEndpoint(wrappers);
49  polygon::wrapPolygon(wrappers);
50  wrapSipApproximation(wrappers);
51  wrapSkyWcs(wrappers);
52  wrapSpan(wrappers);
53  wrapSpanSet(wrappers);
54  wrapTransform(wrappers);
55  wrapTransformFactory(wrappers);
56  wrappers.makeSubmodule("wcsUtils");
57  wrapWcsUtils(wrappers);
58  wrappers.finish();
59 }
void wrapPolygon(lsst::utils::python::WrapperCollection &)
Definition: _polygon.cc:129
void wrapWcsUtils(lsst::utils::python::WrapperCollection &)
Definition: _wcsUtils.cc:46
void wrapSpan(lsst::utils::python::WrapperCollection &)
Definition: _span.cc:102
void wrapTransform(lsst::utils::python::WrapperCollection &)
Definition: _transform.cc:130
void wrapEndpoint(lsst::utils::python::WrapperCollection &wrappers)
Definition: _endpoint.cc:201
void wrapTransformFactory(lsst::utils::python::WrapperCollection &)
void wrapSpanSet(lsst::utils::python::WrapperCollection &)
Definition: _spanSet.cc:335
void wrapSipApproximation(lsst::utils::python::WrapperCollection &)
void wrapSkyWcs(lsst::utils::python::WrapperCollection &)
Definition: _skyWcs.cc:165

◆ SpanSet::clearMask< image::MaskPixel >()

◆ SpanSet::intersect< image::MaskPixel >()

◆ SpanSet::intersectNot< image::MaskPixel >()

◆ SpanSet::setImage< std::uint16_t >()

template void lsst::afw::geom::SpanSet::setImage< std::uint16_t > ( image::Image< std::uint16_t > &  image,
std::uint16_t  val,
lsst::geom::Box2I const &  region = lsst::geom::Box2I(),
bool  doClip = false 
) const

◆ SpanSet::setImage< std::uint64_t >()

template void lsst::afw::geom::SpanSet::setImage< std::uint64_t > ( image::Image< std::uint64_t > &  image,
std::uint64_t  val,
lsst::geom::Box2I const &  region = lsst::geom::Box2I(),
bool  doClip = false 
) const

◆ SpanSet::setMask< image::MaskPixel >()

◆ SpanSet::union_< image::MaskPixel >()

◆ wrapEndpoint()

void lsst::afw::geom::wrapEndpoint ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 201 of file _endpoint.cc.

201  {
202  wrappers.addSignatureDependency("lsst.geom");
203  declareGenericEndpoint(wrappers);
204  declarePoint2Endpoint(wrappers);
205  declareSpherePointEndpoint(wrappers);
206 }

◆ wrapSipApproximation()

void lsst::afw::geom::wrapSipApproximation ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 88 of file _sipApproximation.cc.

88  {
89  declareSipApproximation(wrappers);
90 }

◆ wrapSkyWcs()

void lsst::afw::geom::wrapSkyWcs ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 165 of file _skyWcs.cc.

165  {
166  wrappers.addInheritanceDependency("lsst.afw.table.io");
167  wrappers.addInheritanceDependency("lsst.afw.typehandling");
168  wrappers.addSignatureDependency("astshim");
169  declareSkyWcs(wrappers);
170 }

◆ wrapSpan()

void lsst::afw::geom::wrapSpan ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 102 of file _span.cc.

102  {
103  declareSpanIterator(wrappers);
104  declareSpan(wrappers);
105 }

◆ wrapSpanSet()

void lsst::afw::geom::wrapSpanSet ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 335 of file _spanSet.cc.

335  {
336  wrappers.addSignatureDependency("lsst.afw.table.io");
337  wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
338  declareStencil(wrappers);
339  declareSpanSet(wrappers);
340 }

◆ wrapTransform()

void lsst::afw::geom::wrapTransform ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 130 of file _transform.cc.

130  {
131  wrappers.addSignatureDependency("lsst.afw.table.io");
132  wrappers.addSignatureDependency("astshim");
133  declareTransform<GenericEndpoint, GenericEndpoint>(wrappers);
134  declareTransform<GenericEndpoint, Point2Endpoint>(wrappers);
135  declareTransform<GenericEndpoint, SpherePointEndpoint>(wrappers);
136  declareTransform<Point2Endpoint, GenericEndpoint>(wrappers);
137  declareTransform<Point2Endpoint, Point2Endpoint>(wrappers);
138  declareTransform<Point2Endpoint, SpherePointEndpoint>(wrappers);
139  declareTransform<SpherePointEndpoint, GenericEndpoint>(wrappers);
140  declareTransform<SpherePointEndpoint, Point2Endpoint>(wrappers);
141  declareTransform<SpherePointEndpoint, SpherePointEndpoint>(wrappers);
142 }

◆ wrapTransformFactory()

void lsst::afw::geom::wrapTransformFactory ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 66 of file _transformFactory.cc.

66  {
67  declareTransformFactory(wrappers);
68  wrappers.addSignatureDependency("astshim");
69 }

◆ wrapWcsUtils()

void lsst::afw::geom::wrapWcsUtils ( lsst::utils::python::WrapperCollection &  wrappers)

Definition at line 46 of file _wcsUtils.cc.

46  {
47  wrappers.wrap([](auto &mod) {
48  mod.def("createTrivialWcsMetadata", createTrivialWcsMetadata, "wcsName"_a, "xy0"_a);
49  mod.def("deleteBasicWcsMetadata", deleteBasicWcsMetadata, "metadata"_a, "wcsName"_a);
50  mod.def("getCdMatrixFromMetadata", getCdMatrixFromMetadata, "metadata"_a);
51  mod.def("getImageXY0FromMetadata", getImageXY0FromMetadata, "metadata"_a, "wcsName"_a,
52  "strip"_a = false);
53  // getSipMatrixFromMetadata requires a pure python wrapper to return a matrix when order=0
54  mod.def("_getSipMatrixFromMetadata", getSipMatrixFromMetadata, "metadata"_a, "name"_a);
55  mod.def("hasSipMatrix", hasSipMatrix, "metadata"_a, "name"_a);
56  mod.def("makeSipMatrixMetadata", makeSipMatrixMetadata, "matrix"_a, "name"_a);
57  mod.def("makeSimpleWcsMetadata", makeSimpleWcsMetadata, "crpix"_a, "crval"_a, "cdMatrix"_a,
58  "projection"_a = "TAN");
59  mod.def("makeTanSipMetadata",
61  lsst::geom::Point2D const &, lsst::geom::SpherePoint const &, Eigen::Matrix2d const &,
62  Eigen::MatrixXd const &, Eigen::MatrixXd const &))makeTanSipMetadata,
63  "crpix"_a, "crval"_a, "cdMatrix"_a, "sipA"_a, "sipB"_a);
64  mod.def("makeTanSipMetadata",
66  lsst::geom::Point2D const &, lsst::geom::SpherePoint const &, Eigen::Matrix2d const &,
67  Eigen::MatrixXd const &, Eigen::MatrixXd const &, Eigen::MatrixXd const &,
68  Eigen::MatrixXd const &))makeTanSipMetadata,
69  "crpix"_a, "crval"_a, "cdMatrix"_a, "sipA"_a, "sipB"_a, "sipAp"_a, "sipBp"_a);
70  });
71 }
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
Eigen::MatrixXd getSipMatrixFromMetadata(daf::base::PropertySet const &metadata, std::string const &name)
Definition: wcsUtils.cc:113
bool hasSipMatrix(daf::base::PropertySet const &metadata, std::string const &name)
Definition: wcsUtils.cc:139
Eigen::Matrix2d getCdMatrixFromMetadata(daf::base::PropertySet &metadata)
Read a CD matrix from FITS WCS metadata.
Definition: wcsUtils.cc:75
std::shared_ptr< daf::base::PropertyList > createTrivialWcsMetadata(std::string const &wcsName, lsst::geom::Point2I const &xy0)
Definition: wcsUtils.cc:48
lsst::geom::Point2I getImageXY0FromMetadata(daf::base::PropertySet &metadata, std::string const &wcsName, bool strip=false)
Definition: wcsUtils.cc:95