gastro  0.1.0
 All Classes Files Functions Variables Pages
astromfit.h
1 #ifndef ASTROMFIT__H
2 #define ASTROMFIT__H
3 
4 #include <string>
5 #include <iostream>
6 #include <map>
7 
8 #include "ccdimage.h"
9 
10 #include "eigenstuff.h"
11 #include "tripletlist.h"
12 #include "distortionmodel.h"
13 
14 class Associations;
15 class DistortionModel;
16 
53 class AstromFit {
54  private :
55 
56  Associations &_assoc;
57  std::string _WhatToFit;
58  bool _fittingDistortions, _fittingPos, _fittingRefrac, _fittingPM;
59  DistortionModel * _distortionModel;
60  int _LastNTrip; // last triplet count, used to speed up allocation
61  double _referenceColor; // average color
62  unsigned _nRefrac;
63  std::vector<double> _refracCoefficient; // fit parameter
64  unsigned int _refracPosInMatrix; // where it stands
65  double _JDRef; // average Julian date
66 
67  // counts in parameter subsets.
68  unsigned int _nParDistortions;
69  // unsigned int _nParStars; unused presently
70  unsigned int _nParTot;
71  unsigned _nMeasuredStars;
72 
73  public :
74 
77 
79 
82  bool Minimize(const std::string &WhatToFit);
83 
85  void LSDerivatives(const CcdImage &Ccd,
86  TripletList &TList, Eigen::VectorXd &Rhs) const;
87 
88  void LSDerivatives(const CcdImageList &L,
89  TripletList &TList, Eigen::VectorXd &Rhs);
90 
92 
95  void LSDerivatives(TripletList &TList, Eigen::VectorXd &Rhs);
96 
98  void AssignIndices(const std::string &WhatToFit);
99 
100 
102 
105  void OffsetParams(const Eigen::VectorXd &Delta);
106 
108  struct Chi2
109  {
110  double chi2;
111  unsigned ndof;
112  Chi2() : chi2(0), ndof(0) {};
113  friend std::ostream& operator << (std::ostream& s, const Chi2 &C)
114  {
115  s << "Chi2/ndof : " << C.chi2 << '/' << C.ndof << '=' << C.chi2/C.ndof; return s;
116  }
117 
118  // Addentry has a third argument in order to make it compatible with an
119  //other stat accumulator.
120  void AddEntry(double Inc, unsigned Dof, const MeasuredStar *M)
121  {chi2+= Inc; ndof += Dof;}
122 
123  void operator += (const Chi2 &R)
124  {chi2 += R.chi2; ndof += R.ndof;}
125 
126  }; // end of struct Chi2
127 
129  Chi2 ComputeChi2() const;
130 
132  unsigned RemoveOutliers(const double &NSigCut);
133 
135  void MakeResTuple(const std::string &TupleName) const;
136 
138  std::vector<double> RefractionCoefficients() const
139  { return _refracCoefficient;}
140 
141  private :
142 
143  Point TransformFittedStar(const FittedStar &F,
144  const Gtransfo * Sky2TP,
145  const Point &RefractionVector,
146  const double RefractionCoeff,
147  const double Jd) const;
148 
149  template <class ListType, class Accum>
150  void AccumulateStatImageList(ListType &L, Accum &A) const;
151 
152  template <class ImType, class Accum>
153  void AccumulateStatImage(ImType &I, Accum &A) const;
154 
156  void GetMeasuredStarIndices(const MeasuredStar &Ms,
157  std::vector<unsigned> &Indices) const;
158 
159 };
160 
161 
162 #endif /* ASTROMFIT__H */
Chi2 ComputeChi2() const
Returns a chi2 for the current state.
Definition: astromfit.cc:410
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.
Definition: astromfit.cc:497
void AssignIndices(const std::string &WhatToFit)
Set parameter groups fixed or variable and assign indices to each parameter in the big matrix (which ...
Definition: astromfit.cc:576
Definition: astromfit.h:53
void LSDerivatives(const CcdImage &Ccd, TripletList &TList, Eigen::VectorXd &Rhs) const
Definition: astromfit.cc:100
The class that implements the relations between MeasuredStar and FittedStar.
Definition: associations.h:17
handler of an actual image from a single CCD
Definition: ccdimage.h:21
Interface class between AstromFit and an actual model for the Mapping (s) from pixels to some tangent...
Definition: distortionmodel.h:13
bool Minimize(const std::string &WhatToFit)
Does a 1 step minimization, assuming a linear model.
Definition: astromfit.cc:673
void MakeResTuple(const std::string &TupleName) const
Produces a tuple containing residuals of measurements.
Definition: astromfit.cc:746
Simple structure to accumulate Chi2 and Ndof.
Definition: astromfit.h:108
std::vector< double > RefractionCoefficients() const
access to the fitted refraction coefficients. Unit depends on scale in the tangentPlane. Degrees for an actual tangent plane.
Definition: astromfit.h:138
The objects which have been measured several times. The MeasuredStar s measuring the same object in d...
Definition: fittedstar.h:37
void OffsetParams(const Eigen::VectorXd &Delta)
Offsest the parameters by the requested quantities. The used parameter layout is the one from the las...
Definition: astromfit.cc:619
objects measured on actual images. Coordinates and uncertainties are expressed in pixel image frame...
Definition: measuredstar.h:21
AstromFit(Associations &A, DistortionModel *D)
this is the only constructor
Definition: astromfit.cc:20