LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions
lsst::afw::geom Namespace Reference

Namespaces

 angle
 
 coordinates
 
 detail
 
 details
 
 ellipses
 
 polygon
 
 python
 
 skyWcs
 
 spherePoint
 
 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. 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.

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 }
T to_string(T... args)
STL class.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ 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 }
Point< int, 2 > Point2I
Definition: Point.h:321
void deleteBasicWcsMetadata(daf::base::PropertySet &metadata, std::string const &wcsName)
Definition: wcsUtils.cc:67
T lround(T... args)
bool strip
Definition: fits.cc:831

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

509  {
510  auto iwcToSky = wcs.getFrameDict()->getMapping("IWC", "SKY");
511  return std::make_shared<TransformPoint2ToSpherePoint>(*iwcToSky, simplify);
512 }
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71

◆ 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: ACTUAL_PIXELS, if present, else PIXELS.

Definition at line 514 of file SkyWcs.cc.

514  {
515  auto pixelToIwc = wcs.getFrameDict()->getMapping(ast::FrameSet::BASE, "IWC");
516  return std::make_shared<TransformPoint2ToPoint2>(*pixelToIwc, simplify);
517 }
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
static int constexpr 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 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 }
T to_string(T... args)
STL class.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167

◆ 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 }
STL class.

◆ 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 str(T... args)
T isfinite(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

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

140  {
141  Eigen::Matrix2d cdMatrix;
142  double orientRad = orientation.asRadians();
143  double scaleDeg = scale.asDegrees();
144  double xmult = flipX ? 1.0 : -1.0;
145  cdMatrix(0, 0) = std::cos(orientRad) * scaleDeg * xmult;
146  cdMatrix(0, 1) = std::sin(orientRad) * scaleDeg;
147  cdMatrix(1, 0) = -std::sin(orientRad) * scaleDeg * xmult;
148  cdMatrix(1, 1) = std::cos(orientRad) * scaleDeg;
149  return cdMatrix;
150 }
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109
T sin(T... args)
T cos(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 422 of file SkyWcs.cc.

423  {
424  double const dx = 1000; // any "reasonable" number of pixels will do
425  std::vector<double> inLL = {center[0] - dx, center[1] - dx};
426  std::vector<double> inUR = {center[0] + dx, center[1] + dx};
427  std::vector<double> outLL(inLL);
428  std::vector<double> outUR(inUR);
429  if (flipLR) {
430  outLL[0] = inUR[0];
431  outUR[0] = inLL[0];
432  }
433  if (flipTB) {
434  outLL[1] = inUR[1];
435  outUR[1] = inLL[1];
436  }
437  auto const flipPix = TransformPoint2ToPoint2(ast::WinMap(inLL, inUR, outLL, outUR));
438  return makeModifiedWcs(flipPix, wcs, true);
439 }
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:441
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
A WinMap is a linear Mapping which transforms a rectangular window in one coordinate system into a si...
Definition: WinMap.h:45

◆ 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 ACTUAL_PIXELS frame exists then pixelTransform is inserted just after the 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 ACTUAL_PIXELS frame does not exist then pixelTransform is inserted just after the 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 ACTUAL_PIXELS frame is present then insert just after the ACTUAL_PIXELS frame, else insert just after the PIXELS frame.
Returns
the new WCS

Definition at line 441 of file SkyWcs.cc.

442  {
443  auto const pixelMapping = pixelTransform.getMapping();
444  auto oldFrameDict = wcs.getFrameDict();
445  bool const hasActualPixels = oldFrameDict->hasDomain("ACTUAL_PIXELS");
446  auto const pixelFrame = oldFrameDict->getFrame("PIXELS", false);
447  auto const iwcFrame = oldFrameDict->getFrame("IWC", false);
448  auto const skyFrame = oldFrameDict->getFrame("SKY", false);
449  auto const oldPixelToIwc = oldFrameDict->getMapping("PIXELS", "IWC");
450  auto const iwcToSky = oldFrameDict->getMapping("IWC", "SKY");
451 
452  std::shared_ptr<ast::FrameDict> newFrameDict;
453  std::shared_ptr<ast::Mapping> newPixelToIwc;
454  if (hasActualPixels) {
455  auto const actualPixelFrame = oldFrameDict->getFrame("ACTUAL_PIXELS", false);
456  auto const oldActualPixelToPixels = oldFrameDict->getMapping("ACTUAL_PIXELS", "PIXELS");
457  std::shared_ptr<ast::Mapping> newActualPixelsToPixels;
458  if (modifyActualPixels) {
459  newActualPixelsToPixels = pixelMapping->then(*oldActualPixelToPixels).simplified();
460  newPixelToIwc = oldPixelToIwc;
461  } else {
462  newActualPixelsToPixels = oldActualPixelToPixels;
463  newPixelToIwc = pixelMapping->then(*oldPixelToIwc).simplified();
464  }
465  newFrameDict =
466  std::make_shared<ast::FrameDict>(*actualPixelFrame, *newActualPixelsToPixels, *pixelFrame);
467  newFrameDict->addFrame("PIXELS", *newPixelToIwc, *iwcFrame);
468  } else {
469  newPixelToIwc = pixelMapping->then(*oldPixelToIwc).simplified();
470  newFrameDict = std::make_shared<ast::FrameDict>(*pixelFrame, *newPixelToIwc, *iwcFrame);
471  }
472  newFrameDict->addFrame("IWC", *iwcToSky, *skyFrame);
473  return std::make_shared<SkyWcs>(*newFrameDict);
474 }
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71

◆ 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 }
A UnitMap is a unit (null) Mapping that has no effect on the coordinates supplied to it...
Definition: UnitMap.h:44
T str(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
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
PolyMap is a Mapping which performs a general polynomial transformation.
Definition: PolyMap.h:49

◆ 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 }
T empty(T... args)
A UnitMap is a unit (null) Mapping that has no effect on the coordinates supplied to it...
Definition: UnitMap.h:44
T str(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
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
PolyMap is a Mapping which performs a general polynomial transformation.
Definition: PolyMap.h:49
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 172 of file wcsUtils.cc.

175  {
176  auto pl = std::make_shared<daf::base::PropertyList>();
177  pl->add("RADESYS", "ICRS");
178  pl->add("EQUINOX", 2000); // not needed, but may help some older code
179  pl->add("CTYPE1", "RA---" + projection);
180  pl->add("CTYPE2", "DEC--" + projection);
181  pl->add("CRPIX1", crpix[0] + 1);
182  pl->add("CRPIX2", crpix[1] + 1);
183  pl->add("CRVAL1", crval[0].asDegrees());
184  pl->add("CRVAL2", crval[1].asDegrees());
185  pl->add("CUNIT1", "deg");
186  pl->add("CUNIT2", "deg");
187  for (int i = 0; i < 2; ++i) {
188  for (int j = 0; j < 2; ++j) {
189  if (cdMatrix(i, j) != 0.0) {
190  std::string name = "CD" + std::to_string(i + 1) + "_" + std::to_string(j + 1);
191  pl->add(name, cdMatrix(i, j));
192  }
193  }
194  }
195  return pl;
196 }
table::PointKey< double > crpix
Definition: OldWcs.cc:131
T to_string(T... args)
table::PointKey< double > crval
Definition: OldWcs.cc:130
STL class.

◆ 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 }
T to_string(T... args)
STL class.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h: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 476 of file SkyWcs.cc.

476  {
477  return std::make_shared<SkyWcs>(metadata, strip);
478 }
bool strip
Definition: fits.cc:831

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

481  {
482  auto metadata = makeSimpleWcsMetadata(crpix, crval, cdMatrix, projection);
483  return std::make_shared<SkyWcs>(*metadata);
484 }
table::PointKey< double > crpix
Definition: OldWcs.cc:131
table::PointKey< double > crval
Definition: OldWcs.cc:130
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

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

488  {
489  auto frameDict = makeSkyWcsFrameDict(pixelsToFieldAngle, orientation, flipX, boresight, projection);
490  return std::make_shared<SkyWcs>(frameDict);
491 }

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

202  {
203  auto metadata = makeSimpleWcsMetadata(crpix, crval, cdMatrix, "TAN-SIP");
204  metadata->combine(makeSipMatrixMetadata(sipA, "A"));
205  metadata->combine(makeSipMatrixMetadata(sipB, "B"));
206  return metadata;
207 }
table::PointKey< double > crpix
Definition: OldWcs.cc:131
table::PointKey< double > crval
Definition: OldWcs.cc:130
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
std::shared_ptr< daf::base::PropertyList > makeSipMatrixMetadata(Eigen::MatrixXd const &matrix, std::string const &name)
Definition: wcsUtils.cc:150

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

212  {
213  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB);
214  metadata->combine(makeSipMatrixMetadata(sipAp, "AP"));
215  metadata->combine(makeSipMatrixMetadata(sipBp, "BP"));
216  return metadata;
217 }
table::PointKey< double > crpix
Definition: OldWcs.cc:131
table::PointKey< double > crval
Definition: OldWcs.cc:130
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:198
std::shared_ptr< daf::base::PropertyList > makeSipMatrixMetadata(Eigen::MatrixXd const &matrix, std::string const &name)
Definition: wcsUtils.cc:150

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

495  {
496  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB);
497  return std::make_shared<SkyWcs>(*metadata);
498 }
table::PointKey< double > crpix
Definition: OldWcs.cc:131
table::PointKey< double > crval
Definition: OldWcs.cc:130
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:198

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

503  {
504  auto metadata = makeTanSipMetadata(crpix, crval, cdMatrix, sipA, sipB, sipAp, sipBp);
505  return std::make_shared<SkyWcs>(*metadata);
506 }
table::PointKey< double > crpix
Definition: OldWcs.cc:131
table::PointKey< double > crval
Definition: OldWcs.cc:130
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:198

◆ 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
SeriesMap then(Mapping const &next) const
Return a series compound mapping this(first(input)) containing shallow copies of the original...
Definition: Mapping.cc:37
Point< double, 2 > Point2D
Definition: Point.h:324
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
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
Definition: ShiftMap.h:40

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

152  {
153  auto const dstInverse = dst.getTransform()->inverted();
154  return src.getTransform()->then(*dstInverse);
155 }
std::shared_ptr< RecordT > src
Definition: Match.cc:48

◆ operator<<() [1/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 };
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [2/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 }
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [3/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 }
std::ostream * os
Definition: Schema.cc:746

◆ 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 }
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [5/5]

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

Print a SkyWcs to an ostream.

For now it just prints "SkyWcs"; eventually it would be nice to have a summary

Definition at line 519 of file SkyWcs.cc.

519  {
520  os << "SkyWcs";
521  return os;
522 };
std::ostream * os
Definition: Schema.cc:746

◆ 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 }
Stencil
An enumeration class which describes the shapes.
Definition: SpanSet.h:66
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
An affine coordinate transformation consisting of a linear transformation and an offset.
def init()
Definition: tests.py:75
T endl(T... args)
int y
Definition: SpanSet.cc:49
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
STL class.
T push_back(T... args)
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:78
T str(T... args)
T make_pair(T... args)
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
solver_t * s
double x
STL class.
T begin(T... args)
ItemVariant const * other
Definition: Schema.cc:56
int end
A 2D linear coordinate transformation.
std::ostream * os
Definition: Schema.cc:746
T reserve(T... args)

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