Namespace lsst::meas::astrom

namespace astrom

Typedefs

typedef std::vector<RecordProxy> ProxyVector

Functions

template<typename MatchT>
afw::math::Statistics makeMatchStatistics(std::vector<MatchT> const &matchList, int const flags, afw::math::StatisticsControl const &sctrl = afw::math::StatisticsControl())

Compute statistics of the distance field of a match list

Parameters
  • [in] matchList: list of matchList between reference objects and sources; fields read:

    • distance: distance between source and reference object, in arbitrary units; the resulting statistics have the same units as distance

  • [in] flags: what to calculate; OR constants such as lsst::afw::math::MEAN, MEANCLIP, STDDEV, MEDIAN, defined in lsst/afw/math/Statitics.h’s Property enum

  • [in] sctrl: statistics configuration

template<typename MatchT>
afw::math::Statistics makeMatchStatisticsInPixels(afw::geom::SkyWcs const &wcs, std::vector<MatchT> const &matchList, int const flags, afw::math::StatisticsControl const &sctrl = afw::math::StatisticsControl())

Compute statistics of on-detector radial separation for a match list, in pixels

Parameters
  • [in] wcs: WCS describing pixel to sky transformation

  • [in] matchList: list of matchList between reference objects and sources; fields read:

    • first: reference object; only the coord is read

    • second: source; only the centroid is read

  • [in] flags: what to calculate; OR constants such as lsst::afw::math::MEAN, MEANCLIP, STDDEV, MEDIAN, defined in lsst/afw/math/Statitics.h’s Property enum

  • [in] sctrl: statistics configuration

template<typename MatchT>
afw::math::Statistics makeMatchStatisticsInRadians(afw::geom::SkyWcs const &wcs, std::vector<MatchT> const &matchList, int const flags, afw::math::StatisticsControl const &sctrl = afw::math::StatisticsControl())

Compute statistics of on-sky radial separation for a match list, in radians

Parameters
  • [in] wcs: WCS describing pixel to sky transformation

  • [in] matchList: list of matchList between reference objects and sources; fields read:

    • first: reference object; only the coord is read

    • second: source; only the centroid is read

  • [in] flags: what to calculate; OR constants such as lsst::afw::math::MEAN, MEANCLIP, STDDEV, MEDIAN, defined in lsst/afw/math/Statitics.h’s Property enum

  • [in] sctrl: statistics configuration

ProxyVector makeProxies(afw::table::SourceCatalog const &sourceCat, afw::geom::SkyWcs const &distortedWcs, afw::geom::SkyWcs const &tanWcs)
ProxyVector makeProxies(afw::table::SimpleCatalog const &posRefCat, afw::geom::SkyWcs const &tanWcs)
afw::table::ReferenceMatchVector matchOptimisticB(afw::table::SimpleCatalog const &posRefCat, afw::table::SourceCatalog const &sourceCat, MatchOptimisticBControl const &control, afw::geom::SkyWcs const &wcs, int posRefBegInd = 0, bool verbose = false)

Match sources to stars in a position reference catalog using optimistic pattern matching B

Optimistic Pattern Matching is described in V. Tabur 2007, PASA, 24, 189-198 “Fast Algorithms for Matching CCD Images to a Stellar Catalogue”

Return

a list of matches; the d field may be set, but you should not rely on it

Parameters
  • [in] posRefCat: catalog of position reference stars; fields read:

    • ”coord”

    • control.refFluxField

  • [in] sourceCat: catalog of detected sources; fields read:

    • ”Centroid_x”

    • ”Centroid_y”

    • control.refFluxField

  • [in] wcs: estimated WCS

  • [in] control: control object

  • [in] posRefBegInd: index of first start to use in posRefCat

  • [in] verbose: true to print diagnostic information to std::cout

PolynomialTransform compose(geom::AffineTransform const &t1, PolynomialTransform const &t2)

Return a PolynomialTransform that is equivalent to the composition t1(t2())

The returned composition would be exact in ideal arithmetic, but may suffer from significant round-off error for high-order polynomials.

PolynomialTransform compose(PolynomialTransform const &t1, geom::AffineTransform const &t2)

Return a PolynomialTransform that is equivalent to the composition t1(t2())

The returned composition would be exact in ideal arithmetic, but may suffer from significant round-off error for high-order polynomials.

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 OutlierRejectionControl
#include <ScaledPolynomialTransformFitter.h>

Control object for outlier rejection in ScaledPolynomialTransformFitter.

See ScaledPolynomialTransformFitter::rejectOutliers for more information.

class PolynomialTransform
#include <PolynomialTransform.h>

A 2-d coordinate transform represented by a pair of standard polynomials (one for each coordinate).

PolynomialTransform instances should be confined to a single thread.

struct RecordProxy
#include <matchOptimisticB.h>

A wrapper around a SimpleRecord or SourceRecord that allows us to record a pixel position in a way that is independent of the record type.

class ScaledPolynomialTransform
#include <PolynomialTransform.h>

A 2-d coordinate transform represented by a lazy composition of an AffineTransform, a PolynomialTransform, and another AffineTransform.

ScaledPolynomialTransform instances should be confined to a single thread.

class ScaledPolynomialTransformFitter
#include <ScaledPolynomialTransformFitter.h>

A fitter class for scaled polynomial transforms

This class allows for iteration between actual fitting, outlier rejection, and estimation of intrinsic scatter. It also provides access to the current model for debugging via an afw::table::BaseCatalog that contains the input values, output values, and the best-fit-transformed input values.

ScaledPolynomialTransformFitter has two public construction methods:

  • fromMatches fits a transform that maps intermediate world coordinates to pixel coordinates, using as inputs a match of reference coordinates to measured source positions. This sets up the fitter to do outlier rejection and intrinsic scatter estimation.

  • fromGrid fits an inverse to an existing transform, using the to-be-inverted transform to populate a grid of positions. Because the to-be-inverted transform is assumed to be known exactly, fitters initialized with this method have no need for outlier rejection or scatter estimation.

In either case, the fitter creates affine transforms that map the input and output data points onto [-1, 1]. It then fits a polynomial transform that, when composed with the input scaling transform and the inverse of the output scaling transform, maps the input data points to the output data points.

The fitter can be used in an outlier-rejection loop with the following pattern (with user-defined convergence criteria):

while (true) {
    fitter.fit();
    if (converged) break;
    fitter.updateModel();
    fitter.computeIntrinsicScatter();
    fitter.rejectOutliers();
}
This pattern fits a model, uses that model to transform the input points, estimates intrinsic scatter from the differences between model-transformed points and output data points, and finally rejects outliers by sigma-clipping those differences before repeating.

ScaledPolynomialTransformFitter instances should be confined to a single thread.

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.

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.

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

namespace detail

Functions

int computePackedOffset(int order)

Compute the index of the first coefficient with the given order in a packed 2-d polynomial coefficient array.

This defines the ordering as

[(0,0), (0,1), (1,0), (0,2), (1,1), (2,0), ...]
(or the same with indices swapped).

int computePackedSize(int order)

Compute this size of a packed 2-d polynomial coefficient array.

void computePowers(Eigen::VectorXd &r, double x)

Fill an array with integer powers of x, so \($r[n] == r^n\).

When multiple powers are needed, this should be signficantly faster than repeated calls to std::pow().

Eigen::VectorXd computePowers(double x, int n)

Return an array with integer powers of x, so \($r[n] == r^n\).

When multiple powers are needed, this should be signficantly faster than repeated calls to std::pow().

class BinomialMatrix
#include <polynomialUtils.h>

A class that computes binomial coefficients up to a certain power.

The binomial coefficient is defined as:

\[ \left(\begin{array}{ c } n k \end{array}right\) = \frac{n!}{k!(n-k)!} \]
with both \(n\) and \(k\) nonnegative integers and \(k \le n\)

This class uses recurrence relations to avoid computing factorials directly, making it both more efficient and numerically stable.

namespace sip

Functions

template<class MatchT>
CreateWcsWithSip<MatchT> makeCreateWcsWithSip(std::vector<MatchT> const &matches, afw::geom::SkyWcs const &linearWcs, int const order, geom::Box2I const &bbox = geom::Box2I(), int const ngrid = 0)

Factory function for CreateWcsWithSip.

template<class MatchT>
class CreateWcsWithSip
#include <CreateWcsWithSip.h>

Measure the distortions in an image plane and express them a SIP polynomials.

Given a list of matching sources between a catalogue and an image, and a linear Wcs that describes the mapping from pixel space in the image and ra/dec space in the catalogue, calculate discrepancies between the two and compute SIP distortion polynomials to describe the discrepancy

SIP polynomials are defined in Shupe at al. (2005) ASPC 347 491.

Note that the SIP standard insists (although it is only mentioned obliquly between Eqns 3 and 4) that the lowest three terms in the distortion polynomials be zero (A00, A10, A01, B00, etc.). To achieve this, we need to adjust the values of CD and CRPIX from the input wcs. This may not be the behaviour you expect.

A Wcs may be created in a variety of ways (e.g. lsst::meas::astrom::net::GlobalAstrometrySolution ), and the list of matched sources (matches) can be generated with the matchRaDec function.

#Example usage
matches = matchRaDec(catSet, srcSet, 1.0*afwGeom.arcseconds, true)
wcs = getWcsFromSomewhere()

maxScatter=0.1
maxOrder= 10
sipObject = CreateWcsWithSip(matches, wcs, maxScatter, maxOrder)
wcs = sipObject.getNewWcs()

Note that the matches must be one-to-one; this is ensured by passing closest=true to matchRaDec.

template<class FittingFunc>
class LeastSqFitter1d
#include <LeastSqFitter1d.h>

Fit an lsst::afw::math::Function1 object to a set of data points in one dimension.

The class is templated over the kind of object to fit.

Input is a list of x ordinates for a set of points, the y coordinate, and the uncertainties, s. order is order of the polynomial to fit (e.g if the templated function is lsst::afw::math::PolynomialFunction1, then order=3 => fit a function of the form \(ax^2+bx+c\)

See

LeastSqFitter1d

Template Parameters
Parameters
  • x: Ordinate of points to fit

  • y: Co-ordinate of pionts to fit

  • s: 1 \(\sigma\) uncertainties in z

  • order: Polynomial order to fit

template<class FittingFunc>
class LeastSqFitter2d
#include <LeastSqFitter2d.h>

Fit an lsst::afw::math::Function1 object to a set of data points in two dimensions.

The class is templated over the kind of object to fit. Note that we fit the 1d object in each dimension, not the 2d one.

Input is a list of x and y ordinates for a set of points, the z coordinate, and the uncertainties, s. order is order of the polynomial to fit (e.g if the templated function is lsst::afw::math::PolynomialFunction1, then order=3 => fit a function of the form \(ax^2+bx+c\)

See

LeastSqFitter1d

Template Parameters
Parameters
  • x: Ordinate of points to fit

  • y: Ordinate of points to fit

  • z: Co-ordinate of pionts to fit

  • s: 1 \(\sigma\) uncertainties in z

  • order: Polynomial order to fit

class MatchSrcToCatalogue
#include <MatchSrcToCatalogue.h>

Match a SourceSet of objects with known ra/dec with a SourceSet of objects with known xy positions Take a catalogue of objects with known positions, a catalogue of objects with known xy, and a wcs to convert one xy <> ra/dec. This class then finds the set of objects with common ra/dec.

The simplest usage is to create an object of this class, then access the corresponence sets with getMatchedImgSet() and getMatchedCatSet(). Creating the object automatically calculates the sets of corresponences for you. If you are unhappy with these matches, you can change one or more of your input arguments and redo the match with findMatches()

Using this class has the side effect of updating the coord field of the input SourceCatalog (which may be desirable).