gastro  0.1.0
 All Classes Files Functions Variables Pages
Classes | Public Member Functions | List of all members
AstromFit Class Reference

#include <astromfit.h>

Classes

struct  Chi2
 Simple structure to accumulate Chi2 and Ndof. More...
 

Public Member Functions

 AstromFit (Associations &A, DistortionModel *D)
 this is the only constructor
 
bool Minimize (const std::string &WhatToFit)
 Does a 1 step minimization, assuming a linear model. More...
 
void LSDerivatives (const CcdImage &Ccd, TripletList &TList, Eigen::VectorXd &Rhs) const
 
void LSDerivatives (const CcdImageList &L, TripletList &TList, Eigen::VectorXd &Rhs)
 
void LSDerivatives (TripletList &TList, Eigen::VectorXd &Rhs)
 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 OffsetParams (const Eigen::VectorXd &Delta)
 Offsest the parameters by the requested quantities. The used parameter layout is the one from the last call to AssignIndices or Minimize(). More...
 
Chi2 ComputeChi2 () const
 Returns a chi2 for the current state. More...
 
unsigned RemoveOutliers (const double &NSigCut)
 Discards measurements contributing more than a cut, computed as <chi2>+NSigCut+rms(chi2). Returns the number of removed outliers. No refit done. More...
 
void MakeResTuple (const std::string &TupleName) const
 Produces a tuple containing residuals of measurements.
 
std::vector< double > RefractionCoefficients () const
 access to the fitted refraction coefficients. Unit depends on scale in the tangentPlane. Degrees for an actual tangent plane.
 
 AstromFit (Associations &A)
 
bool Minimize (const FitKind, const int MaxIter=0)
 
void SetStarIndexes ()
 
double ComputeChi2 ()
 
void PrintChi2 (const std::string &Message) const
 
GeomParam & GetGeomParam (const CcdImage &ccdImage) const
 
void SaveResults (const std::string &Tag)
 

Detailed Description

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 grandient of the chi2 (w.r.t. parameters), and the Chi2 itself. It interfaces with the actual modelling of distortions via a mimimum virtual interface DistortionModel, and the actual mappings via an other virtual interface : Mapping.

In short AstromFit 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.

Member Function Documentation

void AstromFit::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(...).

WhatToFit is searched for strings : "Distortions", "Pos", "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 DistortionModel, and it can then be used to turn subsets of distortion parameter on or off, if the DistortionModel implements such a thing.

AstromFit::Chi2 AstromFit::ComputeChi2 ( ) const

Returns a chi2 for the current state.

for the list of images in the provided association and the reference stars, if any

void AstromFit::LSDerivatives ( const CcdImage Ccd,
TripletList &  TList,
Eigen::VectorXd &  Rhs 
) const

Changes in this routine should be reflected into AccumulateStatImage

void AstromFit::LSDerivatives ( TripletList &  TList,
Eigen::VectorXd &  Rhs 
)

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 parameter which vary are to be set using AssignIndices.

bool AstromFit::Minimize ( const std::string &  WhatToFit)

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.

void AstromFit::OffsetParams ( const Eigen::VectorXd &  Delta)

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

unsigned AstromFit::RemoveOutliers ( const double &  NSigCut)

Discards measurements contributing more than a cut, computed as <chi2>+NSigCut+rms(chi2). Returns the number of removed outliers. No refit done.

After returning form here, there are still measurements that contribute above the cut, but their contribution should be evaluated after a refit before discarding them .


The documentation for this class was generated from the following files: