LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
A fitter and results class for approximating a general Transform in a form compatible with FITS WCS persistence. More...
#include <SipApproximation.h>
Classes | |
struct | Grid |
struct | Solution |
Public Member Functions | |
SipApproximation (std::shared_ptr< TransformPoint2ToPoint2 > pixelToIwc, lsst::geom::Point2D const &crpix, Eigen::Matrix2d const &cd, lsst::geom::Box2D const &bbox, lsst::geom::Extent2I const &gridShape, int order, bool useInverse=true, double svdThreshold=-1) | |
Construct a new approximation by fitting on a grid of points. More... | |
SipApproximation (std::shared_ptr< TransformPoint2ToPoint2 > pixelToIwc, lsst::geom::Point2D const &crpix, Eigen::Matrix2d const &cd, lsst::geom::Box2D const &bbox, lsst::geom::Extent2I const &gridShape, ndarray::Array< double const, 2 > const &a, ndarray::Array< double const, 2 > const &b, ndarray::Array< double const, 2 > const &ap, ndarray::Array< double const, 2 > const &bp, bool useInverse=true) | |
Construct from existing SIP coefficients. More... | |
SipApproximation (SipApproximation const &)=delete | |
SipApproximation & | operator= (SipApproximation const &)=delete |
SipApproximation (SipApproximation &&) noexcept=default | |
SipApproximation & | operator= (SipApproximation &&) noexcept=default |
~SipApproximation () noexcept | |
int | getOrder () const noexcept |
Return the polynomial order of the current solution (same for forward and reverse). More... | |
double | getA (int p, int q) const |
Return a coefficient of the forward transform polynomial. More... | |
double | getB (int p, int q) const |
Return a coefficient of the forward transform polynomial. More... | |
double | getAP (int p, int q) const |
Return a coefficient of the reverse transform polynomial. More... | |
double | getBP (int p, int q) const |
Return a coefficient of the reverse transform polynomial. More... | |
Eigen::MatrixXd | getA () const noexcept |
Return the coefficients of the forward transform polynomial. More... | |
Eigen::MatrixXd | getB () const noexcept |
Return the coefficients of the forward transform polynomial. More... | |
Eigen::MatrixXd | getAP () const noexcept |
Return the coefficients of the reverse transform polynomial. More... | |
Eigen::MatrixXd | getBP () const noexcept |
Return the coefficients of the reverse transform polynomial. More... | |
lsst::geom::Point2D | applyForward (lsst::geom::Point2D const &pix) const |
Convert a point from pixels to intermediate world coordinates. More... | |
std::vector< lsst::geom::Point2D > | applyForward (std::vector< lsst::geom::Point2D > const &pix) const |
Convert an array of points from pixels to intermediate world coordinates. More... | |
lsst::geom::Point2D | applyInverse (lsst::geom::Point2D const &iwcs) const |
Convert a point from intermediate world coordinates to pixels. More... | |
std::vector< lsst::geom::Point2D > | applyInverse (std::vector< lsst::geom::Point2D > const &iwcs) const |
Convert an array of points from intermediate world coordinates to pixels. More... | |
lsst::geom::Extent2D | getGridStep () const noexcept |
Return the distance between grid points in pixels. More... | |
lsst::geom::Extent2I | getGridShape () const noexcept |
Return the number of grid points in x and y. More... | |
lsst::geom::Box2D | getBBox () const noexcept |
Return the pixel-coordinate bounding box over which the approximation should be valid. More... | |
lsst::geom::Point2D | getPixelOrigin () const noexcept |
Return the pixel origin of the WCS being approximated. More... | |
Eigen::Matrix2d | getCdMatrix () const noexcept |
Return the CD matrix of the WCS being approximated. More... | |
void | updateGrid (lsst::geom::Extent2I const &shape) |
Update the grid to the given number of points in x and y. More... | |
void | refineGrid (int factor=2) |
Update the grid by making it finer by a given integer factor. More... | |
void | fit (int order, double svdThreshold=-1) |
Obtain a new solution at the given order with the current grid. More... | |
std::pair< double, double > | computeMaxDeviation () const noexcept |
Return the maximum deviation of the solution from the exact transform on the current grid. More... | |
A fitter and results class for approximating a general Transform in a form compatible with FITS WCS persistence.
The Simple Imaging Polynomial (SIP) convention (Shupe et al 2005) adds forward and reverse polynomial mappings to a standard projection FITS WCS projection (e.g. "TAN" for gnomonic) that relate Intermediate World Coordinates (see Calabretta & Greisen 2002) to image pixel coordinates. The SIP "forward" transform is defined by polynomial coeffients \(A\) and \(B\) that map pixel coordinates \((u, v)\) to Intermediate World Coordinates \((x, y)\) via
\[ \boldsymbol{S}\left[\begin{array}{c} x \\ y \end{array}\right] \equiv \left[\begin{array}{c} x_s \\ y_s \end{array}\right] = \left[\begin{array}{c} (u - u_0) + \displaystyle\sum_{p,q}^{0 \le p + q \le N} \mathrm{A}_{p,q} (u - u_0)^p (v - v_0)^q \\ (v - v_0) + \displaystyle\sum_{p,q}^{0 \le p + q \le N} \mathrm{B}_{p,q} (u - u_0)^p (v - v_0)^q \end{array}\right] \]
The reverse transform has essentially the same form:
\[ \left[\begin{array}{c} u - u_0 \\ v - v_0 \end{array}\right] = \left[\begin{array}{c} x_s + \displaystyle\sum_{p,q}^{0 \le p + q \le N} \mathrm{AP}_{p,q} x_s^p y_s^q \\ y_s + \displaystyle\sum_{p,q}^{0 \le p + q \le N} \mathrm{BP}_{p,q} x_s^p y_s^q \end{array}\right] \]
In both cases, \((u_0, v_0)\) is the pixel origin (CRPIX in FITS WCS) and \(\boldsymbol{S}\) is the inverse of the Jacobian "CD" matrix. Both CRPIX and CD are considered fixed inputs, and we do not attempt to null the zeroth- and first-order terms of \(A\) and \(B\) (as some SIP fitters do); together, these conventions make solving for the coefficients a much simpler linear problem.
dpix
(for "pixel delta"), and \((x_s, y_s)\) as siwc
(for "scaled
intermediate world coordinates").While LSST WCSs are in general too complex to be described exactly in FITS WCS, they can generally be closely approximated by standard FITS WCS projection with additional SIP distortions. This class fits such an approximation, given a TransformPoint2ToPoint2 object that represents the exact mapping from pixels to Intermediate World Coordinates with a SIP distortion.
Definition at line 94 of file SipApproximation.h.
lsst::afw::geom::SipApproximation::SipApproximation | ( | std::shared_ptr< TransformPoint2ToPoint2 > | pixelToIwc, |
lsst::geom::Point2D const & | crpix, | ||
Eigen::Matrix2d const & | cd, | ||
lsst::geom::Box2D const & | bbox, | ||
lsst::geom::Extent2I const & | gridShape, | ||
int | order, | ||
bool | useInverse = true , |
||
double | svdThreshold = -1 |
||
) |
Construct a new approximation by fitting on a grid of points.
[in] | pixelToIwc | The true Transform to approximate. Should go from pixels to Intermediate World Coordinates when applyForward is called. |
[in] | crpix | Pixel origin, using the LSST 0-indexed convention rather than the FITS 1-indexed convention; equal to (CRPIX1 - 1, CRPIX2 - 1). |
[in] | cd | Nominal Jacobian ("CD" in FITS WCS). |
[in] | bbox | Pixel-coordinate bounding box over which the approximation should be valid. Used to construct the grid of points to fit. |
[in] | gridShape | Number of points in x and y for the grid of points. |
[in] | order | Order of the polynomial (same for forward and reverse transforms). |
[in] | useInverse | If true, the inverse SIP transform will be fit and compared to data points generated by calls to pixelToIwc.applyInverse instead of pixelToIwc.applyForward. |
[in] | svdThreshold | Fraction of the largest singular value at which to declare smaller singular values zero in the least squares solution. Negative values use Eigen's internal default. |
lsst::pex::exceptions::InvalidParameterError | Thrown if order is negative or gridShape is non-positive. |
Definition at line 209 of file SipApproximation.cc.
lsst::afw::geom::SipApproximation::SipApproximation | ( | std::shared_ptr< TransformPoint2ToPoint2 > | pixelToIwc, |
lsst::geom::Point2D const & | crpix, | ||
Eigen::Matrix2d const & | cd, | ||
lsst::geom::Box2D const & | bbox, | ||
lsst::geom::Extent2I const & | gridShape, | ||
ndarray::Array< double const, 2 > const & | a, | ||
ndarray::Array< double const, 2 > const & | b, | ||
ndarray::Array< double const, 2 > const & | ap, | ||
ndarray::Array< double const, 2 > const & | bp, | ||
bool | useInverse = true |
||
) |
Construct from existing SIP coefficients.
This constructor is primarily intended for testing purposes.
[in] | pixelToIwc | The true Transform to approximate. Should go from pixels to Intermediate World Coordinates when applyForward is called. |
[in] | crpix | Pixel origin, using the LSST 0-indexed convention rather than the FITS 1-indexed convention; equal to (CRPIX1 - 1, CRPIX - 1). |
[in] | cd | Nominal Jacobian ("CD" in FITS WCS). |
[in] | bbox | Pixel-coordinate bounding box over which the approximation should be valid. Used to construct the grid of points to fit. |
[in] | gridShape | Number of points in x and y for the grid of points. |
[in] | a | Matrix of A coefficients, with the first dimension corresponding to powers of \((u - u_0)\) and the second corresponding to powers of \((v - v_0)\). |
[in] | b | Matrix of B coefficients, with the first dimension corresponding to powers of \((u - u_0)\) and the second corresponding to powers of \((v - v_0)\). |
[in] | ap | Matrix of AP coefficients, with the first dimension corresponding to powers of \(x_s\) and the second corresponding to powers of \(y_s\). |
[in] | bp | Matrix of BP coefficients, with the first dimension corresponding to powers of \(x_s\) and the second corresponding to powers of \(y_s\). |
[in] | useInverse | If true, the inverse SIP transform will be compared to data points generated by calls to pixelToIwc.applyInverse instead of pixelToIwc.applyForward. |
lsst::pex::exceptions::InvalidParameterError | Thrown if gridShape is non-positive, or any matrix argument is non-square. |
Definition at line 228 of file SipApproximation.cc.
|
delete |
|
defaultnoexcept |
|
defaultnoexcept |
lsst::geom::Point2D lsst::afw::geom::SipApproximation::applyForward | ( | lsst::geom::Point2D const & | pix | ) | const |
Convert a point from pixels to intermediate world coordinates.
This method is inefficient and should only be used for diagnostic purposes.
Definition at line 321 of file SipApproximation.cc.
std::vector< lsst::geom::Point2D > lsst::afw::geom::SipApproximation::applyForward | ( | std::vector< lsst::geom::Point2D > const & | pix | ) | const |
Convert an array of points from pixels to intermediate world coordinates.
Definition at line 327 of file SipApproximation.cc.
lsst::geom::Point2D lsst::afw::geom::SipApproximation::applyInverse | ( | lsst::geom::Point2D const & | iwcs | ) | const |
Convert a point from intermediate world coordinates to pixels.
This method is inefficient and should only be used for diagnostic purposes.
Definition at line 339 of file SipApproximation.cc.
std::vector< lsst::geom::Point2D > lsst::afw::geom::SipApproximation::applyInverse | ( | std::vector< lsst::geom::Point2D > const & | iwcs | ) | const |
Convert an array of points from intermediate world coordinates to pixels.
Definition at line 344 of file SipApproximation.cc.
|
noexcept |
Return the maximum deviation of the solution from the exact transform on the current grid.
The deviations are in scaled intermediate world coordinates \(\sqrt{\delta x_s^2 \delta y_s^2}\) for the forward transform and in pixels \((\delta u^2, \delta v^2)\) for the reverse transform (respectively). Note that in the common case where the CD matrix includes the scaling from angle units to pixel units, the scaled intermediate world coordinate values are also in (nominal) pixel units.
Definition at line 380 of file SipApproximation.cc.
void lsst::afw::geom::SipApproximation::fit | ( | int | order, |
double | svdThreshold = -1 |
||
) |
Obtain a new solution at the given order with the current grid.
[in] | order | Polynomial order to fit. |
[in] | svdThreshold | Fraction of the largest singular value at which to declare smaller singular values zero in the least squares solution. Negative values use Eigen's internal default. |
pex::exceptions::LogicError | Thrown if the number of free parameters implied by order is larger than the number of data points defined by the grid. |
Definition at line 376 of file SipApproximation.cc.
|
noexcept |
Return the coefficients of the forward transform polynomial.
Definition at line 293 of file SipApproximation.cc.
double lsst::afw::geom::SipApproximation::getA | ( | int | p, |
int | q | ||
) | const |
Return a coefficient of the forward transform polynomial.
Out-of-bounds arguments yields undefined behavior.
Definition at line 262 of file SipApproximation.cc.
|
noexcept |
Return the coefficients of the reverse transform polynomial.
Definition at line 307 of file SipApproximation.cc.
double lsst::afw::geom::SipApproximation::getAP | ( | int | p, |
int | q | ||
) | const |
Return a coefficient of the reverse transform polynomial.
Out-of-bounds arguments yields undefined behavior.
Definition at line 270 of file SipApproximation.cc.
|
noexcept |
Return the coefficients of the forward transform polynomial.
Definition at line 300 of file SipApproximation.cc.
double lsst::afw::geom::SipApproximation::getB | ( | int | p, |
int | q | ||
) | const |
Return a coefficient of the forward transform polynomial.
Out-of-bounds arguments yields undefined behavior.
Definition at line 266 of file SipApproximation.cc.
|
inlinenoexcept |
Return the pixel-coordinate bounding box over which the approximation should be valid.
Definition at line 291 of file SipApproximation.h.
|
noexcept |
Return the coefficients of the reverse transform polynomial.
Definition at line 314 of file SipApproximation.cc.
double lsst::afw::geom::SipApproximation::getBP | ( | int | p, |
int | q | ||
) | const |
Return a coefficient of the reverse transform polynomial.
Out-of-bounds arguments yields undefined behavior.
Definition at line 274 of file SipApproximation.cc.
|
inlinenoexcept |
Return the CD matrix of the WCS being approximated.
Definition at line 297 of file SipApproximation.h.
|
noexcept |
Return the number of grid points in x and y.
Definition at line 360 of file SipApproximation.cc.
|
noexcept |
Return the distance between grid points in pixels.
Definition at line 355 of file SipApproximation.cc.
|
noexcept |
Return the polynomial order of the current solution (same for forward and reverse).
Definition at line 258 of file SipApproximation.cc.
|
inlinenoexcept |
Return the pixel origin of the WCS being approximated.
Definition at line 294 of file SipApproximation.h.
|
defaultnoexcept |
|
delete |
void lsst::afw::geom::SipApproximation::refineGrid | ( | int | factor = 2 | ) |
Update the grid by making it finer by a given integer factor.
lsst::pex::exceptions::InvalidParameterError | Thrown if factor is non-positive. |
Definition at line 368 of file SipApproximation.cc.
void lsst::afw::geom::SipApproximation::updateGrid | ( | lsst::geom::Extent2I const & | shape | ) |
Update the grid to the given number of points in x and y.
This does not invalidate or modify the current solution; this allows the user to fit with a coarse grid and then check whether the solution still works well on a finer grid.
lsst::pex::exceptions::InvalidParameterError | Thrown if shape is non-positive. |
Definition at line 364 of file SipApproximation.cc.