lsst.jointcal
master-gc935ebf72c
|
Class that handles the astrometric least squares problem. More...
#include <AstrometryFit.h>
Public Member Functions | |
AstrometryFit (Associations &associations, AstrometryModel *astrometryModel, double posError) | |
this is the only constructor More... | |
unsigned | minimize (const std::string &whatToFit, const double nSigRejCut=0) |
Does a 1 step minimization, assuming a linear model. More... | |
void | LSDerivatives1 (const CcdImage &ccdImage, TripletList &tList, Eigen::VectorXd &rhs, const MeasuredStarList *msList=nullptr) const |
Compute derivatives of measurement terms for this CcdImage. More... | |
void | LSDerivatives2 (const FittedStarList &fsl, TripletList &tList, Eigen::VectorXd &rhs) const |
Compute derivatives of reference terms (if any), associated to the FittedStarList. More... | |
void | LSDerivatives (TripletList &tList, Eigen::VectorXd &rhs) const |
Evaluates the chI^2 derivatives (Jacobian and gradient) for the current whatToFit setting. More... | |
void | assignIndices (const std::string &whatToFit) |
Set parameter groups fixed or variable and assign indices to each parameter in the big matrix (which will be used by offsetParams(...). More... | |
void | freezeErrorScales () |
The transformations used to propagate errors are freezed to the current state. More... | |
void | offsetParams (const Eigen::VectorXd &delta) |
Offset the parameters by the requested quantities. More... | |
Chi2 | computeChi2 () const |
Returns a chi2 for the current state. More... | |
void | outliersContributions (MeasuredStarList &mOutliers, FittedStarList &fOutLiers, TripletList &tList, Eigen::VectorXd &grad) |
Contributions to derivatives from (presumably) outlier terms. More... | |
unsigned | removeOutliers (double nSigmaCut, const std::string &measOrRef="Meas Ref") |
Discards measurements and reference contributions contributing to the chi2 more than nSigmaCut, computed as:
\[ <chi2> + nSigmaCut + rms(chi2) \] (statistics over contributions to the chi2). More... | |
unsigned | findOutliers (double nSigmaCut, MeasuredStarList &mSOutliers, FittedStarList &fSOutliers, const std::string &measOrRef="Meas Ref") const |
Find Measurements and references contributing more than a cut, computed as
\[ <chi2> + nSigmaCut + rms(chi2). \] The outliers are NOT removed, and no refit is done. More... | |
void | removeMeasOutliers (MeasuredStarList &outliers) |
Just removes outliers from the fit. No Refit done. More... | |
void | removeRefOutliers (FittedStarList &outliers) |
Just removes outliers from the fit. No Refit done. More... | |
void | makeResTuple (const std::string &tupleName) const |
Produces both ntuples (cook up names from the provided string) More... | |
void | makeMeasResTuple (const std::string &tupleName) const |
Produces a tuple containing residuals of measurement terms. More... | |
void | makeRefResTuple (const std::string &tupleName) const |
Produces a tuple containing residuals of reference terms. More... | |
void | checkStuff () |
DEBUGGING routine. More... | |
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.
Definition at line 55 of file AstrometryFit.h.
lsst::jointcal::AstrometryFit::AstrometryFit | ( | Associations & | associations, |
AstrometryModel * | astrometryModel, | ||
double | posError | ||
) |
this is the only constructor
Definition at line 141 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::assignIndices | ( | const std::string & | whatToFit | ) |
Set parameter groups fixed or variable and assign indices to each parameter in the big matrix (which will be used by offsetParams(...).
[in] | whatToFit | Valid strings: "Distortions", "Positions", "Refrac", "PM" which define which parameter set is going to be variable when computing derivatives (LSDerivatives) and minimizing (minimize()). |
Definition at line 725 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::checkStuff | ( | ) |
DEBUGGING routine.
Definition at line 909 of file AstrometryFit.cc.
Chi2 lsst::jointcal::AstrometryFit::computeChi2 | ( | ) | const |
Returns a chi2 for the current state.
For the list of images in the provided association and the reference stars, if any.
Definition at line 546 of file AstrometryFit.cc.
unsigned lsst::jointcal::AstrometryFit::findOutliers | ( | double | nSigmaCut, |
MeasuredStarList & | mSOutliers, | ||
FittedStarList & | fSOutliers, | ||
const std::string & | measOrRef = "Meas Ref" |
||
) | const |
Find Measurements and references contributing more than a cut, computed as
\[ <chi2> + nSigmaCut + rms(chi2). \]
The outliers are NOT removed, and no refit is done.
After returning from here, there are still measurements that contribute above the cut, but their contribution should be evaluated after a refit before discarding them.
[in] | nSigmaCut | Number of sigma to select on. |
[out] | mSOutliers | list of MeasuredStar outliers to populate |
[out] | fSOutliers | list of FittedStar outliers to populate |
[in] | measOrRef | Which outliers to remove. One of "Meas", "Ref" or "Meas Ref". |
Definition at line 621 of file AstrometryFit.cc.
|
inline |
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.
Definition at line 143 of file AstrometryFit.h.
void lsst::jointcal::AstrometryFit::LSDerivatives | ( | TripletList & | tList, |
Eigen::VectorXd & | rhs | ||
) | const |
Evaluates the chI^2 derivatives (Jacobian and gradient) for the current whatToFit setting.
this routine computes the derivatives of all LS terms, including the ones that refer to references stars, if any
The Jacobian is provided as triplets, the gradient as a dense vector. The parameters which vary are to be set using assignIndices.
Definition at line 449 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::LSDerivatives1 | ( | const CcdImage & | ccdImage, |
TripletList & | tList, | ||
Eigen::VectorXd & | rhs, | ||
const MeasuredStarList * | msList = nullptr |
||
) | const |
Compute derivatives of measurement terms for this CcdImage.
Changes in this routine should be reflected into accumulateStatImage
Definition at line 210 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::LSDerivatives2 | ( | const FittedStarList & | fsl, |
TripletList & | tList, | ||
Eigen::VectorXd & | rhs | ||
) | const |
Compute derivatives of reference terms (if any), associated to the FittedStarList.
Definition at line 357 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::makeMeasResTuple | ( | const std::string & | tupleName | ) | const |
Produces a tuple containing residuals of measurement terms.
Definition at line 955 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::makeRefResTuple | ( | const std::string & | tupleName | ) | const |
Produces a tuple containing residuals of reference terms.
Definition at line 1013 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::makeResTuple | ( | const std::string & | tupleName | ) | const |
Produces both ntuples (cook up names from the provided string)
Definition at line 941 of file AstrometryFit.cc.
unsigned lsst::jointcal::AstrometryFit::minimize | ( | const std::string & | whatToFit, |
const double | nSigRejCut = 0 |
||
) |
Does a 1 step minimization, assuming a linear model.
It calls assignIndices, LSDerivatives, solves the linear system and calls offsetParams. No line search. Relies on sparse linear algebra.
This is a complete Newton Raphson step. Compute first and second derivatives, solve for the step and apply it, without a line search.
[in] | whatToFit | Valid strings: "Distortions", "Positions", "Refrac", "PM" which define which parameter set is going to be variable when computing derivatives (LSDerivatives) 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. |
[in] | nSigRejCut | How many sigma to reject outliers at. Outlier rejection ignored for nSigRejCut=0 |
Definition at line 816 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::offsetParams | ( | const Eigen::VectorXd & | 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.
[in] | delta | vector of offsets to apply |
Definition at line 764 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::outliersContributions | ( | MeasuredStarList & | mOutliers, |
FittedStarList & | fOutLiers, | ||
TripletList & | tList, | ||
Eigen::VectorXd & | grad | ||
) |
Contributions to derivatives from (presumably) outlier terms.
contributions to derivatives of (presumambly) outlier terms. No discarding done.
No discarding done.
Definition at line 600 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::removeMeasOutliers | ( | MeasuredStarList & | outliers | ) |
Just removes outliers from the fit. No Refit done.
Definition at line 709 of file AstrometryFit.cc.
unsigned lsst::jointcal::AstrometryFit::removeOutliers | ( | double | nSigmaCut, |
const std::string & | measOrRef = "Meas Ref" |
||
) |
Discards measurements and reference contributions contributing to the chi2 more than nSigmaCut, computed as:
\[ <chi2> + nSigmaCut + rms(chi2) \]
(statistics over contributions to the chi2).
No refit done.
[in] | nSigmaCut | Number of sigma to cut on. |
[in] | measOrRef | Which outliers to remove. One of "Meas", "Ref" or "Meas Ref". |
Definition at line 612 of file AstrometryFit.cc.
void lsst::jointcal::AstrometryFit::removeRefOutliers | ( | FittedStarList & | outliers | ) |
Just removes outliers from the fit. No Refit done.
Definition at line 718 of file AstrometryFit.cc.