LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions
lsst::afw::geom Namespace Reference

Namespaces

 calculateSipWcsHeader
 
 detail
 
 details
 
 ellipses
 
 polygon
 
 python
 
 skyWcs
 
 testUtils
 
 transform
 
 transformConfig
 
 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  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  SpherePointEndpoint
 An endpoint for lsst::geom::SpherePoint. 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  Stencil { Stencil::CIRCLE, Stencil::BOX, Stencil::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...
 
 PYBIND11_MODULE (spanSet, 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.

66 { CIRCLE, BOX, MANHATTAN };

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 51 of file wcsUtils.cc.

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

◆ deleteBasicWcsMetadata()

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

Definition at line 67 of file wcsUtils.cc.

67  {
68  std::vector<std::string> const names = {"CRPIX1", "CRPIX2", "CRVAL1", "CRVAL2", "CTYPE1",
69  "CTYPE2", "CUNIT1", "CUNIT2", "CD1_1", "CD1_2",
70  "CD2_1", "CD2_2", "WCSAXES"};
71  for (auto const& name : names) {
72  if (metadata.exists(name + wcsName)) {
73  metadata.remove(name + wcsName);
74  }
75  }
76 }

◆ 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 78 of file wcsUtils.cc.

78  {
79  Eigen::Matrix2d matrix;
80  bool found{false};
81  for (int i = 0; i < 2; ++i) {
82  for (int j = 0; j < 2; ++j) {
83  std::string const cardName = "CD" + std::to_string(i + 1) + "_" + std::to_string(j + 1);
84  if (metadata.exists(cardName)) {
85  matrix(i, j) = metadata.getAsDouble(cardName);
86  found = true;
87  } else {
88  matrix(i, j) = 0.0;
89  }
90  }
91  }
92  if (!found) {
93  throw LSST_EXCEPT(pex::exceptions::TypeError, "No CD matrix coefficients found");
94  }
95  return matrix;
96 }

◆ getImageXY0FromMetadata()

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

Definition at line 98 of file wcsUtils.cc.

99  {
100  int x0 = 0; // Our value of X0
101  int y0 = 0; // Our value of Y0
102 
103  if (metadata.exists("CRPIX1" + wcsName) && metadata.exists("CRPIX2" + wcsName) &&
104  metadata.exists("CRVAL1" + wcsName) && metadata.exists("CRVAL2" + wcsName) &&
105  (metadata.getAsDouble("CRPIX1" + wcsName) == 1.0) &&
106  (metadata.getAsDouble("CRPIX2" + wcsName) == 1.0)) {
107  x0 = static_cast<int>(std::lround(metadata.getAsDouble("CRVAL1" + wcsName)));
108  y0 = static_cast<int>(std::lround(metadata.getAsDouble("CRVAL2" + wcsName)));
109  if (strip) {
110  deleteBasicWcsMetadata(metadata, wcsName);
111  }
112  }
113  return lsst::geom::Point2I(x0, y0);
114 }

◆ 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 558 of file SkyWcs.cc.

559  {
560  auto iwcToSky = wcs.getFrameDict()->getMapping("IWC", "SKY");
561  return std::make_shared<TransformPoint2ToSpherePoint>(*iwcToSky, simplify);
562 }

◆ 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 564 of file SkyWcs.cc.

564  {
565  auto pixelToIwc = wcs.getFrameDict()->getMapping(ast::FrameSet::BASE, "IWC");
566  return std::make_shared<TransformPoint2ToPoint2>(*pixelToIwc, simplify);
567 }

◆ getSipMatrixFromMetadata()

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

Definition at line 116 of file wcsUtils.cc.

116  {
117  std::string cardName = name + "_ORDER";
118  if (!metadata.exists(cardName)) {
120  "metadata does not contain SIP matrix " + name + ": " + cardName + " not found");
121  };
122  int order = metadata.getAsInt(cardName);
123  if (order < 0) {
125  "matrix order = " + std::to_string(order) + " < 0");
126  }
127  Eigen::MatrixXd matrix(order + 1, order + 1);
128  auto const coeffName = name + "_";
129  for (int i = 0; i <= order; ++i) {
130  for (int j = 0; j <= order; ++j) {
131  std::string const cardName = getSipCoeffCardName(coeffName, i, j);
132  if (metadata.exists(cardName)) {
133  matrix(i, j) = metadata.getAsDouble(cardName);
134  } else {
135  matrix(i, j) = 0.0;
136  }
137  }
138  }
139  return matrix;
140 }

◆ hasSipMatrix()

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

Definition at line 142 of file wcsUtils.cc.

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

◆ 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\n 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 }

◆ 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 138 of file SkyWcs.cc.

139  {
140  Eigen::Matrix2d cdMatrix;
141  double orientRad = orientation.asRadians();
142  double scaleDeg = scale.asDegrees();
143  double xmult = flipX ? 1.0 : -1.0;
144  cdMatrix(0, 0) = std::cos(orientRad) * scaleDeg * xmult;
145  cdMatrix(0, 1) = std::sin(orientRad) * scaleDeg;
146  cdMatrix(1, 0) = -std::sin(orientRad) * scaleDeg * xmult;
147  cdMatrix(1, 1) = std::cos(orientRad) * scaleDeg;
148  return cdMatrix;
149 }

◆ 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 472 of file SkyWcs.cc.

473  {
474  double const dx = 1000; // any "reasonable" number of pixels will do
475  std::vector<double> inLL = {center[0] - dx, center[1] - dx};
476  std::vector<double> inUR = {center[0] + dx, center[1] + dx};
477  std::vector<double> outLL(inLL);
478  std::vector<double> outUR(inUR);
479  if (flipLR) {
480  outLL[0] = inUR[0];
481  outUR[0] = inLL[0];
482  }
483  if (flipTB) {
484  outLL[1] = inUR[1];
485  outUR[1] = inLL[1];
486  }
487  auto const flipPix = TransformPoint2ToPoint2(ast::WinMap(inLL, inUR, outLL, outUR));
488  return makeModifiedWcs(flipPix, wcs, true);
489 }

◆ 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\n Provides basic exception safety.

Definition at line 214 of file transformFactory.cc.

214  {
215  return std::make_shared<TransformPoint2ToPoint2>(ast::UnitMap(2));
216 }

◆ 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 491 of file SkyWcs.cc.

492  {
493  auto const pixelMapping = pixelTransform.getMapping();
494  auto oldFrameDict = wcs.getFrameDict();
495  bool const hasActualPixels = oldFrameDict->hasDomain("ACTUAL_PIXELS");
496  auto const pixelFrame = oldFrameDict->getFrame("PIXELS", false);
497  auto const iwcFrame = oldFrameDict->getFrame("IWC", false);
498  auto const skyFrame = oldFrameDict->getFrame("SKY", false);
499  auto const oldPixelToIwc = oldFrameDict->getMapping("PIXELS", "IWC");
500  auto const iwcToSky = oldFrameDict->getMapping("IWC", "SKY");
501 
502  std::shared_ptr<ast::FrameDict> newFrameDict;
503  std::shared_ptr<ast::Mapping> newPixelToIwc;
504  if (hasActualPixels) {
505  auto const actualPixelFrame = oldFrameDict->getFrame("ACTUAL_PIXELS", false);
506  auto const oldActualPixelToPixels = oldFrameDict->getMapping("ACTUAL_PIXELS", "PIXELS");
507  std::shared_ptr<ast::Mapping> newActualPixelsToPixels;
508  if (modifyActualPixels) {
509  newActualPixelsToPixels = pixelMapping->then(*oldActualPixelToPixels).simplified();
510  newPixelToIwc = oldPixelToIwc;
511  } else {
512  newActualPixelsToPixels = oldActualPixelToPixels;
513  newPixelToIwc = pixelMapping->then(*oldPixelToIwc).simplified();
514  }
515  newFrameDict =
516  std::make_shared<ast::FrameDict>(*actualPixelFrame, *newActualPixelsToPixels, *pixelFrame);
517  newFrameDict->addFrame("PIXELS", *newPixelToIwc, *iwcFrame);
518  } else {
519  newPixelToIwc = pixelMapping->then(*oldPixelToIwc).simplified();
520  newFrameDict = std::make_shared<ast::FrameDict>(*pixelFrame, *newPixelToIwc, *iwcFrame);
521  }
522  newFrameDict->addFrame("IWC", *iwcToSky, *skyFrame);
523  return std::make_shared<SkyWcs>(*newFrameDict);
524 }

◆ 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\n 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 }

◆ 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\n 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 }

◆ 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 172 of file wcsUtils.cc.

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

◆ makeSipMatrixMetadata()

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

Definition at line 150 of file wcsUtils.cc.

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

◆ 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 526 of file SkyWcs.cc.

526  {
527  return std::make_shared<SkyWcs>(metadata, strip);
528 }

◆ 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 530 of file SkyWcs.cc.

531  {
532  auto metadata = makeSimpleWcsMetadata(crpix, crval, cdMatrix, projection);
533  return std::make_shared<SkyWcs>(*metadata);
534 }

◆ 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 536 of file SkyWcs.cc.

538  {
539  auto frameDict = makeSkyWcsFrameDict(pixelsToFieldAngle, orientation, flipX, boresight, projection);
540  return std::make_shared<SkyWcs>(frameDict);
541 }

◆ 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 197 of file wcsUtils.cc.

201  {
202  auto metadata = makeSimpleWcsMetadata(crpix, crval, cdMatrix, "TAN-SIP");
203  metadata->combine(makeSipMatrixMetadata(sipA, "A"));
204  metadata->combine(makeSipMatrixMetadata(sipB, "B"));
205  return metadata;
206 }

◆ 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 208 of file wcsUtils.cc.

211  {
212  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB);
213  metadata->combine(makeSipMatrixMetadata(sipAp, "AP"));
214  metadata->combine(makeSipMatrixMetadata(sipBp, "BP"));
215  return metadata;
216 }

◆ 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 543 of file SkyWcs.cc.

545  {
546  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB);
547  return std::make_shared<SkyWcs>(*metadata);
548 }

◆ 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 550 of file SkyWcs.cc.

553  {
554  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB, sipAp, sipBp);
555  return std::make_shared<SkyWcs>(*metadata);
556 }

◆ 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\n 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 }

◆ 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\n Provides basic exception safety.

Definition at line 151 of file SkyWcs.cc.

151  {
152  auto const dstInverse = dst.getTransform()->inverted();
153  return src.getTransform()->then(*dstInverse);
154 }

◆ 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 240 of file Endpoint.cc.

240  {
241  os << "GenericEndpoint(" << endpoint.getNAxes() << ")";
242  return os;
243 }

◆ operator<<() [2/5]

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

Print "Point2Endpoint()" to the ostream.

Definition at line 245 of file Endpoint.cc.

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

◆ 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 569 of file SkyWcs.cc.

569  {
570  os << wcs.toString();
571  return os;
572 };

◆ operator<<() [4/5]

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

Print "SpherePointEndpoint()" to the ostream.

Definition at line 250 of file Endpoint.cc.

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

◆ 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 189 of file Transform.cc.

189  {
190  os << "Transform<" << transform.getFromEndpoint() << ", " << transform.getToEndpoint() << ">";
191  return os;
192 };

◆ 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 ( spanSet  ,
mod   
)

Definition at line 195 of file spanSet.cc.

195  {
196  using MaskPixel = image::MaskPixel;
197 
198  py::module::import("lsst.geom");
199  py::module::import("lsst.afw.geom.span");
200 
201  py::enum_<Stencil>(mod, "Stencil")
202  .value("CIRCLE", Stencil::CIRCLE)
203  .value("BOX", Stencil::BOX)
204  .value("MANHATTAN", Stencil::MANHATTAN);
205 
206  PySpanSet cls(mod, "SpanSet");
207 
208  /* SpanSet Constructors */
209  cls.def(py::init<>());
210  cls.def(py::init<lsst::geom::Box2I>(), "box"_a);
211  cls.def(py::init<std::vector<Span>, bool>(), "spans"_a, "normalize"_a = true);
212 
213  table::io::python::addPersistableMethods<SpanSet>(cls);
214 
215  /* SpanSet Methods */
216  cls.def("getArea", &SpanSet::getArea);
217  cls.def("getBBox", &SpanSet::getBBox);
218  cls.def("isContiguous", &SpanSet::isContiguous);
219  cls.def("shiftedBy", (std::shared_ptr<SpanSet>(SpanSet::*)(int, int) const) & SpanSet::shiftedBy);
220  cls.def("shiftedBy",
221  (std::shared_ptr<SpanSet>(SpanSet::*)(lsst::geom::Extent2I const &) const) & SpanSet::shiftedBy);
222  cls.def("clippedTo", &SpanSet::clippedTo);
223  cls.def("transformedBy",
224  (std::shared_ptr<SpanSet>(SpanSet::*)(lsst::geom::LinearTransform const &) const) &
225  SpanSet::transformedBy);
226  cls.def("transformedBy",
227  (std::shared_ptr<SpanSet>(SpanSet::*)(lsst::geom::AffineTransform const &) const) &
228  SpanSet::transformedBy);
229  cls.def("transformedBy", (std::shared_ptr<SpanSet>(SpanSet::*)(TransformPoint2ToPoint2 const &) const) &
230  SpanSet::transformedBy);
231  cls.def("overlaps", &SpanSet::overlaps);
232  cls.def("contains", (bool (SpanSet::*)(SpanSet const &) const) & SpanSet::contains);
233  cls.def("contains", (bool (SpanSet::*)(lsst::geom::Point2I const &) const) & SpanSet::contains);
234  cls.def("computeCentroid", &SpanSet::computeCentroid);
235  cls.def("computeShape", &SpanSet::computeShape);
236  cls.def("dilated", (std::shared_ptr<SpanSet>(SpanSet::*)(int, Stencil) const) & SpanSet::dilated,
237  "radius"_a, "stencil"_a = Stencil::CIRCLE);
238  cls.def("dilated", (std::shared_ptr<SpanSet>(SpanSet::*)(SpanSet const &) const) & SpanSet::dilated);
239  cls.def("eroded", (std::shared_ptr<SpanSet>(SpanSet::*)(int, Stencil) const) & SpanSet::eroded,
240  "radius"_a, "stencil"_a = Stencil::CIRCLE);
241  cls.def("eroded", (std::shared_ptr<SpanSet>(SpanSet::*)(SpanSet const &) const) & SpanSet::eroded);
242  cls.def("intersect", (std::shared_ptr<SpanSet>(SpanSet::*)(SpanSet const &) const) & SpanSet::intersect);
243  cls.def("intersectNot",
244  (std::shared_ptr<SpanSet>(SpanSet::*)(SpanSet const &) const) & SpanSet::intersectNot);
245  cls.def("union", (std::shared_ptr<SpanSet>(SpanSet::*)(SpanSet const &) const) & SpanSet::union_);
246  cls.def_static("fromShape",
247  (std::shared_ptr<SpanSet>(*)(int, Stencil, lsst::geom::Point2I)) & SpanSet::fromShape,
248  "radius"_a, "stencil"_a = Stencil::CIRCLE, "offset"_a = lsst::geom::Point2I());
249  cls.def_static("fromShape",
250  [](int r, Stencil s, std::pair<int, int> point) {
251  return SpanSet::fromShape(r, s, lsst::geom::Point2I(point.first, point.second));
252  },
253  "radius"_a, "stencil"_a = Stencil::CIRCLE, "offset"_a = std::pair<int, int>(0, 0));
254  cls.def_static("fromShape",
255  (std::shared_ptr<SpanSet>(*)(geom::ellipses::Ellipse const &)) & SpanSet::fromShape);
256  cls.def("split", &SpanSet::split);
257  cls.def("findEdgePixels", &SpanSet::findEdgePixels);
258  cls.def("indices", [](SpanSet const &self) -> std::pair<std::vector<int>, std::vector<int>> {
259  std::vector<int> yind;
260  std::vector<int> xind;
261  yind.reserve(self.getArea());
262  xind.reserve(self.getArea());
263  for (auto const &span : self) {
264  auto y = span.getY();
265  for (int x = span.getX0(); x <= span.getX1(); ++x) {
266  yind.push_back(y);
267  xind.push_back(x);
268  }
269  }
270  return std::make_pair(yind, xind);
271  });
272 
273  /* SpanSet Operators */
274  cls.def("__eq__", [](SpanSet const &self, SpanSet const &other) -> bool { return self == other; },
275  py::is_operator());
276  cls.def("__ne__", [](SpanSet const &self, SpanSet const &other) -> bool { return self != other; },
277  py::is_operator());
278  cls.def("__iter__", [](SpanSet &self) { return py::make_iterator(self.begin(), self.end()); },
279  py::keep_alive<0, 1>());
280  cls.def("__len__", [](SpanSet const &self) -> decltype(self.size()) { return self.size(); });
281  cls.def("__contains__", [](SpanSet &self, SpanSet const &other) -> bool { return self.contains(other); });
282  cls.def("__contains__",
283  [](SpanSet &self, lsst::geom::Point2I &other) -> bool { return self.contains(other); });
284  cls.def("__repr__", [](SpanSet const &self) -> std::string {
286  image::Mask<MaskPixel> tempMask(self.getBBox());
287  self.setMask(tempMask, static_cast<MaskPixel>(1));
288  auto array = tempMask.getArray();
289  auto dims = array.getShape();
290  for (std::size_t i = 0; i < dims[0]; ++i) {
291  os << "[";
292  for (std::size_t j = 0; j < dims[1]; ++j) {
293  os << array[i][j];
294  if (j != dims[1] - 1) {
295  os << ", ";
296  }
297  }
298  os << "]" << std::endl;
299  }
300  return os.str();
301  });
302  cls.def("__str__", [](SpanSet const &self) -> std::string {
304  for (auto const &span : self) {
305  os << span.getY() << ": " << span.getMinX() << ".." << span.getMaxX() << std::endl;
306  }
307  return os.str();
308  });
309  // Instantiate all the templates
310 
311  declareMaskMethods<MaskPixel>(cls);
312 
313  declareImageTypes<std::uint16_t>(cls);
314  declareImageTypes<std::uint64_t>(cls);
315  declareImageTypes<int>(cls);
316  declareImageTypes<float>(cls);
317  declareImageTypes<double>(cls);
318 
319  // Extra instantiation for flatten unflatten methods
320  declareFlattenMethod<long>(cls);
321  declareUnflattenMethod<long>(cls);
322 
323  declarefromMask<MaskPixel>(cls);
324 }

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

y
int y
Definition: SpanSet.cc:49
lsst::afw::geom::deleteBasicWcsMetadata
void deleteBasicWcsMetadata(daf::base::PropertySet &metadata, std::string const &wcsName)
Definition: wcsUtils.cc:67
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::image::Mask
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
ast::Mapping::simplified
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
std::pair< int, int >
std::vector::reserve
T reserve(T... args)
wcs
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
std::cos
T cos(T... args)
lsst::sphgeom::orientation
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
std::vector< std::string >
ast::Mapping::then
SeriesMap then(Mapping const &next) const
Return a series compound mapping this(first(input)) containing shallow copies of the original.
Definition: Mapping.cc:37
lsst::geom::LinearTransform
A 2D linear coordinate transformation.
Definition: LinearTransform.h:69
lsst::afw::geom::Stencil::MANHATTAN
@ MANHATTAN
ast::FrameDict::addFrame
void addFrame(int iframe, Mapping const &map, Frame const &frame) override
Add a new Frame and an associated Mapping to this FrameSet so as to define a new coordinate system,...
Definition: FrameDict.cc:32
strip
bool strip
Definition: fits.cc:911
lsst::afw::geom::makeModifiedWcs
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:491
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
crval
table::PointKey< double > crval
Definition: OldWcs.cc:130
ast::PolyMap
PolyMap is a Mapping which performs a general polynomial transformation.
Definition: PolyMap.h:49
ast::MatrixMap
MatrixMap is a form of Mapping which performs a general linear transformation.
Definition: MatrixMap.h:42
end
int end
Definition: BoundedField.cc:105
src
std::shared_ptr< RecordT > src
Definition: Match.cc:48
ast::WinMap
A WinMap is a linear Mapping which transforms a rectangular window in one coordinate system into a si...
Definition: WinMap.h:45
lsst::afw::geom.transform.transformContinued.cls
cls
Definition: transformContinued.py:33
std::vector::push_back
T push_back(T... args)
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
std::isfinite
T isfinite(T... args)
std::forward
T forward(T... args)
astshim.fitsChanContinued.contains
def contains(self, name)
Definition: fitsChanContinued.py:127
x
double x
Definition: ChebyshevBoundedField.cc:277
ast::ShiftMap
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
Definition: ShiftMap.h:40
crpix
table::PointKey< double > crpix
Definition: OldWcs.cc:131
lsst::afw::geom::Stencil::BOX
@ BOX
ast::makeRadialMapping
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
other
ItemVariant const * other
Definition: Schema.cc:56
std::to_string
T to_string(T... args)
lsst::afw::geom::TransformPoint2ToPoint2
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
lsst::afw::geom::Stencil::CIRCLE
@ CIRCLE
lsst::afw::image::MaskPixel
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Definition: LsstImageTypes.h:34
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::sin
T sin(T... args)
std::ostringstream
STL class.
lsst::afw::geom.python.transform.toEndpoint
toEndpoint
Definition: transform.py:60
os
std::ostream * os
Definition: Schema.cc:746
std::lround
T lround(T... args)
std::endl
T endl(T... args)
std::begin
T begin(T... args)
ast::FrameSet::BASE
static constexpr int BASE
index of base frame
Definition: FrameSet.h:104
lsst::geom::Point< int, 2 >
lsst::afw::geom::makeTanSipMetadata
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:197
lsst::geom::Point2I
Point< int, 2 > Point2I
Definition: Point.h:321
lsst::afw.display.ds9.scale
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109
std::vector::empty
T empty(T... args)
transform
table::Key< int > transform
Definition: TransformMap.cc:299
std::ostringstream::str
T str(T... args)
std::size_t
std::make_pair
T make_pair(T... args)
lsst::afw::geom::makeSimpleWcsMetadata
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:172
lsst::pex::exceptions::TypeError
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167
ast::TranMap
TranMap is a Mapping which combines the forward transformation of a supplied Mapping with the inverse...
Definition: TranMap.h:49
lsst::utils.tests.init
def init()
Definition: tests.py:58
lsst::geom::Extent< int, 2 >
lsst::afw::geom::Stencil
Stencil
An enumeration class which describes the shapes.
Definition: SpanSet.h:66
lsst::afw::geom::makeSipMatrixMetadata
std::shared_ptr< daf::base::PropertyList > makeSipMatrixMetadata(Eigen::MatrixXd const &matrix, std::string const &name)
Definition: wcsUtils.cc:150
ast::UnitMap
A UnitMap is a unit (null) Mapping that has no effect on the coordinates supplied to it.
Definition: UnitMap.h:44