LSSTApplications  21.0.0+1b62c9342b,21.0.0+45a059f35e,21.0.0-1-ga51b5d4+ceb9cf20a3,21.0.0-10-g68cce58c5+c7d3cce47e,21.0.0-2-g103fe59+c1ca725317,21.0.0-2-g1367e85+a1c2f7fe71,21.0.0-2-g2909d54+45a059f35e,21.0.0-2-g45278ab+1b62c9342b,21.0.0-2-g4bc9b9f+b2e40a4e47,21.0.0-2-g5242d73+a1c2f7fe71,21.0.0-2-g54e2caa+c00cf99ed0,21.0.0-2-g66bcc37+27b9d7859a,21.0.0-2-g7f82c8f+203cf74700,21.0.0-2-g8dde007+b0df52bfdd,21.0.0-2-g8f08a60+73884b2cf5,21.0.0-2-ga326454+203cf74700,21.0.0-2-ga63a54e+eec04437aa,21.0.0-2-gc738bc1+59028256f4,21.0.0-2-gde069b7+5a8f2956b8,21.0.0-2-ge17e5af+a1c2f7fe71,21.0.0-2-ge712728+9ad031c87e,21.0.0-2-gecfae73+d3766aec80,21.0.0-2-gfc62afb+a1c2f7fe71,21.0.0-20-g4449a12+38dfb87bce,21.0.0-22-gf0532904+afb8e7912b,21.0.0-3-g4c5b185+a403cb96fd,21.0.0-3-g6d51c4a+27b9d7859a,21.0.0-3-g8076721+e873df194c,21.0.0-3-gaa929c8+df5d87f43a,21.0.0-3-gd222c45+afc8332dbe,21.0.0-4-g1383c07+27b9d7859a,21.0.0-4-g3300ddd+1b62c9342b,21.0.0-4-g5873dc9+9a92674037,21.0.0-4-g8a80011+f67daf2f53,21.0.0-5-gcff38f6+bce43c5818,21.0.0-6-g463d161+44134145d4,21.0.0-6-gd3283ba+df5d87f43a,21.0.0-8-g19111d86+d6551531e4,w.2021.04
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::meas::astrom::SipForwardTransform Class Reference

A transform that maps pixel coordinates to intermediate world coordinates according to the SIP convention. More...

#include <SipTransform.h>

Inheritance diagram for lsst::meas::astrom::SipForwardTransform:
lsst::meas::astrom::SipTransformBase

Public Member Functions

 SipForwardTransform (geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix, PolynomialTransform const &forwardSipPoly)
 Construct a SipForwardTransform from its components. More...
 
 SipForwardTransform (SipForwardTransform const &other)=default
 
 SipForwardTransform (SipForwardTransform &&other)=default
 
SipForwardTransformoperator= (SipForwardTransform const &other)=default
 
SipForwardTransformoperator= (SipForwardTransform &&other)=default
 
void swap (SipForwardTransform &other)
 
geom::AffineTransform linearize (geom::Point2D const &in) const
 Return an approximate affine transform at the given point. More...
 
geom::Point2D operator() (geom::Point2D const &uv) const
 Apply the transform to a point. More...
 
SipForwardTransform transformPixels (geom::AffineTransform const &s) const
 Return a new forward SIP transform that includes a transformation of the pixel coordinate system by the given affine transform. More...
 
geom::Point2D const & getPixelOrigin () const
 Return the pixel origin (CRPIX, but zero-indexed) of the transform. More...
 
geom::LinearTransform const & getCdMatrix () const
 Return the CD matrix of the transform. More...
 
PolynomialTransform const & getPoly () const
 Return the polynomial component of the transform (A,B) or (AP,BP). More...
 

Static Public Member Functions

static SipForwardTransform convert (PolynomialTransform const &poly, geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix)
 Convert a PolynomialTransform to an equivalent SipForwardTransform. More...
 
static SipForwardTransform convert (ScaledPolynomialTransform const &scaled, geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix)
 Convert a ScaledPolynomialTransform to an equivalent SipForwardTransform. More...
 
static SipForwardTransform convert (ScaledPolynomialTransform const &scaled)
 Convert a ScaledPolynomialTransform to an equivalent SipForwardTransform. More...
 

Protected Member Functions

void swap (SipTransformBase &other)
 
void transformPixelsInPlace (geom::AffineTransform const &s)
 

Protected Attributes

geom::Point2D _pixelOrigin
 
geom::LinearTransform _cdMatrix
 
PolynomialTransform _poly
 

Detailed Description

A transform that maps pixel coordinates to intermediate world coordinates according to the SIP convention.

The SIP forward transform is defined as

\[ \left[\begin{array}{ c } x \\ y \end{array}\right] = \mathbf{Z} \left[\begin{array}{ c } (u - u_0) + {\displaystyle\sum_{p,q}^{2 \le p + q \le N}} \mathrm{A}_{p,q} (u-u_0)^p (v-v_0)^q \\ (v - v_0) + {\displaystyle\sum_{p,q}^{2 \le p + q \le N}} \mathrm{B}_{p,q} (u-u_0)^p (v-v_0)^q \end{array}\right] \]

where

The SIP convention encourages (but does not require) nulling the zeroth- and first-order elements of \(\mathrm{A}\) and \(\mathrm{B}\), which ensures the representation of a given transform is unique. This also makes fitting a SIP transform to data a nonlinear operation, as well as making the conversion from standard polynomial transforms to SIP form impossible in general. Accordingly, this class does not attempt to null low-order polynomial terms at all when converting from other transforms.

SipForwardTransform instances should be confined to a single thread.

Definition at line 136 of file SipTransform.h.

Constructor & Destructor Documentation

◆ SipForwardTransform() [1/3]

lsst::meas::astrom::SipForwardTransform::SipForwardTransform ( geom::Point2D const &  pixelOrigin,
geom::LinearTransform const &  cdMatrix,
PolynomialTransform const &  forwardSipPoly 
)
inline

Construct a SipForwardTransform from its components.

Parameters
[in]pixelOriginCRPIX \((u_0,v_0)\) (zero-indexed).
[in]cdMatrixCD matrix \(Z\)
[in]forwardSipPolyPolynomial transform \((A,B)\)

Definition at line 175 of file SipTransform.h.

177  : SipTransformBase(pixelOrigin, cdMatrix, forwardSipPoly) {}

◆ SipForwardTransform() [2/3]

lsst::meas::astrom::SipForwardTransform::SipForwardTransform ( SipForwardTransform const &  other)
default

◆ SipForwardTransform() [3/3]

lsst::meas::astrom::SipForwardTransform::SipForwardTransform ( SipForwardTransform &&  other)
default

Member Function Documentation

◆ convert() [1/3]

SipForwardTransform lsst::meas::astrom::SipForwardTransform::convert ( PolynomialTransform const &  poly,
geom::Point2D const &  pixelOrigin,
geom::LinearTransform const &  cdMatrix 
)
static

Convert a PolynomialTransform to an equivalent SipForwardTransform.

Parameters
[in]polyPolynomialTransform to convert.
[in]pixelOriginCRPIX \((u_0,v_0)\) (zero-indexed)
[in]cdMatrixCD matrix \(Z\)

Definition at line 52 of file SipTransform.cc.

54  {
55  auto forwardSipPoly = compose(geom::AffineTransform(cdMatrix.inverted()),
57  // Subtracting 1 here accounts for the extra terms outside the sum in the
58  // transform definition (see class docs) - note that you can fold those
59  // terms into the sum by adding 1 from the A_10 and B_01 terms.
60  forwardSipPoly._xCoeffs(1, 0) -= 1;
61  forwardSipPoly._yCoeffs(0, 1) -= 1;
62  return SipForwardTransform(pixelOrigin, cdMatrix, forwardSipPoly);
63 }

◆ convert() [2/3]

SipForwardTransform lsst::meas::astrom::SipForwardTransform::convert ( ScaledPolynomialTransform const &  scaled)
static

Convert a ScaledPolynomialTransform to an equivalent SipForwardTransform.

The pixel origin CRPIX and CD matrix are defined to reproduce the translation and linear transformation in the ScaledPolynomialTransform's input and output scalings (respectively).

Definition at line 79 of file SipTransform.cc.

79  {
80  geom::Point2D pixelOrigin(-scaled.getOutputScalingInverse().getTranslation());
81  geom::LinearTransform cdMatrix(scaled.getInputScaling().getLinear().inverted());
82  return convert(scaled, pixelOrigin, cdMatrix);
83 }

◆ convert() [3/3]

SipForwardTransform lsst::meas::astrom::SipForwardTransform::convert ( ScaledPolynomialTransform const &  scaled,
geom::Point2D const &  pixelOrigin,
geom::LinearTransform const &  cdMatrix 
)
static

Convert a ScaledPolynomialTransform to an equivalent SipForwardTransform.

Parameters
[in]scaledScaledPolynomialTransform to convert.
[in]pixelOriginCRPIX \((u_0,v_0)\) (zero-indexed)
[in]cdMatrixCD matrix \(Z\)

Definition at line 65 of file SipTransform.cc.

67  {
68  auto forwardSipPoly =
69  compose(geom::AffineTransform(cdMatrix.inverted()) * scaled.getOutputScalingInverse(),
70  compose(scaled.getPoly(),
71  scaled.getInputScaling() * geom::AffineTransform(geom::Extent2D(pixelOrigin))));
72  // Account for the terms outside the sum in the definition (see comment
73  // earlier in the file for more explanation).
74  forwardSipPoly._xCoeffs(1, 0) -= 1;
75  forwardSipPoly._yCoeffs(0, 1) -= 1;
76  return SipForwardTransform(pixelOrigin, cdMatrix, forwardSipPoly);
77 }

◆ getCdMatrix()

geom::LinearTransform const& lsst::meas::astrom::SipTransformBase::getCdMatrix ( ) const
inlineinherited

Return the CD matrix of the transform.

Definition at line 56 of file SipTransform.h.

56 { return _cdMatrix; }

◆ getPixelOrigin()

geom::Point2D const& lsst::meas::astrom::SipTransformBase::getPixelOrigin ( ) const
inlineinherited

Return the pixel origin (CRPIX, but zero-indexed) of the transform.

Definition at line 51 of file SipTransform.h.

51 { return _pixelOrigin; }

◆ getPoly()

PolynomialTransform const& lsst::meas::astrom::SipTransformBase::getPoly ( ) const
inlineinherited

Return the polynomial component of the transform (A,B) or (AP,BP).

Definition at line 61 of file SipTransform.h.

61 { return _poly; }

◆ linearize()

geom::AffineTransform lsst::meas::astrom::SipForwardTransform::linearize ( geom::Point2D const &  in) const

Return an approximate affine transform at the given point.

Definition at line 85 of file SipTransform.cc.

85  {
87  return geom::AffineTransform(_cdMatrix) * (geom::AffineTransform() + _poly.linearize(tail(in))) * tail;
88 }

◆ operator()()

geom::Point2D lsst::meas::astrom::SipForwardTransform::operator() ( geom::Point2D const &  uv) const

Apply the transform to a point.

Definition at line 90 of file SipTransform.cc.

90  {
92  return getCdMatrix()(geom::Extent2D(duv) + getPoly()(duv));
93 }

◆ operator=() [1/2]

SipForwardTransform& lsst::meas::astrom::SipForwardTransform::operator= ( SipForwardTransform &&  other)
default

◆ operator=() [2/2]

SipForwardTransform& lsst::meas::astrom::SipForwardTransform::operator= ( SipForwardTransform const &  other)
default

◆ swap() [1/2]

void lsst::meas::astrom::SipForwardTransform::swap ( SipForwardTransform other)
inline

Definition at line 187 of file SipTransform.h.

◆ swap() [2/2]

void lsst::meas::astrom::SipTransformBase::swap ( SipTransformBase other)
inlineprotectedinherited

Definition at line 85 of file SipTransform.h.

85  {
86  std::swap(_pixelOrigin, other._pixelOrigin);
87  std::swap(_cdMatrix, other._cdMatrix);
88  _poly.swap(other._poly);
89  }

◆ transformPixels()

SipForwardTransform lsst::meas::astrom::SipForwardTransform::transformPixels ( geom::AffineTransform const &  s) const

Return a new forward SIP transform that includes a transformation of the pixel coordinate system by the given affine transform.

Definition at line 95 of file SipTransform.cc.

95  {
97  result.transformPixelsInPlace(s);
98  return result;
99 }

◆ transformPixelsInPlace()

void lsst::meas::astrom::SipTransformBase::transformPixelsInPlace ( geom::AffineTransform const &  s)
protectedinherited

Definition at line 40 of file SipTransform.cc.

40  {
41  // The implementation for transformPixels is identical for
42  // SipForwardTransform and SipReverseTransform. That's pretty obvious for
43  // the pixel origin and CD matrix, which are the same in both cases, but
44  // it wasn't obvious to me until I did the math that the polynomial
45  // transforms are composed with the affine transform the same way.
46  auto sInv = s.inverted();
47  _pixelOrigin = s.getLinear()(_pixelOrigin - sInv.getTranslation());
48  _cdMatrix = _cdMatrix * sInv.getLinear();
49  _poly = compose(s.getLinear(), compose(getPoly(), sInv.getLinear()));
50 }

Member Data Documentation

◆ _cdMatrix

geom::LinearTransform lsst::meas::astrom::SipTransformBase::_cdMatrix
protectedinherited

Definition at line 94 of file SipTransform.h.

◆ _pixelOrigin

geom::Point2D lsst::meas::astrom::SipTransformBase::_pixelOrigin
protectedinherited

Definition at line 93 of file SipTransform.h.

◆ _poly

PolynomialTransform lsst::meas::astrom::SipTransformBase::_poly
protectedinherited

Definition at line 95 of file SipTransform.h.


The documentation for this class was generated from the following files:
lsst::geom::LinearTransform
A 2D linear coordinate transformation.
Definition: LinearTransform.h:69
lsst::meas::astrom::SipTransformBase::getPoly
PolynomialTransform const & getPoly() const
Return the polynomial component of the transform (A,B) or (AP,BP).
Definition: SipTransform.h:61
lsst::meas::astrom::SipForwardTransform::SipForwardTransform
SipForwardTransform(geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix, PolynomialTransform const &forwardSipPoly)
Construct a SipForwardTransform from its components.
Definition: SipTransform.h:175
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
lsst::meas::astrom::SipTransformBase::_pixelOrigin
geom::Point2D _pixelOrigin
Definition: SipTransform.h:93
lsst::meas::astrom::SipTransformBase::_poly
PolynomialTransform _poly
Definition: SipTransform.h:95
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::meas::astrom::PolynomialTransform::linearize
geom::AffineTransform linearize(geom::Point2D const &in) const
Return an approximate affine transform at the given point.
Definition: PolynomialTransform.cc:129
result
py::object result
Definition: _schema.cc:429
lsst::meas::astrom::SipTransformBase::getPixelOrigin
geom::Point2D const & getPixelOrigin() const
Return the pixel origin (CRPIX, but zero-indexed) of the transform.
Definition: SipTransform.h:51
std::swap
T swap(T... args)
lsst::meas::astrom::SipTransformBase::swap
void swap(SipTransformBase &other)
Definition: SipTransform.h:85
lsst::meas::astrom::SipTransformBase::getCdMatrix
geom::LinearTransform const & getCdMatrix() const
Return the CD matrix of the transform.
Definition: SipTransform.h:56
lsst::geom::polynomials
Low-level polynomials (including special polynomials) in C++.
Definition: Basis1d.h:26
lsst::geom::Point< double, 2 >
lsst::meas::astrom::SipForwardTransform::convert
static SipForwardTransform convert(PolynomialTransform const &poly, geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix)
Convert a PolynomialTransform to an equivalent SipForwardTransform.
Definition: SipTransform.cc:52
lsst::meas::astrom::SipTransformBase::SipTransformBase
SipTransformBase(geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix, PolynomialTransform const &poly)
Construct a SipTransformBase from its components.
Definition: SipTransform.h:76
lsst::geom::Extent2D
Extent< double, 2 > Extent2D
Definition: Extent.h:400
lsst::meas::astrom::SipTransformBase::_cdMatrix
geom::LinearTransform _cdMatrix
Definition: SipTransform.h:94
lsst::geom::Extent< double, 2 >
lsst::meas::astrom::PolynomialTransform::swap
void swap(PolynomialTransform &other)
Lightweight swap.
Definition: PolynomialTransform.cc:122
lsst::meas::astrom::compose
PolynomialTransform compose(geom::AffineTransform const &t1, PolynomialTransform const &t2)
Return a PolynomialTransform that is equivalent to the composition t1(t2())
Definition: PolynomialTransform.cc:214