File SipTransform.h

namespace lsst

Class for a simple mapping implementing a generic AstrometryTransform.

Remove all non-astronomical counts from the Chunk Exposure’s pixels.

Forward declarations for lsst::utils::Cache

For details on the Cache class, see the Cache.h file.

It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.

A base class for image defects

Numeric constants used by the Integrate.h integrator routines.

Compute Image Statistics

Note

Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.

Note

The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.

namespace meas
namespace astrom

Functions

std::shared_ptr<afw::geom::SkyWcs> makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, geom::SpherePoint const &skyOrigin)

Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.

Parameters
  • [in] sipForward: Mapping from pixel coordinates to intermediate world coordinates.

  • [in] sipReverse: Mapping from intermediate world coordinates to pixel coordinates.

  • [in] skyOrigin: ICRS position of the gnomonic projection that maps sky coordinates to intermediate world coordinates (CRVAL).

Exceptions
  • pex::exceptions::InvalidParameterError: if the forward and reverse SIP transforms have different CRPIX values or CD matrices.

std::shared_ptr<afw::geom::SkyWcs> transformWcsPixels(afw::geom::SkyWcs const &wcs, geom::AffineTransform const &s)

Create a new SkyWcs whose pixel coordinate system has been transformed via an affine transform.

Return

a new Wcs that satisfies the following:

newWcs = transformWcsPixels(wcs, s);
assert(newWcs.skyToPixel(sky), s(wcs.skyToPixel(sky)));
assert(newWcs.pixelToSky(pixel), wcs.pixelToSky(s.inverted()(pixel)));
for all sky coordinates sky and pixel coordinates pixel.

Parameters
  • [in] wcs: Original SkyWcs object.

  • [in] s: AffineTransform to apply to the pixel coordinate system.

std::shared_ptr<afw::geom::SkyWcs> rotateWcsPixelsBy90(afw::geom::SkyWcs const &wcs, int nQuarter, geom::Extent2I const &dimensions)

Return a new SkyWcs that represents a rotation of the image it corresponds to about the image’s center.

Parameters
  • [in] wcs: Original SkyWcs to be rotated.

  • [in] nQuarter: Number of 90 degree rotations (positive is counterclockwise).

  • [in] dimensions: Width and height of the image.

class SipForwardTransform : public lsst::meas::astrom::SipTransformBase
#include <SipTransform.h>

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

The SIP forward transform is defined as

\[\begin{split} \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] \end{split}\]
where
  • \((u,v)\) are pixel coordinates (zero-indexed).

  • \((x,y)\) are “intermediate world coordinates” the result of applying the gnomonic (TAN) projection at sky origin CRVAL to sky coordinates).

  • \(\mathbf{Z}\) is the \(2 \times 2\) linear transform ( \(\mathrm{CD}\)) matrix.

  • \((u_0,v_0)\) is the pixel origin \(\mathrm{CRPIX}\) (but zero-indexed; the FITS standard is 1-indexed).

  • \(\mathrm{A}\), \(\mathrm{B}\) are the polynomial coefficients of the forward transform.

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.

Public Functions

SipForwardTransform(geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix, PolynomialTransform const &forwardSipPoly)

Construct a SipForwardTransform from its components.

Parameters
  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed).

  • [in] cdMatrix: CD matrix \(Z\)

  • [in] forwardSipPoly: Polynomial transform \((A,B)\)

SipForwardTransform(SipForwardTransform const &other)
SipForwardTransform(SipForwardTransform &&other)
SipForwardTransform &operator=(SipForwardTransform const &other)
SipForwardTransform &operator=(SipForwardTransform &&other)
void swap(SipForwardTransform &other)
geom::AffineTransform linearize(geom::Point2D const &in) const

Return an approximate affine transform at the given point.

geom::Point2D operator()(geom::Point2D const &uv) const

Apply the transform to a point.

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.

Public Static Functions

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

Convert a PolynomialTransform to an equivalent SipForwardTransform.

Parameters
  • [in] poly: PolynomialTransform to convert.

  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed)

  • [in] cdMatrix: CD matrix \(Z\)

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

Convert a ScaledPolynomialTransform to an equivalent SipForwardTransform.

Parameters
  • [in] scaled: ScaledPolynomialTransform to convert.

  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed)

  • [in] cdMatrix: CD matrix \(Z\)

static SipForwardTransform convert(ScaledPolynomialTransform const &scaled)

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

class SipReverseTransform : public lsst::meas::astrom::SipTransformBase
#include <SipTransform.h>

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

The SIP reverse transform is defined as

\[\begin{split} \left[\begin{array}{ c } u \\ v \end{array}\right] = \left[\begin{array}{ c } u_0 + U + {\displaystyle\sum_{p,q}^{0 \le p + q \le N}} \mathrm{AP}_{p,q} U^p V^q \\ v_0 + V + {\displaystyle\sum_{p,q}^{0 \le p + q \le N}} \mathrm{BP}_{p,q} U^p V^q \\ \end{array}\right] \end{split}\]
with
\[\begin{split} \left[\begin{array}{ c } U \\ V \end{array}\right] = \mathbf{Z}^{-1} \left[\begin{array}{ c } x \\ y \end{array}\right] \end{split}\]
and
  • \((u,v)\) are pixel coordinates.

  • \((x,y)\) are “intermediate world coordinates” the result of applying the gnomonic (TAN) projection at sky origin CRVAL to sky coordinates).

  • \(\mathbf{Z}\) is the \(2 \times 2\) linear transform ( \(\mathrm{CD}\)) matrix.

  • \((u_0,v_0)\) is the pixel origin \(\mathrm{CRPIX}\) (but zero-indexed; the FITS standard is 1-indexed).

  • \(\mathrm{AP}\), \(\mathrm{BP}\) are the polynomial coefficients of the reverse transform.

SipForwardTransform instances should be confined to a single thread.

Public Functions

SipReverseTransform(geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix, PolynomialTransform const &reverseSipPoly)

Construct a SipReverseTransform from its components.

Parameters
  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed)

  • [in] cdMatrix: CD matrix \(Z\)

  • [in] reverseSipPoly: Polynomial transform \((AP,BP)\)

SipReverseTransform(SipReverseTransform const &other)
SipReverseTransform(SipReverseTransform &&other)
SipReverseTransform &operator=(SipReverseTransform const &other)
SipReverseTransform &operator=(SipReverseTransform &&other)
void swap(SipReverseTransform &other)
geom::AffineTransform linearize(geom::Point2D const &in) const

Return an approximate affine transform at the given point.

geom::Point2D operator()(geom::Point2D const &xy) const

Apply the transform to a point.

SipReverseTransform transformPixels(geom::AffineTransform const &s) const

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

Public Static Functions

static SipReverseTransform convert(PolynomialTransform const &poly, geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix)

Convert a PolynomialTransform to an equivalent SipReverseTransform.

Parameters
  • [in] poly: PolynomialTransform to convert.

  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed)

  • [in] cdMatrix: CD matrix \(Z\)

static SipReverseTransform convert(ScaledPolynomialTransform const &scaled, geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix)

Convert a ScaledPolynomialTransform to an equivalent SipReverseTransform.

Parameters
  • [in] scaled: ScaledPolynomialTransform to convert.

  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed)

  • [in] cdMatrix: CD matrix \(Z\)

static SipReverseTransform convert(ScaledPolynomialTransform const &scaled)

Convert a ScaledPolynomialTransform to an equivalent SipReverseTransform.

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

Private Members

geom::LinearTransform _cdInverse

Friends

friend lsst::meas::astrom::PolynomialTransform
friend lsst::meas::astrom::ScaledPolynomialTransform
class SipTransformBase
#include <SipTransform.h>

Base class for SIP transform objects.

This class simply provides some getters for its derived classes. It should not be used directly, and does not define a polymorphic interface.

Subclassed by lsst::meas::astrom::SipForwardTransform, lsst::meas::astrom::SipReverseTransform

Public Functions

geom::Point2D const &getPixelOrigin() const

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

geom::LinearTransform const &getCdMatrix() const

Return the CD matrix of the transform.

PolynomialTransform const &getPoly() const

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

Protected Functions

SipTransformBase(geom::Point2D const &pixelOrigin, geom::LinearTransform const &cdMatrix, PolynomialTransform const &poly)

Construct a SipTransformBase from its components.

See SipForwardTransform and SipReverseTransform for more extensive definitions.

Parameters
  • [in] pixelOrigin: CRPIX \((u_0,v_0)\) (zero-indexed)

  • [in] cdMatrix: CD matrix \(Z\)

  • [in] poly: Either the forward or reverse SIP polynomial (depending on the derived class).

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

Protected Attributes

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