lsst.jointcal  master-gc935ebf72c+13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Gtransfo.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_GTRANSFO_H
3 #define LSST_JOINTCAL_GTRANSFO_H
4 
5 #include <iostream>
6 #include <string>
7 #include <sstream>
8 #include <vector>
9 
10 #include "lsst/pex/exceptions.h"
11 #include "lsst/jointcal/FatPoint.h"
12 
13 namespace pexExcept = lsst::pex::exceptions;
14 
15 namespace lsst {
16 namespace jointcal {
17 
18 class StarMatchList;
19 class Frame;
20 class GtransfoLin;
21 
23 
37 class Gtransfo {
38 public:
40  virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const = 0;
41 
43  void apply(const Point &in, Point &out) const { apply(in.x, in.y, out.x, out.y); }
44 
47  Point apply(const Point &in) const {
48  double xout, yout;
49  apply(in.x, in.y, xout, yout);
50  return Point(xout, yout);
51  }
52 
54  virtual void dump(std::ostream &stream = std::cout) const = 0;
55 
56  std::string __str__() {
57  std::stringstream s;
58  dump(s);
59  return s.str();
60  }
61 
63 
67  virtual double fit(const StarMatchList &starMatchList) = 0;
68 
70  void transformStar(FatPoint &in) const { transformPosAndErrors(in, in); }
71 
73  virtual double getJacobian(const Point &point) const { return getJacobian(point.x, point.y); }
74 
76  virtual std::unique_ptr<Gtransfo> clone() const = 0;
77 
80  virtual std::unique_ptr<Gtransfo> reduceCompo(const Gtransfo *right) const;
81 
83  virtual double getJacobian(const double x, const double y) const;
84 
86  virtual void computeDerivative(const Point &where, GtransfoLin &derivative,
87  const double step = 0.01) const;
88 
90  virtual GtransfoLin linearApproximation(const Point &where, const double step = 0.01) const;
91 
92  virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const;
93 
95  virtual void transformErrors(const Point &where, const double *vIn, double *vOut) const;
96 
98 
100  virtual std::unique_ptr<Gtransfo> inverseTransfo(const double precision, const Frame &region) const;
101 
103  void getParams(double *params) const;
104 
106  void offsetParams(const double *params);
107 
109  virtual double paramRef(const int i) const;
110 
112  virtual double &paramRef(const int i);
113 
116  virtual void paramDerivatives(const Point &where, double *dx, double *dy) const;
117 
119 
121  virtual std::unique_ptr<Gtransfo> roughInverse(const Frame &region) const;
122 
124  virtual int getNpar() const { return 0; }
125 
126  void write(const std::string &fileName) const;
127 
128  virtual void write(std::ostream &stream) const;
129 
130  virtual ~Gtransfo(){};
131 };
132 
134 std::ostream &operator<<(std::ostream &stream, const Gtransfo &gtransfo);
135 
138 
139 std::unique_ptr<Gtransfo> gtransfoCompose(const Gtransfo *left, const Gtransfo *right);
140 
141 /*=============================================================*/
143 
144 class GtransfoIdentity : public Gtransfo {
145 public:
148 
150  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const {
151  xOut = xIn;
152  yOut = yIn;
153  }; // to speed up
154 
155  double fit(const StarMatchList &starMatchList) {
156  throw pexExcept::TypeError(
157  "GtransfoIdentity is the identity transformation: it cannot be fit to anything.");
158  }
159 
160  std::unique_ptr<Gtransfo> reduceCompo(const Gtransfo *right) const { return right->clone(); }
161  void dump(std::ostream &stream = std::cout) const { stream << "x' = x\ny' = y" << std::endl; }
162 
163  int getNpar() const { return 0; }
164  std::unique_ptr<Gtransfo> clone() const { return std::unique_ptr<Gtransfo>(new GtransfoIdentity); }
165 
166  void computeDerivative(const Point &where, GtransfoLin &derivative, const double step = 0.01) const;
167 
169  virtual GtransfoLin linearApproximation(const Point &where, const double step = 0.01) const;
170 
171  void write(std::ostream &s) const;
172 
173  void read(std::istream &s);
174 
175  // ClassDef(GtransfoIdentity,1)
176 };
177 
179 bool isIdentity(const Gtransfo *gtransfo);
180 
182 bool isIntegerShift(const Gtransfo *gtransfo);
183 
184 /*==================== GtransfoPoly =======================*/
185 
187 class GtransfoPoly : public Gtransfo {
188 public:
189  using Gtransfo::apply; // to unhide Gtransfo::apply(const Point &)
190 
191 private:
192  unsigned _degree; // the degree
193  unsigned _nterms; // number of parameters per coordinate
194  std::vector<double> _coeffs; // the actual coefficients
195  // both polynomials in a single vector to speed up allocation and copies
196 
197  /* use std::vector rather than double * to avoid
198  writing copy constructor and "operator =".
199  Vect would work as well but introduces a dependence
200  that can be avoided */
201 
202  /* This routine take a double * for the vector because the array can
203  then be allocated on the execution stack, which speeds thing
204  up. However this uses Variable Length Array (VLA) which is not
205  part of C++, but gcc implements it. */
206  void computeMonomials(double xIn, double yIn, double *monomial) const;
207 
208 public:
211  GtransfoPoly(const unsigned degree = 1);
212 
214  GtransfoPoly(const Gtransfo *gtransfo, const Frame &frame, unsigned degree, unsigned nPoint = 1000);
215 
216  // sets the polynomial degree.
217  void setDegree(const unsigned degree);
218 
219  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
220 
222  void computeDerivative(const Point &where, GtransfoLin &derivative, const double step = 0.01) const;
223 
225  virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const;
226 
228  unsigned getDegree() const { return _degree; }
229 
231  int getNpar() const { return 2 * _nterms; }
232 
234  void dump(std::ostream &stream = std::cout) const;
235 
237  double fit(const StarMatchList &starMatchList);
238 
240  GtransfoPoly operator*(const GtransfoPoly &right) const;
241 
243  GtransfoPoly operator+(const GtransfoPoly &right) const;
244 
246  GtransfoPoly operator-(const GtransfoPoly &right) const;
247 
248  std::unique_ptr<Gtransfo> reduceCompo(const Gtransfo *right) const;
249 
250  std::unique_ptr<Gtransfo> clone() const { return std::unique_ptr<Gtransfo>(new GtransfoPoly(*this)); }
251 
253  double coeff(const unsigned powX, const unsigned powY, const unsigned whichCoord) const;
254 
256  double &coeff(const unsigned powX, const unsigned powY, const unsigned whichCoord);
257 
259  double coeffOrZero(const unsigned powX, const unsigned powY, const unsigned whichCoord) const;
260 
261  double determinant() const;
262 
264  double paramRef(const int i) const;
265 
267  double &paramRef(const int i);
268 
271  void paramDerivatives(const Point &where, double *dx, double *dy) const;
272 
273  void write(std::ostream &s) const;
274  void read(std::istream &s);
275 
276 private:
277  double computeFit(const StarMatchList &starMatchList, const Gtransfo &InTransfo, const bool UseErrors);
278 };
279 
281 std::unique_ptr<GtransfoPoly> inversePolyTransfo(const Gtransfo &Direct, const Frame &frame,
282  const double Prec);
283 
284 GtransfoLin normalizeCoordinatesTransfo(const Frame &frame);
285 
286 /*=============================================================*/
288 class GtransfoLin : public GtransfoPoly {
289 public:
290  using GtransfoPoly::apply; // to unhide Gtransfo::apply(const Point &)
291 
294 
296  explicit GtransfoLin(const GtransfoPoly &gtransfoPoly);
297 
299  GtransfoLin operator*(const GtransfoLin &right) const;
300 
302  GtransfoLin invert() const;
303 
304  // useful? double jacobian(const double x, const double y) const { return determinant();}
305 
307  void computeDerivative(const Point &where, GtransfoLin &derivative, const double step = 0.01) const;
309  GtransfoLin linearApproximation(const Point &where, const double step = 0.01) const;
310 
311  // void dump(std::ostream &stream = std::cout) const;
312 
313  // double fit(const StarMatchList &starMatchList);
314 
316  GtransfoLin(const double ox, const double oy, const double aa11, const double aa12, const double aa21,
317  const double aa22);
318 
321 
322  std::unique_ptr<Gtransfo> clone() const { return std::unique_ptr<Gtransfo>(new GtransfoLin(*this)); }
323 
324  std::unique_ptr<Gtransfo> inverseTransfo(const double precision, const Frame &region) const;
325 
326  double A11() const { return coeff(1, 0, 0); }
327  double A12() const { return coeff(0, 1, 0); }
328  double A21() const { return coeff(1, 0, 1); }
329  double A22() const { return coeff(0, 1, 1); }
330  double Dx() const { return coeff(0, 0, 0); }
331  double Dy() const { return coeff(0, 0, 1); }
332 
333 protected:
334  double &a11() { return coeff(1, 0, 0); }
335  double &a12() { return coeff(0, 1, 0); }
336  double &a21() { return coeff(1, 0, 1); }
337  double &a22() { return coeff(0, 1, 1); }
338  double &dx() { return coeff(0, 0, 0); }
339  double &dy() { return coeff(0, 0, 1); }
340 
341  friend class Gtransfo;
342  friend class GtransfoIdentity; // for Gtransfo::Derivative
343  friend class GtransfoPoly; // // for Gtransfo::Derivative
344 
345 private:
346  void setDegree(const unsigned degree); // to hide GtransfoPoly::setDegree
347 };
348 
349 /*=============================================================*/
350 
353 public:
354  using Gtransfo::apply; // to unhide Gtransfo::apply(const Point &)
356  GtransfoLinShift(double ox = 0., double oy = 0.) : GtransfoLin(ox, oy, 1., 0., 0., 1.) {}
357  GtransfoLinShift(const Point &point) : GtransfoLin(point.x, point.y, 1., 0., 0., 1.){};
358  double fit(const StarMatchList &starMatchList);
359 
360  int getNpar() const { return 2; }
361 };
362 
363 /*=============================================================*/
365 class GtransfoLinRot : public GtransfoLin {
366 public:
367  using Gtransfo::apply; // to unhide apply(const Point&)
368 
370  GtransfoLinRot(const double angleRad, const Point *center = nullptr, const double scaleFactor = 1.0);
371  double fit(const StarMatchList &starMatchList);
372 
373  int getNpar() const { return 4; }
374 };
375 
376 /*=============================================================*/
377 
380 public:
381  using Gtransfo::apply; // to unhide apply(const Point&)
383  GtransfoLinScale(const double scale = 1) : GtransfoLin(0.0, 0.0, scale, 0., 0., scale){};
385  GtransfoLinScale(const double scaleX, const double scaleY)
386  : GtransfoLin(0.0, 0.0, scaleX, 0., 0., scaleY){};
387 
388  int getNpar() const { return 2; }
389 };
390 
391 /*==================WCS's transfo's =====================================*/
392 
393 class BaseTanWcs : public Gtransfo {
394 protected:
395  GtransfoLin linPix2Tan; // pixels to tangent plane (internally in radians)
396  std::unique_ptr<GtransfoPoly> corr;
397  double ra0, dec0; // in radians
398  double cos0, sin0; // cos(dec0), sin(dec0)
399 
400 public:
401  using Gtransfo::apply; // to unhide apply(const Point&)
402 
403  BaseTanWcs(const GtransfoLin &pix2Tan, const Point &tangentPoint,
404  const GtransfoPoly *corrections = nullptr);
405 
406  BaseTanWcs(const BaseTanWcs &original);
407 
408  void operator=(const BaseTanWcs &original);
409 
410  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
411 
413  Point getTangentPoint() const;
414 
416  GtransfoLin getLinPart() const;
417 
419  const GtransfoPoly *getCorr() const { return corr.get(); }
420 
422  void setCorrections(std::unique_ptr<GtransfoPoly> corrections);
423 
425  Point getCrPix() const;
426 
428  virtual GtransfoPoly getPix2TangentPlane() const = 0;
429 
431  virtual void pix2TP(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const = 0;
432 
433  ~BaseTanWcs();
434 };
435 
436 class TanRaDec2Pix; // the inverse of TanPix2RaDec.
437 
439 class TanPix2RaDec : public BaseTanWcs {
440 public:
441  using Gtransfo::apply; // to unhide apply(const Point&)
444  TanPix2RaDec(const GtransfoLin &pix2Tan, const Point &tangentPoint,
445  const GtransfoPoly *corrections = nullptr);
446 
449 
451  virtual void pix2TP(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const;
452 
453  TanPix2RaDec();
454 
456  TanPix2RaDec operator*(const GtransfoLin &right) const;
457 
458  std::unique_ptr<Gtransfo> reduceCompo(const Gtransfo *right) const;
459 
461  TanRaDec2Pix invert() const;
462 
464  std::unique_ptr<Gtransfo> roughInverse(const Frame &region) const;
465 
468  std::unique_ptr<Gtransfo> inverseTransfo(const double precision, const Frame &region) const;
469 
470  std::unique_ptr<Gtransfo> clone() const;
471 
472  void dump(std::ostream &stream) const;
473 
475  double fit(const StarMatchList &starMatchList);
476 };
477 
479 class TanSipPix2RaDec : public BaseTanWcs {
480 public:
483  TanSipPix2RaDec(const GtransfoLin &pix2Tan, const Point &tangentPoint,
484  const GtransfoPoly *corrections = nullptr);
485 
488 
490  virtual void pix2TP(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const;
491 
492  TanSipPix2RaDec();
493 
496  std::unique_ptr<Gtransfo> inverseTransfo(const double precision, const Frame &region) const;
497 
498  std::unique_ptr<Gtransfo> clone() const;
499 
500  void dump(std::ostream &stream) const;
501 
503  double fit(const StarMatchList &starMatchList);
504 };
505 
507 
513 class TanRaDec2Pix : public Gtransfo {
514  double ra0, dec0; // tangent point (internally in radians)
515  double cos0, sin0;
516  GtransfoLin linTan2Pix; // tangent plane to pixels (internally in radians)
517 
518 public:
519  using Gtransfo::apply; // to unhide apply(const Point&)
520 
522  TanRaDec2Pix(const GtransfoLin &tan2Pix, const Point &tangentPoint);
523 
525  TanRaDec2Pix();
526 
528  GtransfoLin getLinPart() const;
529 
531  void setTangentPoint(const Point &tangentPoint);
532 
534  Point getTangentPoint() const;
535 
537  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
538 
540  void transformPosAndErrors(const FatPoint &in, FatPoint &out) const;
541 
543  TanPix2RaDec invert() const;
544 
546  std::unique_ptr<Gtransfo> roughInverse(const Frame &region) const;
547 
549  std::unique_ptr<Gtransfo> inverseTransfo(const double precision, const Frame &region) const;
550 
551  void dump(std::ostream &stream) const;
552 
553  std::unique_ptr<Gtransfo> clone() const;
554 
555  double fit(const StarMatchList &starMatchList);
556 };
557 
559 typedef void(GtransfoFun)(const double, const double, double &, double &, const void *);
560 
562 class UserTransfo : public Gtransfo {
563 private:
564  GtransfoFun *_userFun;
565  const void *_userData;
566 
567 public:
568  using Gtransfo::apply; // to unhide apply(const Point&)
569 
571  UserTransfo(GtransfoFun &fun, const void *userData);
572 
573  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
574 
575  void dump(std::ostream &stream = std::cout) const;
576 
577  double fit(const StarMatchList &starMatchList);
578 
579  std::unique_ptr<Gtransfo> clone() const;
580 };
581 
583 std::unique_ptr<Gtransfo> gtransfoRead(const std::string &fileName);
585 std::unique_ptr<Gtransfo> gtransfoRead(std::istream &s);
586 } // namespace jointcal
587 } // namespace lsst
588 
589 #endif // LSST_JOINTCAL_GTRANSFO_H
GtransfoPoly operator-(const GtransfoPoly &right) const
Subtraction.
Definition: Gtransfo.cc:978
GtransfoLin linearApproximation(const Point &where, const double step=0.01) const
linear (local) approximation.
Definition: Gtransfo.cc:1088
void write(std::ostream &s) const
Definition: Gtransfo.cc:988
Implements the (forward) SIP distorsion scheme.
Definition: Gtransfo.h:479
implements the linear transformations (6 real coefficients).
Definition: Gtransfo.h:288
GtransfoPoly getPix2TangentPlane() const
the transformation from pixels to tangent plane (coordinates in degrees)
Definition: Gtransfo.cc:1326
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
a mix of apply and Derivative
Definition: Gtransfo.cc:567
GtransfoLin getLinPart() const
The Linear part (corresponding to CD&#39;s and CRPIX&#39;s)
Definition: Gtransfo.cc:1462
GtransfoPoly getPix2TangentPlane() const
the transformation from pixels to tangent plane (coordinates in degrees)
Definition: Gtransfo.cc:1394
virtual void transformErrors(const Point &where, const double *vIn, double *vOut) const
transform errors (represented as double[3] in order V(xx),V(yy),Cov(xy))
Definition: Gtransfo.cc:116
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.h:164
std::unique_ptr< Gtransfo > gtransfoCompose(const Gtransfo *left, const Gtransfo *right)
Returns a pointer to a composition.
Definition: Gtransfo.cc:367
virtual std::unique_ptr< Gtransfo > roughInverse(const Frame &region) const
Rough inverse.
Definition: Gtransfo.cc:149
unsigned getDegree() const
returns degree
Definition: Gtransfo.h:228
A point in a plane.
Definition: Point.h:13
GtransfoPoly operator+(const GtransfoPoly &right) const
Addition.
Definition: Gtransfo.cc:965
GtransfoLin(const GtransfoIdentity &)
Handy converter:
Definition: Gtransfo.h:320
the transformation that handles pix to sideral transfos (Gnomonic, possibly with polynomial distortio...
Definition: Gtransfo.h:439
void setCorrections(std::unique_ptr< GtransfoPoly > corrections)
Assign the correction polynomial (what it means is left to derived classes)
Definition: Gtransfo.cc:1270
GtransfoLinShift(double ox=0., double oy=0.)
Add ox and oy.
Definition: Gtransfo.h:356
int getNpar() const
total number of parameters
Definition: Gtransfo.h:231
virtual void pix2TP(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const
transforms from pixel space to tangent plane
Definition: Gtransfo.cc:1401
double A12() const
Definition: Gtransfo.h:327
double coeff(const unsigned powX, const unsigned powY, const unsigned whichCoord) const
access to coefficients (read only)
Definition: Gtransfo.cc:651
virtual void pix2TP(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const
transforms from pixel space to tangent plane
Definition: Gtransfo.cc:1333
void computeDerivative(const Point &where, GtransfoLin &derivative, const double step=0.01) const
specialised analytic routine
Definition: Gtransfo.cc:509
std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame &region) const
Inverse transfo: returns a TanRaDec2Pix if there are no corrections, or the iterative solver if there...
Definition: Gtransfo.cc:1389
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.cc:1581
virtual GtransfoLin linearApproximation(const Point &where, const double step=0.01) const
linear (local) approximation.
Definition: Gtransfo.cc:92
Point getTangentPoint() const
tangent point coordinates (in degrees)
Definition: Gtransfo.cc:1460
GtransfoLinScale(const double scale=1)
Definition: Gtransfo.h:383
void dump(std::ostream &stream=std::cout) const
dumps the transfo coefficients to stream.
Definition: Gtransfo.h:161
std::unique_ptr< Gtransfo > roughInverse(const Frame &region) const
Overload the &quot;generic routine&quot; (available for all Gtransfo types.
Definition: Gtransfo.cc:1543
std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame &region) const
returns an inverse transfo. Numerical if not overloaded.
Definition: Gtransfo.cc:1116
GtransfoLinShift(const Point &point)
Definition: Gtransfo.h:357
bool isIdentity(const Gtransfo *gtransfo)
Shorthand test to tell if a transfo belongs to the GtransfoIdentity class.
Definition: Gtransfo.cc:27
GtransfoLin operator*(const GtransfoLin &right) const
enables to combine linear tranformations: T1=T2*T3 is legal.
Definition: Gtransfo.cc:1067
virtual double fit(const StarMatchList &starMatchList)=0
fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
double fit(const StarMatchList &starMatchList)
Not implemented yet, because we do it otherwise.
Definition: Gtransfo.cc:1425
void dump(std::ostream &stream=std::cout) const
dumps the transfo coefficients to stream.
Definition: Gtransfo.cc:1571
virtual double getJacobian(const Point &point) const
returns the local jacobian.
Definition: Gtransfo.h:73
void dump(std::ostream &stream) const
dumps the transfo coefficients to stream.
Definition: Gtransfo.cc:1538
virtual GtransfoLin linearApproximation(const Point &where, const double step=0.01) const
linear approximation.
Definition: Gtransfo.cc:389
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
xOut = xIn; yOut = yIn !
Definition: Gtransfo.h:150
void write(const std::string &fileName) const
Definition: Gtransfo.cc:198
std::ostream & operator<<(std::ostream &stream, const Gtransfo &gtransfo)
allows &#39;stream &lt;&lt; Transfo;&#39; (by calling gtransfo.dump(stream)).
Definition: Gtransfo.cc:193
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.cc:1551
Polynomial transformation class.
Definition: Gtransfo.h:187
GtransfoLin normalizeCoordinatesTransfo(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
Definition: Gtransfo.cc:725
A Point with uncertainties.
Definition: FatPoint.h:11
virtual std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame &region) const
returns an inverse transfo. Numerical if not overloaded.
Definition: Gtransfo.cc:251
void dump(std::ostream &stream) const
dumps the transfo coefficients to stream.
Definition: Gtransfo.cc:1416
double fit(const StarMatchList &starMatchList)
fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
Definition: Gtransfo.cc:1555
void dump(std::ostream &stream) const
dumps the transfo coefficients to stream.
Definition: Gtransfo.cc:1347
void computeDerivative(const Point &where, GtransfoLin &derivative, const double step=0.01) const
specialised analytic routine
Definition: Gtransfo.cc:1082
double x
coordinate
Definition: Point.h:18
double A22() const
Definition: Gtransfo.h:329
double coeffOrZero(const unsigned powX, const unsigned powY, const unsigned whichCoord) const
read access, zero if beyond degree
Definition: Gtransfo.cc:664
GtransfoLin getLinPart() const
The Linear part (corresponding to CD&#39;s and CRPIX&#39;s)
Definition: Gtransfo.cc:1268
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
Definition: Gtransfo.cc:486
GtransfoLin()
the default constructor constructs the do-nothing transformation.
Definition: Gtransfo.h:293
bool isIntegerShift(const Gtransfo *gtransfo)
Shorthand test to tell if a transfo is a simple integer shift.
Definition: Gtransfo.cc:33
std::unique_ptr< GtransfoPoly > inversePolyTransfo(const Gtransfo &Direct, const Frame &frame, const double Prec)
approximates the inverse by a polynomial, up to required precision.
Definition: Gtransfo.cc:1013
just here to provide a specialized constructor, and fit.
Definition: Gtransfo.h:365
void write(std::ostream &s) const
Definition: Gtransfo.cc:394
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.h:322
double determinant() const
Definition: Gtransfo.cc:719
void read(std::istream &s)
Definition: Gtransfo.cc:396
GtransfoLinScale(const double scaleX, const double scaleY)
Definition: Gtransfo.h:385
rectangle with sides parallel to axes.
Definition: Frame.h:19
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
Definition: Gtransfo.cc:1517
std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame &region) const
Inverse transfo: returns a TanRaDec2Pix if there are no corrections, or the iterative solver if there...
Definition: Gtransfo.cc:1319
TanRaDec2Pix invert() const
approximate inverse : it ignores corrections;
Definition: Gtransfo.cc:1307
double fit(const StarMatchList &starMatchList)
guess what
Definition: Gtransfo.cc:1120
GtransfoPoly operator*(const GtransfoPoly &right) const
Composition (internal stuff in quadruple precision)
Definition: Gtransfo.cc:944
GtransfoIdentity()
constructor.
Definition: Gtransfo.h:147
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
Definition: Gtransfo.cc:99
const GtransfoPoly * getCorr() const
the &quot;correction&quot; (non-owning pointer)
Definition: Gtransfo.h:419
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.h:250
void read(std::istream &s)
Definition: Gtransfo.cc:998
TanPix2RaDec operator*(const GtransfoLin &right) const
composition with GtransfoLin
Definition: Gtransfo.cc:1301
double fit(const StarMatchList &starMatchList)
Not implemented yet, because we do it otherwise.
Definition: Gtransfo.cc:1356
std::string __str__()
Definition: Gtransfo.h:56
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
Definition: Gtransfo.cc:1567
double A21() const
Definition: Gtransfo.h:328
double fit(const StarMatchList &starMatchList)
fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
Definition: Gtransfo.cc:1575
void offsetParams(const double *params)
Definition: Gtransfo.cc:174
virtual int getNpar() const
returns the number of parameters (to compute chi2&#39;s)
Definition: Gtransfo.h:124
virtual std::unique_ptr< Gtransfo > reduceCompo(const Gtransfo *right) const
to be overloaded by derived classes if they can really &quot;reduce&quot; the composition (e.g.
Definition: Gtransfo.cc:52
TanPix2RaDec invert() const
exact typed inverse:
Definition: Gtransfo.cc:1536
double Dy() const
Definition: Gtransfo.h:331
int getNpar() const
total number of parameters
Definition: Gtransfo.h:360
void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
transform with analytical derivatives
Definition: Gtransfo.cc:1465
virtual void paramDerivatives(const Point &where, double *dx, double *dy) const
Derivative w.r.t parameters.
Definition: Gtransfo.cc:188
std::unique_ptr< Gtransfo > reduceCompo(const Gtransfo *right) const
to be overloaded by derived classes if they can really &quot;reduce&quot; the composition (e.g.
Definition: Gtransfo.h:160
void paramDerivatives(const Point &where, double *dx, double *dy) const
Derivative w.r.t parameters.
Definition: Gtransfo.cc:683
int getNpar() const
returns the number of parameters (to compute chi2&#39;s)
Definition: Gtransfo.h:163
A do-nothing transformation. It anyway has dummy routines to mimick a Gtransfo.
Definition: Gtransfo.h:144
void setTangentPoint(const Point &tangentPoint)
Resets the projection (or tangent) point.
Definition: Gtransfo.cc:1445
just here to provide a specialized constructor, and fit.
Definition: Gtransfo.h:352
double Dx() const
Definition: Gtransfo.h:330
Point apply(const Point &in) const
All these apply(..) shadow the virtual one in derived classes, unless one writes &quot;using Gtransfo::app...
Definition: Gtransfo.h:47
int getNpar() const
total number of parameters
Definition: Gtransfo.h:388
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
Definition: Gtransfo.h:513
void dump(std::ostream &stream=std::cout) const
print out of coefficients in a readable form.
Definition: Gtransfo.cc:703
std::unique_ptr< Gtransfo > reduceCompo(const Gtransfo *right) const
to be overloaded by derived classes if they can really &quot;reduce&quot; the composition (e.g.
Definition: Gtransfo.cc:1295
double fit(const StarMatchList &starMatchList)
fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
Definition: Gtransfo.h:155
Point getTangentPoint() const
The tangent point (in degrees)
Definition: Gtransfo.cc:1266
std::unique_ptr< Gtransfo > roughInverse(const Frame &region) const
Overload the &quot;generic routine&quot; (available for all Gtransfo types.
Definition: Gtransfo.cc:1315
just here to provide specialized constructors. GtransfoLin fit routine.
Definition: Gtransfo.h:379
a virtual (interface) class for geometric transformations.
Definition: Gtransfo.h:37
void transformStar(FatPoint &in) const
allows to write MyTransfo(MyStar)
Definition: Gtransfo.h:70
GtransfoPoly(const unsigned degree=1)
Default transfo : identity for all degrees (&gt;=1 ).
Definition: Gtransfo.cc:408
void setDegree(const unsigned degree)
Definition: Gtransfo.cc:465
virtual void computeDerivative(const Point &where, GtransfoLin &derivative, const double step=0.01) const
Computes the local Derivative of a transfo. Step is used for numerical derivation.
Definition: Gtransfo.cc:75
std::unique_ptr< GtransfoPoly > corr
Definition: Gtransfo.h:396
void getParams(double *params) const
params should be at least Npar() long
Definition: Gtransfo.cc:169
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
Definition: Gtransfo.cc:1240
double A11() const
Definition: Gtransfo.h:326
void computeDerivative(const Point &where, GtransfoLin &derivative, const double step=0.01) const
Computes the local Derivative of a transfo. Step is used for numerical derivation.
Definition: Gtransfo.cc:385
BaseTanWcs(const GtransfoLin &pix2Tan, const Point &tangentPoint, const GtransfoPoly *corrections=nullptr)
Definition: Gtransfo.cc:1208
void apply(const Point &in, Point &out) const
applies the tranfo to in and writes into out. Is indeed virtual.
Definition: Gtransfo.h:43
double fit(const StarMatchList &starMatchList)
guess what
Definition: Gtransfo.cc:1124
a run-time transfo that allows users to define a Gtransfo with minimal coding (just the transfo routi...
Definition: Gtransfo.h:562
virtual GtransfoPoly getPix2TangentPlane() const =0
transfo from pix to tangent plane (defined by derived classes)
double paramRef(const int i) const
Definition: Gtransfo.cc:673
GtransfoLin invert() const
returns the inverse: T1 = T2.invert();
Definition: Gtransfo.cc:1090
std::unique_ptr< Gtransfo > gtransfoRead(const std::string &fileName)
The virtual constructor from a file.
Definition: Gtransfo.cc:1587
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.cc:1412
virtual std::unique_ptr< Gtransfo > clone() const =0
returns a copy (allocated by new) of the transformation.
double fit(const StarMatchList &starMatchList)
guess what
Definition: Gtransfo.cc:817
virtual void dump(std::ostream &stream=std::cout) const =0
dumps the transfo coefficients to stream.
UserTransfo(GtransfoFun &fun, const void *userData)
the transfo routine and extra data that it may need.
Definition: Gtransfo.cc:1564
virtual void pix2TP(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const =0
Transforms from pixel space to tangent plane. deferred to actual implementations. ...
void( GtransfoFun)(const double, const double, double &, double &, const void *)
signature of the user-provided routine that actually does the coordinate transfo for UserTransfo...
Definition: Gtransfo.h:559
std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame &region) const
Inverse transfo: returns a TanPix2RaDec.
Definition: Gtransfo.cc:1547
std::unique_ptr< Gtransfo > reduceCompo(const Gtransfo *right) const
to be overloaded by derived classes if they can really &quot;reduce&quot; the composition (e.g.
Definition: Gtransfo.cc:835
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0
int getNpar() const
total number of parameters
Definition: Gtransfo.h:373
Point getCrPix() const
the CRPIX values (this is WCS jargon), in 0-based coordinates
Definition: Gtransfo.cc:1272
virtual double paramRef(const int i) const
Definition: Gtransfo.cc:179
void operator=(const BaseTanWcs &original)
Definition: Gtransfo.cc:1230
std::unique_ptr< Gtransfo > clone() const
returns a copy (allocated by new) of the transformation.
Definition: Gtransfo.cc:1343