Namespace lsst::meas

namespace meas
namespace algorithms

Functions

std::shared_ptr<afw::image::TransmissionCurve const> makeCoaddTransmissionCurve(std::shared_ptr<afw::geom::SkyWcs const> coaddWcs, afw::table::ExposureCatalog const &inputSensors)

Create a TransmissionCurve that represents the effective throughput on a coadd.

Return

a new TransmissionCurve object.

Parameters
  • [in] coaddWcs: WCS that relates the coadd coordinate system to the sky.

  • [in] inputSensors: A catalog containing the WCSs, bounding boxes and polygons, coaddition weights (in a field called ‘weight’), and TransmissionCurves of the sensor-level images that went into the coadd.

Exceptions
  • NotFoundError: Thrown if the ‘weight’ field does not exist in the schema.

  • InvalidParameterError: Thrown if one or more inputs do not have a TransmissionCurve or a Wcs (ValidPolygons may be null to indicate no spatial restrictions other than the bounding box).

template<typename MaskedImageT>
std::vector<std::shared_ptr<afw::detection::Footprint>> findCosmicRays(MaskedImageT &image, afw::detection::Psf const &psf, double const bkgd, daf::base::PropertySet const &ps, bool const keep = false)
template<typename ExposureT>
PTR(ExposurePatch<ExposureT>)

Factory function for ExposurePatch.

CONST_PTR(afw::detection::Footprint)
template<typename MaskedImageT>
void interpolateOverDefects(MaskedImageT &image, afw::detection::Psf const &psf, std::vector<Defect::Ptr> &badList, double fallbackValue = 0.0, bool useFallbackValueAtEdge = false)
template<typename PixelT>std::shared_ptr<PsfCandidate<PixelT> > lsst::meas::algorithms::makePsfCandidate(PTR( afw::table::SourceRecord ) const & source, PTR( afw::image::Exposure < PixelT >) image)

Parameters
  • source: The detected Source

  • image: The image wherein lies the object

Return a PsfCandidate of the right sort

Cf. std::make_pair

template<typename PixelT>
std::pair<std::shared_ptr<afw::math::LinearCombinationKernel>, std::vector<double>> createKernelFromPsfCandidates(afw::math::SpatialCellSet const &psfCells, geom::Extent2I const &dims, geom::Point2I const &xy0, int const nEigenComponents, int const spatialOrder, int const ksize, int const nStarPerCell = -1, bool const constantWeight = true, int const border = 3)
template<typename PixelT>
int countPsfCandidates(afw::math::SpatialCellSet const &psfCells, int const nStarPerCell = -1)
template<typename PixelT>
std::pair<bool, double> fitSpatialKernelFromPsfCandidates(afw::math::Kernel *kernel, afw::math::SpatialCellSet const &psfCells, int const nStarPerCell = -1, double const tolerance = 1e-5, double const lambda = 0.0)
template<typename PixelT>
std::pair<bool, double> fitSpatialKernelFromPsfCandidates(afw::math::Kernel *kernel, afw::math::SpatialCellSet const &psfCells, bool const doNonLinearFit, int const nStarPerCell = -1, double const tolerance = 1e-5, double const lambda = 0.0)
template<typename ImageT>
double subtractPsf(afw::detection::Psf const &psf, ImageT *data, double x, double y, double psfFlux = std::numeric_limits<double>::quiet_NaN())
template<typename Image>
std::pair<std::vector<double>, afw::math::KernelList> fitKernelParamsToImage(afw::math::LinearCombinationKernel const &kernel, Image const &image, geom::Point2D const &pos)
template<typename Image>
std::pair<std::shared_ptr<afw::math::Kernel>, std::pair<double, double>> fitKernelToImage(afw::math::LinearCombinationKernel const &kernel, Image const &image, geom::Point2D const &pos)

Variables

geom::Point2D const& lsst::meas::algorithms::center{ return std::make_shared<ExposurePatch<ExposureT> >(exp, foot, center)
afw::detection::Footprint const &standardFoot
afw::detection::Footprint const geom::Point2D const& lsst::meas::algorithms::standardCenter
afw::detection::Footprint const geom::Point2D const afw::geom::SkyWcs const& lsst::meas::algorithms::standardWcs{ return std::make_shared<ExposurePatch<ExposureT> >(exp, standardFoot, standardCenter, standardWcs)
struct CoaddBoundedFieldElement
#include <CoaddBoundedField.h>

Struct used to hold one Exposure’s data in a CoaddBoundedField.

class CoaddPsf : public lsst::afw::table::io::PersistableFacade<CoaddPsf>, public lsst::meas::algorithms::ImagePsf
#include <CoaddPsf.h>

CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.

It incorporates the logic of James Jee’s Stackfit algorithm for estimating the Psf of coadd by coadding the images of the Psf models of each input exposure.

class Defect : public lsst::afw::image::DefectBase
#include <Interp.h>

Encapsulate information about a bad portion of a detector.

class DoubleGaussianPsf : public lsst::afw::table::io::PersistableFacade<DoubleGaussianPsf>, public lsst::meas::algorithms::KernelPsf
#include <DoubleGaussianPsf.h>

Represent a Psf as a circularly symmetrical double Gaussian.

template<typename ExposureT>
class ExposurePatch
#include <ExposurePatch.h>

A convenience container for the exposure, peak and footprint that will be measured.

This is more useful than a std::pair or similar.

class ImagePsf : public lsst::afw::table::io::PersistableFacade<ImagePsf>, public lsst::afw::detection::Psf
#include <ImagePsf.h>

An intermediate base class for Psfs that use an image representation.

ImagePsf exists only to provide implementations of doComputeApertureFlux and doComputeShape for its derived classes. These implementations use the SincFlux and SdssShape algorithms defined in meas_algorithms, and hence could not be included with the Psf base class in afw.

Subclassed by lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::WarpedPsf, lsst::meas::extensions::psfex::PsfexPsf

class KernelPsf : public lsst::afw::table::io::PersistableFacade<KernelPsf>, public lsst::meas::algorithms::ImagePsf
#include <KernelPsf.h>

A Psf defined by a Kernel.

Subclassed by lsst::meas::algorithms::DoubleGaussianPsf, lsst::meas::algorithms::PcaPsf, lsst::meas::algorithms::SingleGaussianPsf

template<typename T = KernelPsf, typename K = afw::math::Kernel>
class KernelPsfFactory : public lsst::afw::table::io::PersistableFactory
#include <KernelPsfFactory.h>

A PersistableFactory for KernelPsf and its subclasses.

If a KernelPsf subclass has no data members other than its kernel, table persistence for it can be implemented simply by reimplementing getPersistenceName() and registering a specialization of KernelPsfFactory.

Template Parameters
  • T: KernelPsf subclass the factory will construct.

  • K: Kernel subclass the Psf constructor requires.

struct KernelPsfPersistenceHelper
#include <KernelPsfFactory.h>

A read-only singleton struct containing the schema and key used in persistence for KernelPsf.

class PcaPsf : public lsst::afw::table::io::PersistableFacade<PcaPsf>, public lsst::meas::algorithms::KernelPsf
#include <PcaPsf.h>

Represent a PSF as a linear combination of PCA (== Karhunen-Loeve) basis functions.

template<typename PixelT>
class PsfCandidate : public lsst::afw::math::SpatialCellImageCandidate
#include <PsfCandidate.h>

Class stored in SpatialCells for spatial Psf fitting.

PsfCandidate is a detection that may turn out to be a PSF. We’ll assign them to sets of SpatialCells; these sets will then be used to fit a spatial model to the PSF.

class SingleGaussianPsf : public lsst::afw::table::io::PersistableFacade<SingleGaussianPsf>, public lsst::meas::algorithms::KernelPsf
#include <SingleGaussianPsf.h>

Represent a PSF as a circularly symmetrical Gaussian.

class WarpedPsf : public lsst::meas::algorithms::ImagePsf
#include <WarpedPsf.h>

A Psf class that maps an arbitrary Psf through a coordinate transformation.

If K_0(x,x’) is the unwarped PSF, and f is the coordinate transform, then the warped PSF is defined by

K(f(x),f(x’)) = K_0(x,x’) (*)

We linearize the coordinate transform in the vicinity of the point where the PSF is computed. The definition (*) does not include the Jacobian of the transformation, since the afw convention is that PSF’s are normalized to have integral 1 anyway.

namespace interp

Functions

template<typename MaskedImageT>
std::pair<bool, typename MaskedImageT::Image::Pixel> singlePixel(int x, int y, MaskedImageT const &image, bool horizontal, double minval)

Variables

double const lpc_1_c1 = 0.7737

LPC coefficients for sigma = 1, S/N = infty

double const lpc_1_c2 = -0.2737
double const lpc_1s2_c1 = 0.7358

LPC coefficients for sigma = 1/sqrt(2), S/N = infty. These are the coeffs to use when interpolating at 45degrees to the row/column

double const lpc_1s2_c2 = -0.2358
double const min2GaussianBias = -0.5641895835

Mean value of the minimum of two N(0,1) variates.

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

namespace base

Unnamed Group

typedef int ElementCount
typedef double Flux
typedef double FluxErrElement
typedef double Mag
typedef double MagErrElement
typedef float ErrElement
typedef double CentroidElement
typedef double ShapeElement
typedef geom::Point<CentroidElement, 2> Centroid
typedef Eigen::Matrix<ErrElement, 2, 2, Eigen::DontAlign> CentroidCov
typedef afw::geom::ellipses::Quadrupole Shape
typedef Eigen::Matrix<ErrElement, 3, 3, Eigen::DontAlign> ShapeCov
typedef Eigen::Matrix<ShapeElement, 3, 3, Eigen::DontAlign> ShapeTrMatrix

Enums

enum UncertaintyEnum

An enum used to specify how much uncertainty information measurement algorithms provide.

Currently, only ResultMappers (not Results) make use of these distinctions; Result structs always have data members that could hold the full-covariance, but may set some of these to NaN.

Values:

NO_UNCERTAINTY = 0

Algorithm provides no uncertainy information at all.

SIGMA_ONLY = 1

Only the diagonal elements of the covariance matrix are provided.

FULL_COVARIANCE = 2

The full covariance matrix is provided.

Functions

LSST_EXCEPTION_TYPE(FatalAlgorithmError, lsst::pex::exceptions::RuntimeError, lsst::meas::base::FatalAlgorithmError)

Exception to be thrown when a measurement algorithm experiences a fatal error.

This error type causes the meas_base framework to throw completely out of the measurement loop which is run for each exposure, sourceCatalog pair.

LSST_EXCEPTION_TYPE(PixelValueError, lsst::pex::exceptions::DomainError, lsst::meas::base::PixelValueError)

Exception to be thrown when a measurement algorithm encounters a NaN or infinite pixel.

When caught by the plugin framework, this exception will generate a log message.

ShapeTrMatrix makeShapeTransformMatrix(geom::LinearTransform const &xform)

Construct a matrix suitable for transforming second moments.

Given an LinearTransform which maps from positions (x, y) to (a, d), returns a 3-by-3 matrix which transforms (xx, yy, xy) to (aa, dd, ad).

That is, given an input transform described by the matrix

| A11 | A12 | | A21 | A22 |

we return the matrix

| A11*A11 | A12*A12 | 2*A11*A12 | | A21*A21 | A22*A22 | 2*A21*A22 | | A11*A21 | A12*A22 | A11*A22 + A12*A21 |

Return

A 3-by-3 transformation matrix for the second order moments

Parameters
  • [in] xform: LinearTransform describing the coordinate mapping

class ApertureFluxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <ApertureFlux.h>

Base class for multiple-aperture photometry algorithms

ApertureFluxAlgorithm serves as an intermediate base class for all aperture fluxes, which it assumes have that capability of measuring multiple apertures (even if they are not always configured to do so).

Concrete implementations for single-aperture flux measurements are provided as static methods, as well as a consistent interface and control object for its derived classes. Currently, we only have one derived class, CircularApertureFluxAlgorithm, but in the future we anticipate adding more derived classes for e.g. elliptical apertures, or apertures that are circular in sky coordinates rather than pixel coordinates.

Subclassed by lsst::meas::base::CircularApertureFluxAlgorithm

class ApertureFluxControl
#include <ApertureFlux.h>

Configuration object for multiple-aperture flux algorithms

struct ApertureFluxResult : public lsst::meas::base::FluxResult
#include <ApertureFlux.h>

A Result struct for running an aperture flux algorithm with a single radius.

This simply extends FluxResult to add the appropriate error flags for aperture fluxes.

class ApertureFluxTransform : public lsst::meas::base::BaseTransform
#include <ApertureFlux.h>

Measurement transformation for aperture fluxes

Transforms instFluxes with associated errors to magnitudes. Correctly handles multiple apertures. Flags are propagated from input to output.

class BaseAlgorithm
#include <Algorithm.h>

Ultimate abstract base class for all C++ measurement algorithms

New algorithms should not inherit directly from this class.

Subclassed by lsst::meas::base::ForcedAlgorithm, lsst::meas::base::SingleFrameAlgorithm

class BaseTransform
#include <Transform.h>

Abstract base class for all C++ measurement transformations

Measurement plugins return results in raw, uncalibrated units (eg fluxes or positions in pixels). The transformation system provides a mechanism for post-processing those results into a calibrated form (magnitudes, celestial coordinates, etc).

A measurement transformation should derive from BaseTransform. It should implement a constructor which takes three arguments:

  • A Control object describing the configuration of the measurement plugin.

  • The name of the measurement plugin whose outputs are to be transformed (std::string);

  • An lsst::afw::table::SchemaMapper which links the input and output catalogs;

The constructor should use the SchemaMapper to map fields from the input to output schemas and add additional keys to the output as required. For example:


Derived classes should also implement operator() following the interface below. This will be called with a catalog containing the results of the measurement plugin and a catalog to be populated with transformed quantities, as well as WCS and calibration information. For example:


Note that it is safe to assume that both catalogs passed to operator() are contiguous in memory. It is good practice to ensure that they are equal in size: this may be conveniently achieved by calling BaseTransform::checkCatalogSize().

operator() may throw LengthError if the transformation is impossible to complete. In this case, the contents of outputCatalog is not guaranteed.

Subclassed by lsst::meas::base::ApertureFluxTransform, lsst::meas::base::CentroidTransform, lsst::meas::base::FluxTransform, lsst::meas::base::SdssShapeTransform

class BlendednessAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <Blendedness.h>

Compute metrics that measure how blended objects are.

Blendedness is initialized once for a given Schema, then run repeatedly by calls to measureChildPixels and measureParentPixels (in any order, possibly with multiple sources interleaved). Since it needs access to both the image with with noise and the noise replaced children it cannot use the standard plugin interface.

struct CentroidResult
#include <CentroidUtilities.h>

A reusable struct for centroid measurements.

Subclassed by lsst::meas::base::SdssShapeResult

class CentroidResultKey : public lsst::afw::table::FunctorKey<CentroidResult>
#include <CentroidUtilities.h>

A FunctorKey for CentroidResult.

This class makes it easy to copy centroids and their uncertainties to and from records, and provides a method to add the appropriate fields to a Schema.

class CentroidTransform : public lsst::meas::base::BaseTransform
#include <CentroidUtilities.h>

Base for centroid measurement transformations.

Provides a basic transform from centroid plus associated uncertainty to celestial position with uncertainty. The basic “flag” attribute for the measurement algorithm is propagated to the output.

Subclasses should define a constructor which take a Control argument corresponding to the measurement algorithm being transformed and ensure that any other necessary flags are propagated.

Subclassed by lsst::meas::base::NaiveCentroidTransform, lsst::meas::base::SdssCentroidTransform

struct FlagDefinition
#include <FlagHandler.h>

Simple class used to define and document flags The name and doc constitute the identity of the FlagDefinition The number is used for indexing, but is assigned arbitrarily.

class FlagDefinitionList
#include <FlagHandler.h>

vector-type utility class to build a collection of FlagDefinitions

class FlagHandler
#include <FlagHandler.h>

Utility class for handling flag fields that indicate the failure modes of an algorithm.

The typical pattern for using FlagHandler within an Algorithm is:

  • Add a FlagHandler object as a data member.

  • Create a FlagDefinitionList to specify the name and doc for each flag Add a “general” failure flag if one is needed (this indicates that some failure occurred). Add specific error flags for each type of error (these indicate a specific failure).

  • Initialize the FlagHandler data member within the Algorithm’s constructor, using the static addFields method to add the flags from the FlagDefinitionList to the schema.

See PsfFluxAlgorithm for a complete example.

struct FluxResult
#include <FluxUtilities.h>

A reusable result struct for instFlux measurements.

Subclassed by lsst::meas::base::ApertureFluxResult, lsst::meas::base::SdssShapeResult

class FluxResultKey : public lsst::afw::table::FunctorKey<FluxResult>
#include <FluxUtilities.h>

A FunctorKey for FluxResult.

This class makes it easy to copy instFluxes and their uncertainties to and from records, and provides a method to add the appropriate fields to a Schema.

class FluxTransform : public lsst::meas::base::BaseTransform
#include <FluxUtilities.h>

Base for instFlux measurement transformations

Provides a basic transform from instFlux plus associated uncertainty to magnitude with uncertainty. The basic “flag” attribute for the measurement algorithm is propagated to the output

Subclasses should define a constructor which take a Control argument corresponding to the measurement algorithm being transformed and ensure that any other necessary flags are propagated.

Subclassed by lsst::meas::base::GaussianFluxTransform, lsst::meas::base::LocalBackgroundTransform, lsst::meas::base::PeakLikelihoodFluxTransform, lsst::meas::base::PsfFluxTransform, lsst::meas::base::ScaledApertureFluxTransform

class ForcedAlgorithm : public virtual lsst::meas::base::BaseAlgorithm
#include <Algorithm.h>

Base class for algorithms that measure the properties of sources on one image, using previous measurements on another image to hold certain quantities fixed.

ForcedAlgorithm can be used when measuring both on single exposures and coadds, and is typically used to measure colors by holding centroids, apertures, or other model parameters fixed while allowing amplitudes to vary.

In addition to the virtual methods defined here, ForcedAlgorithm also puts requirements on constructor signatures; see the wrapForcedAlgorithm Python function for more information.

Most algorithms will not need to make use of the reference record or WCS, as transformed centroids and shapes should generally be available via the slots in measRecord, but these are made available for algorithms that need to transform more complex information. If that is the case, the algorithm may want to inherit from SimpleAlgorithm instead of inheriting from ForcedAlgorithm directly.

Subclassed by lsst::meas::base::SimpleAlgorithm

class GaussianFluxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <GaussianFlux.h>

A measurement algorithm that estimates instFlux using an elliptical Gaussian weight.

This algorithm computes instFlux as the dot product of an elliptical Gaussian weight function with the image. The size and ellipticity of the weight function are determined using the SdssShape algorithm, or retreived from a named field.

class GaussianFluxControl
#include <GaussianFlux.h>

A C++ control class to handle GaussianFluxAlgorithm’s configuration.

class LocalBackgroundAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <LocalBackground.h>

A measurement algorithm that estimates the local background value per pixel.

class LocalBackgroundControl
#include <LocalBackground.h>

Configuration of LocalBackgroundAlgorithm.

struct MagResult
#include <FluxUtilities.h>

A reusable result struct for magnitudes.

class MagResultKey : public lsst::afw::table::FunctorKey<MagResult>
#include <FluxUtilities.h>

A FunctorKey for MagResult.

This class makes it easy to copy magnitudes and their uncertainties to and from records, and provides a method to add the appropriate fields to a Schema.

class MeasurementError : public RuntimeError
#include <exceptions.h>

Exception to be thrown when a measurement algorithm experiences a known failure mode.

In addition to the usual message, MeasurementError must be constructed with the bit of the algorithm-specific flag that indicates the known failure mode. This allows the measurement framework to set that flag upon failure. Typically, this flag bit is also used to look up the message from the algorithm classes FlagDefinition list; the common pattern is:

if (badThingHappened) {
    // BAD_THING is an enum value from the Algorithm's FlagBits enum; getFlagDefinitions()
    // is a static method algorithms are expected to define.
    throw LSST_EXCEPT(MeasurementError, getFlagDefinitions()[BAD_THING), BAD_THING);
 }

class NaiveCentroidAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <NaiveCentroid.h>

A class that calculates a centroid as a simple unweighted first moment of the 3x3 region around a pixel.

A fixed background (set via config) may optionally be subtracted. This algorithm does not currently report an error, but it probably should.

class NaiveCentroidControl
#include <NaiveCentroid.h>

A C++ control class to handle NaiveCentroidAlgorithm’s configuration.

class PeakLikelihoodFluxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <PeakLikelihoodFlux.h>

A measurement algorithm that estimates the peak instrument flux, using a filtered image which has been convolved with its own PSF.

class PeakLikelihoodFluxControl
#include <PeakLikelihoodFlux.h>

C++ control object for peak likelihood instrument flux.

Peak likelihood flux requires an image that has been filtered by convolving with its own PSF (or an approximate model). It is equivalent to a PSF instrument flux (e.g. as computed by PsfFluxAlgorithm) computed on a non-preconvolved image.

The PSF must be provided in the exposure, as it is used to compute a weighting factor.

Flux and error are computed as follows:

  • instFlux = sum(unfiltered image * PSF) / sum(PSF^2) = value of peak of filtered source / sum(PSF^2)

  • err = sqrt(sum(unfiltered variance * PSF^2) / sum(PSF^2)^2) = sqrt(value of filtered variance at peak / sum(PSF^2)^2)

  • The pixels in the image are samples of a band-limited function, and by using a sinc interpolation (via a warping kernel) we can evaluate this function at any point. We use this technique to compute the peak of the function, which is assumed to be at the centroid of the filtered source.

class PixelFlagsAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <PixelFlags.h>

A measurement algorithm that gets mask bits from the exposure and sets flag bits to summarize which bits are set within a source’s footprint.

class PixelFlagsControl
#include <PixelFlags.h>

A C++ control class to handle PixelFlagsAlgorithm’s configuration.

class PsfFluxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <PsfFlux.h>

A measurement algorithm that estimates instFlux using a linear least-squares fit with the Psf model.

The PsfFlux algorithm is extremely simple: we do a least-squares fit of the Psf model (evaluated at a given position) to the data. For point sources, this provides the optimal instFlux measurement in the limit where the Psf model is correct. We do not use per-pixel weights in the fit, as this results in bright stars being fit with a different effective profile than faint stairs.

class PsfFluxControl
#include <PsfFlux.h>

A C++ control class to handle PsfFluxAlgorithm’s configuration.

In C++, we define Control objects to handle configuration information. Using the LSST_CONTROL_FIELD macro and lsst.pex.config.wrap.makeConfigClass, we can turn these into more full-featured Config classes in Python. While the user will usually interact with the Config class, the plugin wrapper system will turn Config instances into Control instances when passing them to C++.

This should logically be an inner class, but Swig doesn’t know how to parse those.

class SafeCentroidExtractor
#include <InputUtilities.h>

Utility class for measurement algorithms that extracts a position from the Centroid slot and handles errors in a safe and consistent way.

class SafeShapeExtractor
#include <InputUtilities.h>

Utility class for measurement algorithms that extracts an ellipse from the Shape slot and handles errors in a safe and consistent way.

class ScaledApertureFluxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <ScaledApertureFlux.h>

Measure the instFlux in an aperture scaled to the PSF.

This algorithm performs a sinc aperture instFlux measurement where they size of the aperture is determined by multiplying the FWHM of the PSF by the scaling factor specified in the algorithm configuration.

class SdssCentroidAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <SdssCentroid.h>

The Sdss Centroid Algorithm.

class SdssCentroidControl
#include <SdssCentroid.h>

A C++ control class to handle SdssCentroidAlgorithm’s configuration.

class SdssShapeAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <SdssShape.h>

Measure the image moments of source using adaptive Gaussian weights.

This algorithm measures the weighted second moments of an image using a Gaussian weight function, which is iteratively updated to match the current weights. If this iteration does not converge, it can fall back to using unweighted moments, which can be significantly noisier.

See Bernstein & Jarvis, 2002, for more information on this type of algorithm. Note that the code here makes no attempt to correct for the PSF; for PSF corrected ellipticities using weighted moments please use the shapeHSM package.

class SdssShapeControl
#include <SdssShape.h>

A C++ control class to handle SdssShapeAlgorithm’s configuration.

class SdssShapeResult : public lsst::meas::base::ShapeResult, public lsst::meas::base::CentroidResult, public lsst::meas::base::FluxResult
#include <SdssShape.h>

Result object SdssShapeAlgorithm.

Because we have use cases for running SdssShape outside of the measurement framework (in particular, we need to run it on PSF model images), we provide an interface that doesn’t need to use SourceRecord for its inputs and outputs. Instead, it returns an instance of this class.

Note: for what I guess are historical reasons, SdssShape computes covariance terms between the instFlux and the shape, but not between the instFlux and centroid or centroid and shape.

This should logically be an inner class, but Swig doesn’t know how to parse those.

class SdssShapeResultKey : public lsst::afw::table::FunctorKey<SdssShapeResult>
#include <SdssShape.h>

A FunctorKey that maps SdssShapeResult to afw::table Records.

This is used internally by SdssShapeAlgorithm to transfer results from SdssShapeResult to SourceRecord, but it can also be used in the other direction by codes that need to extra an SdssShapeResult from a record.

class SdssShapeTransform : public lsst::meas::base::BaseTransform
#include <SdssShape.h>

Transformation for SdssShape measurements.

SdssShape measures not just shape but also instFlux and centroid. This transform operates on the first directly, and delegates to the Flux and Centroid transforms for the other two.

struct ShapeResult
#include <ShapeUtilities.h>

A reusable struct for moments-based shape measurements.

Shape measurements and their errors should always be in pixels coordinates. This struct should generally be preferred over a custom struct with other ellipse parametrizations unless the measurement takes place in another parametrization and a transformation to this one would result in a loss of information or obfuscate the results of the measurement (i.e. use this one unless you have a good reason not to).

Subclassed by lsst::meas::base::SdssShapeResult

class ShapeResultKey : public lsst::afw::table::FunctorKey<ShapeResult>
#include <ShapeUtilities.h>

A FunctorKey for ShapeResult.

This class makes it easy to copy shapes and their uncertainties to and from records, and provides a method to add the appropriate fields to a Schema.

class SimpleAlgorithm : public lsst::meas::base::SingleFrameAlgorithm, public lsst::meas::base::ForcedAlgorithm
#include <Algorithm.h>

An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm and ForcedAlgorithm.

SimpleAlgorithm allows a ForcedAlgorithm to be defined using the measure() and measureN() signatures of SingleFrameAlgorithm. It should be used for any algorithm for which the forced version of the algorithm does not require anything to be transformed beyond the centroid and shape, and for which the the parameters being fit are the same for both single-frame and forced measurement. This should be the case for all flux algorithms that don’t involve fitting any additional model parameters. It can also be used for centroid and shape algorithms, where having a version that can re-measure values in forced mode may be useful for diagnostic purposes even if it is not useful for science.

Subclassed by lsst::ip::diffim::DipoleCentroidAlgorithm, lsst::ip::diffim::DipoleFluxAlgorithm, lsst::meas::base::ApertureFluxAlgorithm, lsst::meas::base::BlendednessAlgorithm, lsst::meas::base::GaussianFluxAlgorithm, lsst::meas::base::LocalBackgroundAlgorithm, lsst::meas::base::NaiveCentroidAlgorithm, lsst::meas::base::PeakLikelihoodFluxAlgorithm, lsst::meas::base::PixelFlagsAlgorithm, lsst::meas::base::PsfFluxAlgorithm, lsst::meas::base::ScaledApertureFluxAlgorithm, lsst::meas::base::SdssCentroidAlgorithm, lsst::meas::base::SdssShapeAlgorithm, lsst::meas::extensions::photometryKron::KronFluxAlgorithm, lsst::meas::extensions::simpleShape::SimpleShape, lsst::meas::modelfit::DoubleShapeletPsfApproxAlgorithm

template<typename PixelT>
class SincCoeffs
#include <SincCoeffs.h>

A singleton to calculate and cache the coefficients for sinc photometry

Caching is only performed for circular apertures (because elliptical apertures are assumed to be generated dynamically, and hence not expected to recur). Caching must be explicitly requested for a particular circular aperture (using the ‘cache’ method).

class SingleFrameAlgorithm : public virtual lsst::meas::base::BaseAlgorithm
#include <Algorithm.h>

Base class for algorithms that measure the properties of sources on single image.

SingleFrameAlgorithm defines the interface used in measuring both on single exposure images and on coadds.

In addition to the virtual methods defined here, SingleFrameAlgorithm also puts requirements on constructor signatures; see the wrapSingleFrameAlgorithm Python function for more information.

Subclassed by lsst::meas::base::SimpleAlgorithm

namespace python

Functions

template<class Algorithm, class PyAlg>
std::enable_if<!std::is_abstract<Algorithm>::value, void>::type declareAlgorithmConstructor(PyAlg &cls)

Wrap the standard algorithm constructor.

Template Parameters
  • Algorithm: The algorithm class.

  • PyAlg: The pybind11::class_ class corresponding to Algorithm.

Parameters
  • [inout] cls: The pybind11 wrapper for Algorithm.

template<class Algorithm, class PyAlg>
std::enable_if<std::is_abstract<Algorithm>::value, void>::type declareAlgorithmConstructor(PyAlg &cls)

Dummy function for not wrapping the constructor of an abstract base class.

Pybind11 cannot wrap such constructors, and there is no reason to call them from Python anyway.

Template Parameters
  • Algorithm: The algorithm class.

  • PyAlg: The pybind11::class_ class corresponding to Algorithm.

Parameters
  • [inout] cls: The pybind11 wrapper for Algorithm.

template<class Algorithm, class PyAlg>
void declareAlgorithm(PyAlg &clsAlgorithm)

Wrap the implicit API used by meas_base’s algorithms.

This function only initializes constructors, fields, and methods common to all Algorithms.

Template Parameters
  • Algorithm: The algorithm class.

  • PyAlg: The pybind11::class_ class corresponding to Algorithm.

Parameters
  • [inout] clsAlgorithm: The pybind11 wrapper for Algorithm.

template<class Algorithm, class Control, class PyAlg, class PyCtrl>
void declareAlgorithm(PyAlg &clsAlgorithm, PyCtrl &clsControl)

Wrap the implicit API used by meas_base’s algorithm-control pairs (no transform).

This function only initializes constructors, fields, and methods common to all Algorithms and Controls.

Template Parameters
  • Algorithm: The algorithm class.

  • Control: The control class. Must equal Algorithm::Control and Transform::Control.

  • PyAlg: The pybind11::class_ class corresponding to Algorithm.

  • PyCtrl: The pybind11::class_ class corresponding to Control.

Parameters
  • [inout] clsAlgorithm[inout] clsControl: The pybind11 wrappers for the respective C++ classes.

template<class Algorithm, class Control, class Transform, class PyAlg, class PyCtrl, class PyXform>
void declareAlgorithm(PyAlg &clsAlgorithm, PyCtrl &clsControl, PyXform &clsTransform)

Wrap the implicit API used by meas_base’s algorithm-control-transform triads.

This function only initializes constructors, fields, and methods common to all Algorithms, Controls, and Transforms.

Template Parameters
  • Algorithm: The algorithm class.

  • Control: The control class. Must equal Algorithm::Control and Transform::Control.

  • Transform: The transform class.

  • PyAlg: The pybind11::class_ class corresponding to Algorithm.

  • PyCtrl: The pybind11::class_ class corresponding to Control.

  • PyXform: The pybind11::class_ class corresponding to Transform.

Parameters
  • [inout] clsAlgorithm[inout] clsControl[inout] clsTransform: The pybind11 wrappers for the respective C++ classes.

namespace extensions
namespace photometryKron
class KronFluxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <photometryKron.h>

A measurement algorithm that estimates flux using Kron photometry.

class KronFluxControl
#include <photometryKron.h>

C++ control object for Kron flux.

See

KronFluxConfig.

namespace psfex
class PsfexPsf : public lsst::afw::table::io::PersistableFacade<PsfexPsf>, public lsst::meas::algorithms::ImagePsf
#include <PsfexPsf.h>

Represent a PSF as a linear combination of PSFEX (== Karhunen-Loeve) basis functions.

namespace simpleShape
class SimpleShapeControl
#include <simpleShape.h>

A C++ control class to handle SdssShapeAlgorithm’s configuration.

class SimpleShapeResult
#include <simpleShape.h>

Struct to hold the results of SimpleShape when we don’t run it as a plugin.

namespace modelfit

Unnamed Group

typedef float Pixel

Typedefs to be used for pixel values

Unnamed Group

typedef double Scalar

Typedefs to be used for probability and parameter values

typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector
typedef afw::table::Key<Scalar> ScalarKey
typedef afw::table::Key<afw::table::Array<Scalar>> ArrayKey

Typedefs

typedef std::vector<PTR(Model)> ModelVector

Functions

void solveTrustRegion(ndarray::Array<Scalar, 1, 1> const &x, ndarray::Array<Scalar const, 2, 1> const &F, ndarray::Array<Scalar const, 1, 1> const &g, double r, double tolerance)

Solve a symmetric quadratic matrix equation with a ball constraint.

This computes a near-exact solution to the “trust region subproblem” necessary in trust-region-based nonlinear optimizers:

\[ \min_x{\quad g^T x + \frac{1}{2}x^T F x}\quad\quad\quad \text{s.t.} ||x|| \le r \]

The tolerance parameter sets how close to \(r\) we require the norm of the solution to be when it lies on the constraint, as a fraction of \(r\) itself.

This implementation is based on the algorithm described in Section 4.3 of “Nonlinear Optimization” by Nocedal and Wright.

class AdaptiveImportanceSampler : public lsst::meas::modelfit::Sampler
#include <AdaptiveImportanceSampler.h>

Sampler class that performs Monte Carlo sampling, while iteratively updating the analytic distribution from which points are drawn.

Between the iterations defined in the control object, the prior is applied to the samples, and the mixture distribution is updated using expectation-maximization to match the samples.

class CModelAlgorithm
#include <CModel.h>

Main public interface class for CModel algorithm.

See CModel Magnitudes for a full description of the algorithm.

This class provides the methods that actually execute the algorithm, and (depending on how it is constructed) holds the Key objects necessary to use SourceRecords for input and output.

struct CModelControl
#include <CModel.h>

The main control object for CModel, containing parameters for the final linear fit and aggregating the other control objects.

struct CModelResult
#include <CModel.h>

Master result object for CModel, containing results for the final linear fit and three nested CModelStageResult objects for the results of the previous stages.

struct CModelStageControl
#include <CModel.h>

Nested control object for CModel that configures one of the three (“initial”, “exp”, “dev”) nonlinear fitting stages.

struct CModelStageResult
#include <CModel.h>

Result object for a single nonlinear fitting stage of the CModel algorithm

class DoubleShapeletPsfApproxAlgorithm : public lsst::meas::base::SimpleAlgorithm
#include <DoubleShapeletPsfApprox.h>

An algorithm that fits a 2-component shapelet approximation to the PSF model.

This algorithm fits a similar model to the one that has been used on the HSC side for several data releases, but uses the improved optimizer in meas_modelfit instead of the one in (the now defunct) meas_extensions_multiShapelet and using moments to reduce the number of parameters in the fit. It is faster and more robust than GeneralShapeletPsfApprox, but much less flexible.

The model is not a fully general one, even for two shapelet components. We tie the ellipticities of the two components together, hold the center fixed, and keep their radii fixed at a value set in the configuration; this means we fit only one set of ellipse parameters, instead of two.

class DoubleShapeletPsfApproxControl
#include <DoubleShapeletPsfApprox.h>

Control object used to configure a 2-shapelet fit to a PSF model; see DoubleShapeletPsfApproxAlgorithm.

class EpochFootprint
#include <UnitTransformedLikelihood.h>

An image at one epoch of a galaxy, plus associated info

Includes one image of a galaxy and and associated footprint and multi-shapelet PSF model

class GeneralPsfFitter
#include <GeneralPsfFitter.h>

Class for fitting multishapelet models to PSF images.

This class fits up to four shapelet expansions simultaneously to a PSF image, with the relative radii and number of shapelet coefficients for each expansion separately configurable. These expansions are also named; this allows us to map different fits with some expansions disabled to each other, in order to first fit an approximate model and follow this up with a more complete model, using the approximate model as a starting point.

The configuration also defines a simple Bayesian prior for the fit, defined using simple independent Gaussians for the ellipse parameters of each component. The priors can be disabled by setting their width (xxPriorSigma in the control object) to infinity, and those parameters can be held fixed at their input values by setting the prior width to zero. The priors are always centered at the input value, meaning that it may be more appropriate to think of the priors as a form of regularization, rather than a rigorous prior. In fact, it’s impossible to use a prior here rigorously without a noise model for the PSF image, which is something the LSST Psf class doesn’t provide, and here is just provided as a constant noise sigma to be provided by the user (who generally just has to chose a small number arbitrarily). Decreasing the noise sigma will of course decrease the effect of the priors (and vice versa). In any case, having some sort of regularization is probably a good idea, as this is a very high-dimensional fit.

Subclassed by lsst::meas::modelfit::GeneralPsfFitterAlgorithm

class GeneralPsfFitterComponentControl
#include <GeneralPsfFitter.h>

Control object used to define one piece of multishapelet fit to a PSF model; see GeneralPsfFitterControl

class GeneralPsfFitterControl
#include <GeneralPsfFitter.h>

Control object used to configure a multishapelet fit to a PSF model; see GeneralPsfFitter.

The default configuration corresponds to fitting an elliptical double-Gaussian, in which each component can have different radii, positions, and ellipticities. While the fitter can support much more complex models, at present, fitting these is prohibitively slow, and is not recommended in production environments (use DoubleShapeletPsfApprox instead).

class ImportanceSamplerControl
#include <AdaptiveImportanceSampler.h>

Control object for one iteration of adaptive importance sampling.

See

AdaptiveImportanceSampler, AdaptiveImportanceSamplerTask

class Likelihood
#include <Likelihood.h>

Base class for optimizer/sampler likelihood functions that compute likelihood at a point.

Likelihood abstracts the problem of computing the likelihood over different kinds of data. It is responsible for creating a “model matrix” that maps amplitudes to data values, and maintaining a vector of scaled, weighted data values that corresponds to it. Its components can be represented best in the mathematical formula for a -log likelihood assuming Gaussian data and a model with both nonlinear parameters \(\theta\) and linear (“amplitude”) parameters \(\alpha\):

\[ L(\alpha,\theta) = \frac{1}{2}\left(y - A(\theta)\alpha\right)^T\, \Sigma^{-1}\,\left(y - A(\theta)\alpha\right) \]
where \(y\) is the data vector, \(\Sigma\) is the data covariance matrix (assumed to be diagonal), and \(A(\theta)\) is the “true” model matrix (parametrized on the nonlinear parameters).

When fitting or sampling from the likelihood, however, we don’t want to use these quantities directly, and they aren’t what the Likelihood class provides. Instead, we reparametrize with:

\[ w_i \equiv \Sigma_{i,i}^{-1/2} \]
\[ z_i = w_i y_i \]
\[ B_{i,j} = w_i A_{i,j} \]
resulting in the equivalent formula:
\[ L(\alpha,\theta) = \frac{1}{2}\left(z-B(\theta)\alpha\right)^T\,\left(z-B(\theta)\alpha\right) \]
The \(w_i\) are the weights, which are applied to both the data vector and the model matrix to account for the noise in the data. In some cases, we may choose to use a constant weight rather than per-pixel weights, but will will still use a vector to represent it.

Subclassed by lsst::meas::modelfit::MultiShapeletPsfLikelihood, lsst::meas::modelfit::UnitTransformedLikelihood

struct LocalUnitTransform
#include <UnitSystem.h>

A local mapping between two UnitSystems.

LocalUnitTransform is “local” because it linearizes the Wcs and evaluates the PhotoCalib transform at a particular predifined point, allowing it to represent the geometric transform as an AffineTransform and the photometric transform as a simple scaling.

class MixtureComponent
#include <Mixture.h>

A weighted Student’s T or Gaussian distribution used as a component in a Mixture.

class MixturePrior : public lsst::meas::modelfit::Prior
#include <MixturePrior.h>

A prior that’s flat in amplitude parameters, and uses a Mixture for nonlinear parameters.

class MixtureUpdateRestriction
#include <Mixture.h>

Helper class used to define restrictions to the form of the component parameters in Mixture::updateEM.

The base class implementation does not apply any restrictions.

class Model
#include <Model.h>

Abstract base class and concrete factories that define multi-shapelet galaxy models.

A Model provides a mapping from its parameters to ellipses and to a realization using shapelet objects. A Model does not “hold” its parameters; parameters are always stored in separate arrays.

Model parameters are split into three categories: nonlinear, amplitudes, and fixed. These are described more fully in modelfitParameters.

A few private concrete subclasses of Model have been provided that will meet most needs; instances can be constructed via the make() and makeGaussian()

Subclassed by lsst::meas::modelfit::MultiModel

class MultiModel : public lsst::meas::modelfit::Model
#include <MultiModel.h>

A concrete Model class that simply concatenates several other Models.

class MultiShapeletPsfLikelihood : public lsst::meas::modelfit::Likelihood
#include <GeneralPsfFitter.h>

Likelihood object used to fit multishapelet models to PSF model images; mostly for internal use by GeneralPsfFitter.

class Optimizer
#include <optimizer.h>

A numerical optimizer customized for least-squares problems with Bayesian priors.

The algorithm used by Optimizer combines the Gauss-Newton approach of approximating the second-derivative (Hessian) matrix as the inner product of the Jacobian of the residuals, while maintaining a matrix of corrections to this to account for large residuals, which is updated using a symmetric rank-1 (SR1) secant formula. We assume the prior has analytic first and second derivatives, but use numerical derivatives to compute the Jacobian of the residuals at every step. A trust region approach is used to ensure global convergence.

We consider the function \(f(x)\) we wish to optimize to have two terms, which correspond to negative log likelihood ( \(\chi^2/2=\|r(x)|^2\), where \(r(x)\) is the vector of residuals at \(x\)) and negative log prior \(q(x)=-\ln P(x)\):

\[ f(x) = \frac{1}{2}\|r(x)\|^2 + q(x) \]
At each iteration \(k\), we expand \(f(x)\) in a Taylor series in \(s=x_{k+1}-x_{k}\):
\[ f(x) \approx m(s) = f(x_k) + g_k^T s + \frac{1}{2}s^T H_k s \]
where
\[ g_k \equiv \left.\frac{\partial f}{\partial x}\right|_{x_k} = J_k^T r_k + \nabla q_k;\quad\quad J_k \equiv \left.\frac{\partial r}{\partial x}\right|_{x_k} \]
\[ H_k = J_k^T J_k + \nabla^2 q_k + B_k \]
Here, \(B_k\) is the SR1 approximation term to the second derivative term:
\[ B_k \approx \sum_i \frac{\partial^2 r^{(i)}_k}{\partial x^2}r^{(i)}_k \]
which we initialize to zero and then update with the following formula:
\[ B_{k+1} = B_{k} + \frac{v v^T}{v^T s};\quad\quad v\equiv J^T_{k+1} r_{k+1} - J^T_k r_k \]
Unlike the more common rank-2 BFGS update formula, SR1 updates are not guaranteed to produce a positive definite Hessian. This can result in more accurate approximations of the Hessian (and hence more accurate covariance matrices), but it rules out line-search methods and the simple dog-leg approach to the trust region problem. As a result, we should require fewer steps to converge, but spend more time computing each step; this is ideal when we expect the time spent in function evaluation to dominate the time per step anyway.

class OptimizerControl
#include <optimizer.h>

Configuration object for Optimizer.

Many of these configuration options pertain to how the trust region is updated. It’s easiest to understand these together rather than separately. At each iteration, a quadratic model of the objective function is formed. We can use this model to predict how we expect the objective function to behave over a step, and compare it to how the actual objective function behaves. To do this, we’ll use the ratio of the actual reduction in the objective function to the predicted reduction in the objective function, and call this \(\rho\). Then,

  • the step is accepted, and the parameters updated, when \(\rho >\) stepAcceptThreshold.

  • if \(\rho > \) trustRegionGrowReductionRatio and the length of the step is greater than trustRegionGrowStepFraction times the current trust region radius, the trust region radius will be multiplied by trustRegionGrowFactor.

  • if trustRegionShrinkMinReductionRatio \(< \rho < \) trustRegionShrinkMaxReductionRatio, the trust region radius will be multiplied by trustRegionShrinkFactor.

class OptimizerObjective
#include <optimizer.h>

Base class for objective functions for Optimizer.

class Prior
#include <Prior.h>

Base class for Bayesian priors.

Subclassed by lsst::meas::modelfit::MixturePrior, lsst::meas::modelfit::SemiEmpiricalPrior, lsst::meas::modelfit::SoftenedLinearPrior

class Sampler

Subclassed by lsst::meas::modelfit::AdaptiveImportanceSampler

class SemiEmpiricalPrior : public lsst::meas::modelfit::Prior
#include <SemiEmpiricalPrior.h>

A piecewise prior motivated by both real distributions and practical considerations.

class SoftenedLinearPrior : public lsst::meas::modelfit::Prior
#include <SoftenedLinearPrior.h>

A prior that’s linear in radius and flat in ellipticity, with a cubic roll-off at the edges.

class TruncatedGaussian
#include <TruncatedGaussian.h>

Represents a multidimensional Gaussian function truncated at zero.

This is typically used to represent the posterior probability of amplitude parameters, given a flat prior; we require that the amplitudes each be positive but otherwise do not modify the Gaussian likelihood.

Currently only 1 and 2 dimensions are supported, and all dimensions must be truncated. Computing integrals is the only operation for which > 2-d is not implemented, but the integrals must be computed upon construction, so we can’t support any other operations for > 2-d either.

Many operations on TruncatedGaussians are defined in -log space, as underflow/overflow problems will often occur in the non-log forms.

See modelfitTruncatedGaussianMath for implementation notes

class TruncatedGaussianEvaluator
#include <TruncatedGaussian.h>

Helper class for evaluating the -log of a TruncatedGaussian.

class TruncatedGaussianLogEvaluator
#include <TruncatedGaussian.h>

Helper class for evaluating the -log of a TruncatedGaussian.

class TruncatedGaussianSampler
#include <TruncatedGaussian.h>

Helper class for drawing samples from a TruncatedGaussian.

struct UnitSystem
#include <UnitSystem.h>

A simple struct that combines a Wcs and a PhotoCalib.

class UnitTransformedLikelihood : public lsst::meas::modelfit::Likelihood
#include <UnitTransformedLikelihood.h>

A concrete Likelihood class that does not require its parameters and data to be in the same UnitSystem.

This is the main concrete Likelihood class using when fitting sources, even in the case where the measurement UnitSystem is the same as that of the data; we always prefer to fit in a special UnitSystem (see modelfitUnits), using this class to transform the model realization when comparing to the data. This makes forced photometry and modelfit measurements just as easy as single-frame measurements (aside from data access); one can simply initialize a UnitTransformedLikelihood with multiple exposures instead of a single exposure to fit simultaneously to multiple exposures.

class UnitTransformedLikelihoodControl
#include <UnitTransformedLikelihood.h>

Control object used to initialize a UnitTransformedLikelihood.

Translated to Python as UnitTransformedLikelihoodConfig; the Swig-wrapped C++ Control object can be created from the config object via the makeControl() method (see lsst.pex.config.wrap).

namespace detail

Functions

Eigen::Vector4d solveRampPoly(double v0, double v1, double x0, double x1, double s0, double s1)

Solve for the coefficients of a cubic polynomial p(x) that goes from p(x0)=v0 to p(x1)=v1, with p’(x0)=s0 and p’(x1)=s1.

double phid(double z)

Compute univariate normal probabilities.

This function computes

\[ \frac{1}{2\pi}\int_z^{\infty}dx\;e^{-x^2/(2z^2)} \]

This is just a simple wrapper around boost::math::erfc, used to provide the particular form expected by bvnu.

double bvnu(double h, double k, double rho)

Compute bivariate normal probabilities.

This function computes

\[ \frac{1}{2\pi\sqrt{1-\rho^2}}\int_h^{\infty}dx\int_k^{\infty}dy \;e^{-(x^2 - 2\rho x y + y^2)/(2(1-\rho^2))} \]

It is a reimplementation of the “bvnu” MatLab routine by Alan Genz. The original implementation can be found at http://www.math.wsu.edu/faculty/genz/homepage. It is based on the algorithm described in:

Drezner & Wesolowsky (1989), “On the computation of the bivariate normal integral”, Journal of Statist. Comput. Simul. 35, pp. 101-107.

A copy of Genz’s FORTRAN routine of the same is included in the tests directory, as it has been used to generate the test reference data there. It should generally not need to be compiled by users.

Most of the time, this function should be called via the methods in the TruncatedGaussian class; it is exposed publically only for testing purposes.

template<int N>
class Vandermonde
#include <polynomials.h>

Class that computes rows of the Vandermonde matrix and related matrices; the dot product of these row vectors with the polynomial coefficient vectors evaluates the polynomial (or computes a derivative).