lsst.jointcal  master-gc935ebf72c+13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AstrometryFit.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_ASTROMETRY_FIT_H
3 #define LSST_JOINTCAL_ASTROMETRY_FIT_H
4 
5 #include <string>
6 #include <iostream>
7 #include <sstream>
8 
13 #include "lsst/jointcal/Chi2.h"
14 
15 namespace lsst {
16 namespace jointcal {
17 
18 class Associations;
19 
56 private:
57  Associations &_assoc;
58  std::string _whatToFit;
59  bool _fittingDistortions, _fittingPos, _fittingRefrac, _fittingPM;
60  AstrometryModel *_astrometryModel;
61  int _LastNTrip; // last triplet count, used to speed up allocation
62  double _referenceColor, _sigCol; // average and r.m.s color
63  unsigned _nRefrac;
64  double _refractionCoefficient; // fit parameter
65  unsigned int _refracPosInMatrix; // where it stands
66  double _JDRef; // average Julian date
67 
68  // counts in parameter subsets.
69  unsigned int _nParDistortions;
70  unsigned int _nParPositions;
71  unsigned int _nParTot;
72  unsigned _nMeasuredStars;
73  double _posError; // constant term on error on position (in pixel unit)
74 
75 public:
77  AstrometryFit(Associations &associations, AstrometryModel *astrometryModel, double posError);
78 
110  unsigned minimize(const std::string &whatToFit, const double nSigRejCut = 0);
111 
113  void LSDerivatives1(const CcdImage &ccdImage, TripletList &tList, Eigen::VectorXd &rhs,
114  const MeasuredStarList *msList = nullptr) const;
115 
117  void LSDerivatives2(const FittedStarList &fsl, TripletList &tList, Eigen::VectorXd &rhs) const;
118 
120 
123  void LSDerivatives(TripletList &tList, Eigen::VectorXd &rhs) const;
124 
134  void assignIndices(const std::string &whatToFit);
135 
143  void freezeErrorScales() { _astrometryModel->freezeErrorScales(); }
144 
153  void offsetParams(const Eigen::VectorXd &delta);
154 
161  Chi2 computeChi2() const;
162 
167  void outliersContributions(MeasuredStarList &mOutliers, FittedStarList &fOutLiers, TripletList &tList,
168  Eigen::VectorXd &grad);
169 
184  unsigned removeOutliers(double nSigmaCut, const std::string &measOrRef = "Meas Ref");
185 
204  unsigned findOutliers(double nSigmaCut, MeasuredStarList &mSOutliers, FittedStarList &fSOutliers,
205  const std::string &measOrRef = "Meas Ref") const;
206 
208  void removeMeasOutliers(MeasuredStarList &outliers);
209 
211  void removeRefOutliers(FittedStarList &outliers);
212 
214  void makeResTuple(const std::string &tupleName) const;
215 
217  void makeMeasResTuple(const std::string &tupleName) const;
218 
220  void makeRefResTuple(const std::string &tupleName) const;
221 
225  void checkStuff();
226 
227 private:
228  Point transformFittedStar(const FittedStar &fittedStar, const Gtransfo *sky2TP,
229  const Point &refractionVector, double refractionCoeff, double mjd) const;
230 
231  template <class ListType, class Accum>
232  void accumulateStatImageList(ListType &list, Accum &accum) const;
233 
234  template <class ImType, class Accum>
235  void accumulateStatImage(ImType &image, Accum &accum) const;
236 
237  template <class Accum>
238  void accumulateStatRefStars(Accum &accum) const;
239 
241  void setMeasuredStarIndices(const MeasuredStar &ms, std::vector<unsigned> &indices) const;
242 };
243 } // namespace jointcal
244 } // namespace lsst
245 #endif // LSST_JOINTCAL_ASTROMETRY_FIT_H
void outliersContributions(MeasuredStarList &mOutliers, FittedStarList &fOutLiers, TripletList &tList, Eigen::VectorXd &grad)
Contributions to derivatives from (presumably) outlier terms.
void makeMeasResTuple(const std::string &tupleName) const
Produces a tuple containing residuals of measurement terms.
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 The outliers are NOT remo...
void makeResTuple(const std::string &tupleName) const
Produces both ntuples (cook up names from the provided string)
A point in a plane.
Definition: Point.h:13
void freezeErrorScales()
The transformations used to propagate errors are freezed to the current state.
void LSDerivatives(TripletList &tList, Eigen::VectorXd &rhs) const
Evaluates the chI^2 derivatives (Jacobian and gradient) for the current whatToFit setting...
Interface class between AstrometryFit and an actual model for the Mapping (s) from pixels to some tan...
unsigned removeOutliers(double nSigmaCut, const std::string &measOrRef="Meas Ref")
Discards measurements and reference contributions contributing to the chi2 more than nSigmaCut...
void removeMeasOutliers(MeasuredStarList &outliers)
Just removes outliers from the fit. No Refit done.
The class that implements the relations between MeasuredStar and FittedStar.
Definition: Associations.h:28
void LSDerivatives1(const CcdImage &ccdImage, TripletList &tList, Eigen::VectorXd &rhs, const MeasuredStarList *msList=nullptr) const
Compute derivatives of measurement terms for this CcdImage.
unsigned minimize(const std::string &whatToFit, const double nSigRejCut=0)
Does a 1 step minimization, assuming a linear model.
A list of MeasuredStar. They are usually filled in Associations::AddImage.
Definition: MeasuredStar.h:71
Simple structure to accumulate Chi2 and Ndof.
Definition: Chi2.h:13
void makeRefResTuple(const std::string &tupleName) const
Produces a tuple containing residuals of reference terms.
virtual void freezeErrorScales()=0
A list of FittedStar s. Such a list is typically constructed by Associations.
Definition: FittedStar.h:134
Chi2 computeChi2() const
Returns a chi2 for the current state.
objects measured on actual images.
Definition: MeasuredStar.h:18
void assignIndices(const std::string &whatToFit)
Set parameter groups fixed or variable and assign indices to each parameter in the big matrix (which ...
void removeRefOutliers(FittedStarList &outliers)
Just removes outliers from the fit. No Refit done.
AstrometryFit(Associations &associations, AstrometryModel *astrometryModel, double posError)
this is the only constructor
Class that handles the astrometric least squares problem.
Definition: AstrometryFit.h:55
a virtual (interface) class for geometric transformations.
Definition: Gtransfo.h:37
Handler of an actual image from a single CCD.
Definition: CcdImage.h:31
void checkStuff()
DEBUGGING routine.
void offsetParams(const Eigen::VectorXd &delta)
Offset the parameters by the requested quantities.
The objects which have been measured several times.
Definition: FittedStar.h:34
void LSDerivatives2(const FittedStarList &fsl, TripletList &tList, Eigen::VectorXd &rhs) const
Compute derivatives of reference terms (if any), associated to the FittedStarList.