File AstrometryFit.h

namespace lsst

Class for a simple mapping implementing a generic AstrometryTransform.

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

Forward declarations for lsst::utils::Cache

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

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

A base class for image defects

Numeric constants used by the Integrate.h integrator routines.

Compute Image Statistics

Note

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

Note

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

namespace jointcal
class AstrometryFit : public lsst::jointcal::FitterBase
#include <AstrometryFit.h>

Class that handles the astrometric least squares problem.

This is the class that actually computes the quantities required to carry out a LS astrometric fit wrt distortion mappings and coordinates of common objects. Namely it computes the Jacobian and gradient of the chi2 (w.r.t. parameters), and the Chi2 itself. It interfaces with the actual modelling of distortions via a mimimum virtual interface AstrometryModel, and the actual mappings via an other virtual interface : Mapping.

In short AstrometryFit aims at computing derivatives of least quares. The terms of the chi2 are of two kinds:

kind 1 -> (T(X_M) - p(F))^T W (T(X_M) - p(F))

with X_M is a measured (2d) position in CCD coordinates, F refers to the position of the object in some space, defined in practise by p. There is one such term per measurement. The default setup would be that p is the projection from sky to some tangent plane and hence T maps the CCD coordinates onto this TP. p is obtained via the DistorsionModel and can be different for all CcdImage’s. Depending on what is beeing fitted, one could imagine cases where the projector p is the same for all CcdImages.

Kind 2 -> (p’(F)-p’(R))^T W_R (p’(F)-p’(R)) R refers to some externally-provided reference object position, and p’ to some projector from sky to some plane. The reference objects define the overall coordinate frame, which is required when all T and all F are fitted simultaneously. There is one such term per external reference object. There can be more F (fitted) objects than R (reference) objects.

In the same framework, one can fit relative transforms between images by setting p = Identity for all input CcdImages and not fitting T for one of the CcdImage’s. One does not need reference object and would then naturally not have any Kind 2 terms.

Public Functions

AstrometryFit(std::shared_ptr<Associations> associations, std::shared_ptr<AstrometryModel> astrometryModel, double posError)

this is the only constructor

AstrometryFit(AstrometryFit const&)

No copy or move: there is only ever one fitter of a given type.

AstrometryFit(AstrometryFit&&)
AstrometryFit &operator=(AstrometryFit const&)
AstrometryFit &operator=(AstrometryFit&&)
void assignIndices(std::string const &whatToFit)

Set parameters to fit and assign indices in the big matrix.

Parameters
  • [in] whatToFit: Valid strings: zero or more of “Distortions”, “Positions”, “Refrac”, “PM” which define which parameter set is going to be variable when computing derivatives (leastSquareDerivatives) and minimizing (minimize()). whatToFit=”Positions Distortions” will minimize w.r.t mappings and objects positions, and not w.r.t proper motions and refraction modeling. However if proper motions and/or refraction parameters have already been set, then they are accounted for when computing residuals. The string is forwarded to the AstrometryModel, and it can then be used to turn subsets of distortion parameter on or off, if the AstrometryModel implements such a thing.

void freezeErrorTransform()

The transformations used to propagate errors are freezed to the current state. The routine can be called when the mappings are roughly in place. After the call, the transformations used to propage errors are no longer affected when updating the mappings. This allows to have an exactly linear fit, which can be useful.

void offsetParams(Eigen::VectorXd const &delta)

Offset the parameters by the requested quantities. The used parameter layout is the one from the last call to assignIndices or minimize(). There is no easy way to check that the current setting of whatToFit and the provided Delta vector are compatible: we can only test the size.

Parameters
  • [in] delta: vector of offsets to apply

std::shared_ptr<AstrometryModel> getModel() const

Return the model being fit.

void checkStuff()

DEBUGGING routine

Protected Functions

void saveChi2MeasContributions(std::string const &filename) const

Save a CSV file containing residuals of measurement terms.

void saveChi2RefContributions(std::string const &filename) const

Save a CSV file containing residuals of reference terms.

Private Functions

void leastSquareDerivativesMeasurement(CcdImage const &ccdImage, TripletList &tripletList, Eigen::VectorXd &grad, MeasuredStarList const *measuredStarList = nullptr) const

Compute the derivatives of the measured stars and model for one CcdImage.

The last argument will process a sub-list for outlier removal.

void leastSquareDerivativesReference(FittedStarList const &fittedStarList, TripletList &tripletList, Eigen::VectorXd &grad) const

Compute the derivatives of the reference terms.

void accumulateStatImageList(CcdImageList const &ccdImageList, Chi2Accumulator &accum) const

Compute the chi2 (per star or total, depending on which Chi2Accumulator is used) for measurements.

void accumulateStatRefStars(Chi2Accumulator &accum) const

Compute the chi2 (per star or total, depending on which Chi2Accumulator is used) for RefStars.

void getIndicesOfMeasuredStar(MeasuredStar const &measuredStar, IndexVector &indices) const

Set the indices of a measured star from the full matrix, for outlier removal.

Point transformFittedStar(FittedStar const &fittedStar, AstrometryTransform const &sky2TP, Point const &refractionVector, double refractionCoeff, double mjd) const
void accumulateStatImage(CcdImage const &ccdImage, Chi2Accumulator &accum) const

Compute the chi2 (per star or total, depending on which Chi2Accumulator is used) from one CcdImage.

Private Members

bool _fittingDistortions
bool _fittingPos
bool _fittingRefrac
bool _fittingPM
std::shared_ptr<AstrometryModel> _astrometryModel
double _referenceColor
double _sigCol
double _refractionCoefficient
Eigen::Index _refracPosInMatrix
double _JDRef
std::size_t _nParDistortions
std::size_t _nParPositions
std::size_t _nParRefrac
double _posError