LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
AstrometryTransform.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 /*
3  * This file is part of jointcal.
4  *
5  * Developed for the LSST Data Management System.
6  * This product includes software developed by the LSST Project
7  * (https://www.lsst.org).
8  * See the COPYRIGHT file at the top-level directory of this distribution
9  * for details of code ownership.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
25 #ifndef LSST_JOINTCAL_ASTROMETRY_TRANSFORM_H
26 #define LSST_JOINTCAL_ASTROMETRY_TRANSFORM_H
27 
28 #include <iostream>
29 #include <memory>
30 #include <string>
31 #include <sstream>
32 #include <vector>
33 
34 #include "Eigen/Core"
35 
36 #include "lsst/pex/exceptions.h"
37 #include "lsst/afw/geom/SkyWcs.h"
38 #include "lsst/jointcal/FatPoint.h"
39 #include "lsst/jointcal/Frame.h"
40 
42 
43 namespace lsst {
44 namespace jointcal {
45 
46 class StarMatchList;
47 class Frame;
48 class AstrometryTransformLinear;
49 
51 
66 public:
68  virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const = 0;
69 
71  void apply(Point const &in, Point &out) const { apply(in.x, in.y, out.x, out.y); }
72 
75  Point apply(Point const &in) const {
76  double xout, yout;
77  apply(in.x, in.y, xout, yout);
78  return Point(xout, yout);
79  }
80 
89  Frame apply(Frame const &inputframe, bool inscribed) const;
90 
92  virtual void print(std::ostream &out) const = 0;
93 
96  print(s);
97  return s.str();
98  }
99 
101 
105  virtual double fit(StarMatchList const &starMatchList) = 0;
106 
107  void transformStar(FatPoint &in) const { transformPosAndErrors(in, in); }
108 
110  virtual double getJacobian(Point const &point) const { return getJacobian(point.x, point.y); }
111 
114 
132 
134  virtual double getJacobian(const double x, const double y) const;
135 
141  virtual void computeDerivative(Point const &where, AstrometryTransformLinear &derivative,
142  const double step = 0.01) const;
143 
145  virtual AstrometryTransformLinear linearApproximation(Point const &where, const double step = 0.01) const;
146 
147  virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const;
148 
150  virtual void transformErrors(Point const &where, const double *vIn, double *vOut) const;
151 
153 
156  const Frame &region) const;
157 
159  void getParams(double *params) const;
160 
162  void offsetParams(Eigen::VectorXd const &delta);
163 
165  virtual double paramRef(Eigen::Index const i) const;
166 
168  virtual double &paramRef(Eigen::Index const i);
169 
172  virtual void paramDerivatives(Point const &where, double *dx, double *dy) const;
173 
175 
177  virtual std::unique_ptr<AstrometryTransform> roughInverse(const Frame &region) const;
178 
180  virtual std::size_t getNpar() const { return 0; }
181 
190  throw std::logic_error("toAstMap is not implemented for this class.");
191  }
192 
193  void write(const std::string &fileName) const;
194 
195  virtual void write(std::ostream &stream) const;
196 
197  virtual ~AstrometryTransform(){};
198 };
199 
200 std::ostream &operator<<(std::ostream &stream, AstrometryTransform const &transform);
201 
213 std::unique_ptr<AstrometryTransform> compose(AstrometryTransform const &left,
214  AstrometryTransform const &right);
215 
216 /*=============================================================*/
218 
220 public:
223 
225  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const override {
226  xOut = xIn;
227  yOut = yIn;
228  } // to speed up
229 
230  double fit(StarMatchList const &starMatchList) override {
231  throw pexExcept::TypeError(
232  "AstrometryTransformIdentity is the identity transformation: it cannot be fit to anything.");
233  }
234 
237  return right.clone();
238  }
239 
240  void print(std::ostream &out) const override { out << "x' = x\ny' = y" << std::endl; }
241 
242  std::size_t getNpar() const override { return 0; }
243 
246  }
247 
248  void computeDerivative(Point const &where, AstrometryTransformLinear &derivative,
249  const double step = 0.01) const override;
250 
253  const double step = 0.01) const override;
254 
256  std::shared_ptr<ast::Mapping> toAstMap(jointcal::Frame const &domain) const override;
257 
258  void write(std::ostream &s) const override;
259 
260  void read(std::istream &s);
261 
262  // ClassDef(AstrometryTransformIdentity,1)
263 };
264 
271 std::unique_ptr<AstrometryTransform> compose(AstrometryTransform const &left,
272  AstrometryTransformIdentity const &right);
273 
275 bool isIntegerShift(const AstrometryTransform *transform);
276 
277 /*==================== AstrometryTransformPolynomial =======================*/
278 
281 public:
288 
291  std::size_t nPoint = 1000);
292 
302  jointcal::Frame const &domain, std::size_t order, std::size_t nSteps = 50);
303 
305  void setOrder(std::size_t order);
307  std::size_t getOrder() const { return _order; }
308 
309  using AstrometryTransform::apply; // to unhide AstrometryTransform::apply(Point const &)
310 
311  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const override;
312 
314  void computeDerivative(Point const &where, AstrometryTransformLinear &derivative,
315  const double step = 0.01) const override;
316 
318  virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const override;
319 
321  std::size_t getNpar() const override { return 2 * _nterms; }
322 
324  void print(std::ostream &out) const override;
325 
327  double fit(StarMatchList const &starMatchList) override;
328 
331 
334 
337 
338  using AstrometryTransform::composeAndReduce; // to unhide
339  // AstrometryTransform::composeAndReduce(AstrometryTransform
340  // const &)
343 
346  }
347 
352  double getCoefficient(std::size_t powX, std::size_t powY, std::size_t whichCoord) const;
353  double &getCoefficient(std::size_t powX, std::size_t powY, std::size_t whichCoord);
357  double coeffOrZero(std::size_t powX, std::size_t powY, std::size_t whichCoord) const;
358 
359  double determinant() const;
360 
362  double paramRef(Eigen::Index const i) const override;
363 
365  double &paramRef(Eigen::Index const i) override;
366 
369  void paramDerivatives(Point const &where, double *dx, double *dy) const override;
370 
372  std::shared_ptr<ast::Mapping> toAstMap(jointcal::Frame const &domain) const override;
373 
374  void write(std::ostream &s) const override;
375  void read(std::istream &s);
376 
377 private:
378  double computeFit(StarMatchList const &starMatchList, AstrometryTransform const &shiftToCenter,
379  const bool useErrors);
380 
381  std::size_t _order; // The highest sum of exponents of the largest monomial.
382  std::size_t _nterms; // number of parameters per coordinate
383  std::vector<double> _coeffs; // the actual coefficients
384  // both polynomials in a single vector to speed up allocation and copies
385 
386  /* use std::vector rather than double * to avoid
387  writing copy constructor and "operator =".
388  Vect would work as well but introduces a dependence
389  that can be avoided */
390 
391  /* This routine take a double * for the vector because the array can
392  then be allocated on the execution stack, which speeds thing
393  up. However this uses Variable Length Array (VLA) which is not
394  part of C++, but gcc implements it. */
395  void computeMonomials(double xIn, double yIn, double *monomial) const;
396 
402  ndarray::Array<double, 2, 2> toAstPolyMapCoefficients() const;
403 };
404 
417  Frame const &domain,
418  double const precision,
419  std::size_t maxOrder = 9,
420  std::size_t nSteps = 50);
421 
422 AstrometryTransformLinear normalizeCoordinatesTransform(const Frame &frame);
423 
424 /*=============================================================*/
427 public:
428  using AstrometryTransformPolynomial::apply; // to unhide AstrometryTransform::apply(Point const &)
429 
432 
435 
438 
441 
442  void print(std::ostream &out) const override;
443 
444  // useful? double jacobian(const double x, const double y) const { return determinant();}
445 
447  void computeDerivative(Point const &where, AstrometryTransformLinear &derivative,
448  const double step = 0.01) const override;
451  const double step = 0.01) const override;
452 
453  // void print(std::ostream &out) const;
454 
455  // double fit(StarMatchList const &starMatchList);
456 
458  AstrometryTransformLinear(const double ox, const double oy, const double aa11, const double aa12,
459  const double aa21, const double aa22);
460 
463 
466  }
467 
469  const Frame &region) const override;
470 
471  double A11() const { return getCoefficient(1, 0, 0); }
472  double A12() const { return getCoefficient(0, 1, 0); }
473  double A21() const { return getCoefficient(1, 0, 1); }
474  double A22() const { return getCoefficient(0, 1, 1); }
475  double Dx() const { return getCoefficient(0, 0, 0); }
476  double Dy() const { return getCoefficient(0, 0, 1); }
477 
478 protected:
479  double &a11() { return getCoefficient(1, 0, 0); }
480  double &a12() { return getCoefficient(0, 1, 0); }
481  double &a21() { return getCoefficient(1, 0, 1); }
482  double &a22() { return getCoefficient(0, 1, 1); }
483  double &dx() { return getCoefficient(0, 0, 0); }
484  double &dy() { return getCoefficient(0, 0, 1); }
485 
486  friend class AstrometryTransform;
487  friend class AstrometryTransformIdentity; // for AstrometryTransform::Derivative
488  friend class AstrometryTransformPolynomial; // // for AstrometryTransform::Derivative
489 
490 private:
491  void setOrder(std::size_t order); // to hide AstrometryTransformPolynomial::setOrder
492 };
493 
494 /*=============================================================*/
495 
498 public:
499  using AstrometryTransform::apply; // to unhide AstrometryTransform::apply(Point const &)
501  AstrometryTransformLinearShift(double ox = 0., double oy = 0.)
502  : AstrometryTransformLinear(ox, oy, 1., 0., 0., 1.) {}
504  : AstrometryTransformLinear(point.x, point.y, 1., 0., 0., 1.){};
505  double fit(StarMatchList const &starMatchList);
506 
507  std::size_t getNpar() const { return 2; }
508 };
509 
510 /*=============================================================*/
513 public:
514  using AstrometryTransform::apply; // to unhide apply(const Point&)
515 
517  AstrometryTransformLinearRot(const double angleRad, const Point *center = nullptr,
518  const double scaleFactor = 1.0);
519  double fit(StarMatchList const &starMatchList);
520 
521  std::size_t getNpar() const { return 4; }
522 };
523 
524 /*=============================================================*/
525 
528 public:
529  using AstrometryTransform::apply; // to unhide apply(const Point&)
532  : AstrometryTransformLinear(0.0, 0.0, scale, 0., 0., scale){};
534  AstrometryTransformLinearScale(const double scaleX, const double scaleY)
535  : AstrometryTransformLinear(0.0, 0.0, scaleX, 0., 0., scaleY){};
536 
537  std::size_t getNpar() const { return 2; }
538 };
539 
551 public:
553 
555 
556  // Input is x, y pixels; output is ICRS RA, Dec in degrees
557  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const override;
558 
559  void print(std::ostream &out) const override;
560 
562  double fit(const StarMatchList &starMatchList) override;
563 
565 
566  std::shared_ptr<afw::geom::SkyWcs> getSkyWcs() const { return _skyWcs; }
567 
568 private:
570 };
571 
572 /*==================WCS's transform's =====================================*/
573 
575 public:
576  using AstrometryTransform::apply; // to unhide apply(const Point&)
577 
578  BaseTanWcs(AstrometryTransformLinear const &pixToTan, Point const &tangentPoint,
579  const AstrometryTransformPolynomial *corrections = nullptr);
580 
581  BaseTanWcs(const BaseTanWcs &original);
582 
583  void operator=(const BaseTanWcs &original);
584 
586  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
587 
589  Point getTangentPoint() const;
590 
593 
595  const AstrometryTransformPolynomial *getCorr() const { return corr.get(); }
596 
599 
601  Point getCrPix() const;
602 
606 
608  virtual void pixToTangentPlane(double xPixel, double yPixel, double &xTangentPlane,
609  double &yTangentPlane) const = 0;
610 
611  ~BaseTanWcs();
612 
613 protected:
614  AstrometryTransformLinear linPixelToTan; // transform from pixels to tangent plane (degrees)
615  // a linear approximation centered at the pixel and sky origins
617  double ra0, dec0; // sky origin (radians)
618  double cos0, sin0; // cos(dec0), sin(dec0)
619 };
620 
621 class TanRaDecToPixel; // the inverse of TanPixelToRaDec.
622 
627 class TanPixelToRaDec : public BaseTanWcs {
628 public:
629  using AstrometryTransform::apply; // to unhide apply(const Point&)
632  TanPixelToRaDec(AstrometryTransformLinear const &pixToTan, Point const &tangentPoint,
633  const AstrometryTransformPolynomial *corrections = nullptr);
634 
637 
639  virtual void pixToTangentPlane(double xPixel, double yPixel, double &xTangentPlane,
640  double &yTangentPlane) const;
641 
642  TanPixelToRaDec();
643 
646 
647  using AstrometryTransform::composeAndReduce; // to unhide
648  // AstrometryTransform::composeAndReduce(AstrometryTransform
649  // const &)
652 
654  TanRaDecToPixel inverted() const;
655 
658 
661  std::unique_ptr<AstrometryTransform> inverseTransform(const double precision, const Frame &region) const;
662 
664 
665  void print(std::ostream &out) const;
666 
668  double fit(StarMatchList const &starMatchList);
669 };
670 
673 public:
676  TanSipPixelToRaDec(AstrometryTransformLinear const &pixToTan, Point const &tangentPoint,
677  const AstrometryTransformPolynomial *corrections = nullptr);
678 
681 
683  virtual void pixToTangentPlane(double xPixel, double yPixel, double &xTangentPlane,
684  double &yTangentPlane) const;
685 
687 
690  std::unique_ptr<AstrometryTransform> inverseTransform(const double precision, const Frame &region) const;
691 
693 
694  void print(std::ostream &out) const;
695 
697  double fit(StarMatchList const &starMatchList);
698 };
699 
701 
708 public:
709  using AstrometryTransform::apply; // to unhide apply(const Point&)
710 
712  TanRaDecToPixel(AstrometryTransformLinear const &tan2Pix, Point const &tangentPoint);
713 
715  TanRaDecToPixel();
716 
719 
721  void setTangentPoint(Point const &tangentPoint);
722 
724  Point getTangentPoint() const;
725 
727  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
728 
730  void transformPosAndErrors(const FatPoint &in, FatPoint &out) const;
731 
733  TanPixelToRaDec inverted() const;
734 
737 
739  std::unique_ptr<AstrometryTransform> inverseTransform(const double precision, const Frame &region) const;
740 
741  void print(std::ostream &out) const;
742 
744 
745  double fit(StarMatchList const &starMatchList);
746 
747 private:
748  double ra0, dec0; // tangent point (radians)
749  double cos0, sin0;
750  AstrometryTransformLinear linTan2Pix; // tangent plane (probably degrees) to pixels
751 };
752 
754 typedef void(AstrometryTransformFun)(const double, const double, double &, double &, const void *);
755 
761 public:
762  using AstrometryTransform::apply; // to unhide apply(const Point&)
763 
765  UserTransform(AstrometryTransformFun &fun, const void *userData);
766 
767  void apply(const double xIn, const double yIn, double &xOut, double &yOut) const;
768 
769  void print(std::ostream &out) const;
770 
771  double fit(StarMatchList const &starMatchList);
772 
774 
775 private:
776  AstrometryTransformFun *_userFun;
777  const void *_userData;
778 };
779 
784 } // namespace jointcal
785 } // namespace lsst
786 
787 #endif // LSST_JOINTCAL_ASTROMETRY_TRANSFORM_H
int const step
double x
int y
Definition: SpanSet.cc:48
table::Key< int > transform
a virtual (interface) class for geometric transformations.
virtual std::shared_ptr< ast::Mapping > toAstMap(jointcal::Frame const &domain) const
Create an equivalent AST mapping for this transformation, including an analytic inverse if possible.
virtual void paramDerivatives(Point const &where, double *dx, double *dy) const
Derivative w.r.t parameters.
virtual double paramRef(Eigen::Index const i) const
virtual std::unique_ptr< AstrometryTransform > roughInverse(const Frame &region) const
Rough inverse.
virtual std::size_t getNpar() const
returns the number of parameters (to compute chi2's)
virtual double getJacobian(Point const &point) const
returns the local jacobian.
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0
void write(const std::string &fileName) const
virtual AstrometryTransformLinear linearApproximation(Point const &where, const double step=0.01) const
linear (local) approximation.
virtual double fit(StarMatchList const &starMatchList)=0
fits a transform to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
void apply(Point const &in, Point &out) const
applies the tranfo to in and writes into out. Is indeed virtual.
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
virtual std::unique_ptr< AstrometryTransform > composeAndReduce(AstrometryTransform const &right) const
Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.
void offsetParams(Eigen::VectorXd const &delta)
virtual std::unique_ptr< AstrometryTransform > clone() const =0
returns a copy (allocated by new) of the transformation.
void transformStar(FatPoint &in) const
virtual std::unique_ptr< AstrometryTransform > inverseTransform(const double precision, const Frame &region) const
returns an inverse transform. Numerical if not overloaded.
virtual void transformErrors(Point const &where, const double *vIn, double *vOut) const
transform errors (represented as double[3] in order V(xx),V(yy),Cov(xy))
Point apply(Point const &in) const
All these apply(..) shadow the virtual one in derived classes, unless one writes "using AstrometryTra...
virtual void computeDerivative(Point const &where, AstrometryTransformLinear &derivative, const double step=0.01) const
Computes the local Derivative of a transform, w.r.t.
void getParams(double *params) const
params should be at least Npar() long
virtual void print(std::ostream &out) const =0
prints the transform coefficients to stream.
A do-nothing transformation. It anyway has dummy routines to mimick a AstrometryTransform.
std::unique_ptr< AstrometryTransform > clone() const override
returns a copy (allocated by new) of the transformation.
virtual AstrometryTransformLinear linearApproximation(Point const &where, const double step=0.01) const override
linear approximation.
void computeDerivative(Point const &where, AstrometryTransformLinear &derivative, const double step=0.01) const override
Computes the local Derivative of a transform, w.r.t.
void print(std::ostream &out) const override
prints the transform coefficients to stream.
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const override
xOut = xIn; yOut = yIn !
std::size_t getNpar() const override
returns the number of parameters (to compute chi2's)
std::unique_ptr< AstrometryTransform > composeAndReduce(AstrometryTransform const &right) const override
Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.
void write(std::ostream &s) const override
double fit(StarMatchList const &starMatchList) override
fits a transform to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
std::shared_ptr< ast::Mapping > toAstMap(jointcal::Frame const &domain) const override
Create an equivalent AST mapping for this transformation, including an analytic inverse if possible.
implements the linear transformations (6 real coefficients).
std::unique_ptr< AstrometryTransform > clone() const override
returns a copy (allocated by new) of the transformation.
AstrometryTransformLinear(AstrometryTransformIdentity const &)
Handy converter:
AstrometryTransformLinear linearApproximation(Point const &where, const double step=0.01) const override
linear (local) approximation.
void computeDerivative(Point const &where, AstrometryTransformLinear &derivative, const double step=0.01) const override
specialised analytic routine
void print(std::ostream &out) const override
print out of coefficients in a readable form.
std::unique_ptr< AstrometryTransform > inverseTransform(const double precision, const Frame &region) const override
returns an inverse transform. Numerical if not overloaded.
AstrometryTransformLinear operator*(AstrometryTransformLinear const &right) const
enables to combine linear tranformations: T1=T2*T3 is legal.
AstrometryTransformLinear inverted() const
returns the inverse: T1 = T2.inverted();
AstrometryTransformLinear()
the default constructor constructs the do-nothing transformation.
just here to provide a specialized constructor, and fit.
std::size_t getNpar() const
total number of parameters
double fit(StarMatchList const &starMatchList)
guess what
just here to provide specialized constructors. AstrometryTransformLinear fit routine.
std::size_t getNpar() const
total number of parameters
AstrometryTransformLinearScale(const double scaleX, const double scaleY)
just here to provide a specialized constructor, and fit.
double fit(StarMatchList const &starMatchList)
guess what
AstrometryTransformLinearShift(double ox=0., double oy=0.)
Add ox and oy.
std::size_t getNpar() const
total number of parameters
double coeffOrZero(std::size_t powX, std::size_t powY, std::size_t whichCoord) const
read access, zero if beyond order
void computeDerivative(Point const &where, AstrometryTransformLinear &derivative, const double step=0.01) const override
specialised analytic routine
std::unique_ptr< AstrometryTransform > clone() const override
returns a copy (allocated by new) of the transformation.
std::shared_ptr< ast::Mapping > toAstMap(jointcal::Frame const &domain) const override
Create an equivalent AST mapping for this transformation, including an analytic inverse if possible.
AstrometryTransformPolynomial operator-(AstrometryTransformPolynomial const &right) const
Subtraction.
AstrometryTransformPolynomial operator*(AstrometryTransformPolynomial const &right) const
Composition (internal stuff in quadruple precision)
double getCoefficient(std::size_t powX, std::size_t powY, std::size_t whichCoord) const
Get the coefficient of a given power in x and y, for either the x or y coordinate.
std::size_t getNpar() const override
total number of parameters
double paramRef(Eigen::Index const i) const override
void setOrder(std::size_t order)
Sets the polynomial order (the highest sum of exponents of the largest monomial).
double fit(StarMatchList const &starMatchList) override
guess what
void print(std::ostream &out) const override
print out of coefficients in a readable form.
void paramDerivatives(Point const &where, double *dx, double *dy) const override
Derivative w.r.t parameters.
void write(std::ostream &s) const override
virtual std::unique_ptr< AstrometryTransform > composeAndReduce(AstrometryTransform const &right) const
Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const override
a mix of apply and Derivative
std::size_t getOrder() const
Returns the polynomial order.
AstrometryTransformPolynomial(std::size_t order=1)
Default transform : identity for all orders (>=1 ).
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0
AstrometryTransformPolynomial operator+(AstrometryTransformPolynomial const &right) const
Addition.
A AstrometryTransform that holds a SkyWcs.
void print(std::ostream &out) const override
prints the transform coefficients to stream.
std::shared_ptr< afw::geom::SkyWcs > getSkyWcs() const
std::unique_ptr< AstrometryTransform > clone() const override
returns a copy (allocated by new) of the transformation.
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0
double fit(const StarMatchList &starMatchList) override
Not implemented; throws pex::exceptions::LogicError.
AstrometryTransformSkyWcs(std::shared_ptr< afw::geom::SkyWcs > skyWcs)
std::unique_ptr< AstrometryTransformPolynomial > corr
virtual void pixToTangentPlane(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const =0
Transform from pixels to tangent plane (degrees)
Point getCrPix() const
Get the pixel origin of the WCS (CRPIX in FITS WCS terminology, but zero-based)
BaseTanWcs(AstrometryTransformLinear const &pixToTan, Point const &tangentPoint, const AstrometryTransformPolynomial *corrections=nullptr)
AstrometryTransformLinear getLinPart() const
The Linear part (corresponding to CD's and CRPIX's)
const AstrometryTransformPolynomial * getCorr() const
Get a non-owning pointer to the correction transform polynomial.
void operator=(const BaseTanWcs &original)
virtual AstrometryTransformPolynomial getPixelToTangentPlane() const =0
Get a transform from pixels to tangent plane (degrees) This is a linear transform plus the effects of...
Point getTangentPoint() const
Get the sky origin (CRVAL in FITS WCS terminology) in degrees.
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0
AstrometryTransformLinear linPixelToTan
void setCorrections(std::unique_ptr< AstrometryTransformPolynomial > corrections)
Assign the correction polynomial (what it means is left to derived classes)
A Point with uncertainties.
Definition: FatPoint.h:34
rectangle with sides parallel to axes.
Definition: Frame.h:38
A point in a plane.
Definition: Point.h:37
double x
coordinate
Definition: Point.h:42
The transformation that handles pixels to sideral transformations (Gnomonic, possibly with polynomial...
std::unique_ptr< AstrometryTransform > inverseTransform(const double precision, const Frame &region) const
Inverse transform: returns a TanRaDecToPixel if there are no corrections, or the iterative solver if ...
TanPixelToRaDec operator*(AstrometryTransformLinear const &right) const
composition with AstrometryTransformLinear
std::unique_ptr< AstrometryTransform > clone() const
returns a copy (allocated by new) of the transformation.
TanRaDecToPixel inverted() const
approximate inverse : it ignores corrections;
virtual std::unique_ptr< AstrometryTransform > composeAndReduce(AstrometryTransform const &right) const
Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.
double fit(StarMatchList const &starMatchList)
Not implemented yet, because we do it otherwise.
virtual void pixToTangentPlane(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const
transforms from pixel space to tangent plane (degrees)
void print(std::ostream &out) const
prints the transform coefficients to stream.
std::unique_ptr< AstrometryTransform > roughInverse(const Frame &region) const
Overload the "generic routine" (available for all AstrometryTransform types.
AstrometryTransformPolynomial getPixelToTangentPlane() const
the transformation from pixels to tangent plane (degrees)
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane)
void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
transform with analytical derivatives
Point getTangentPoint() const
tangent point coordinates (degrees)
double fit(StarMatchList const &starMatchList)
fits a transform to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
void setTangentPoint(Point const &tangentPoint)
Resets the projection (or tangent) point.
TanPixelToRaDec inverted() const
exact typed inverse:
std::unique_ptr< AstrometryTransform > clone() const
returns a copy (allocated by new) of the transformation.
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0
AstrometryTransformLinear getLinPart() const
The Linear part (corresponding to CD's and CRPIX's)
std::unique_ptr< AstrometryTransform > roughInverse(const Frame &region) const
Overload the "generic routine" (available for all AstrometryTransform types.
std::unique_ptr< AstrometryTransform > inverseTransform(const double precision, const Frame &region) const
Inverse transform: returns a TanPixelToRaDec.
void print(std::ostream &out) const
prints the transform coefficients to stream.
Implements the (forward) SIP distorsion scheme.
std::unique_ptr< AstrometryTransform > inverseTransform(const double precision, const Frame &region) const
Inverse transform: returns a TanRaDecToPixel if there are no corrections, or the iterative solver if ...
void print(std::ostream &out) const
prints the transform coefficients to stream.
double fit(StarMatchList const &starMatchList)
Not implemented yet, because we do it otherwise.
virtual void pixToTangentPlane(double xPixel, double yPixel, double &xTangentPlane, double &yTangentPlane) const
transforms from pixel space to tangent plane (degrees)
std::unique_ptr< AstrometryTransform > clone() const
returns a copy (allocated by new) of the transformation.
AstrometryTransformPolynomial getPixelToTangentPlane() const
the transformation from pixels to tangent plane (degrees)
A run-time transform that allows users to define a AstrometryTransform with minimal coding (just the ...
void print(std::ostream &out) const
prints the transform coefficients to stream.
std::unique_ptr< AstrometryTransform > clone() const
returns a copy (allocated by new) of the transformation.
UserTransform(AstrometryTransformFun &fun, const void *userData)
the transform routine and extra data that it may need.
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0
double fit(StarMatchList const &starMatchList)
fits a transform to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167
T endl(T... args)
T right(T... args)
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108
AstrometryTransformLinear normalizeCoordinatesTransform(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
void() AstrometryTransformFun(const double, const double, double &, double &, const void *)
signature of the user-provided routine that actually does the coordinate transform for UserTransform.
bool isIntegerShift(const AstrometryTransform *transform)
Shorthand test to tell if a transform is a simple integer shift.
std::unique_ptr< AstrometryTransform > compose(AstrometryTransform const &left, AstrometryTransform const &right)
Returns a pointer to a composition of transforms, representing left(right()).
std::unique_ptr< AstrometryTransform > astrometryTransformRead(const std::string &fileName)
The virtual constructor from a file.
std::ostream & operator<<(std::ostream &stream, AstrometryMapping const &mapping)
std::shared_ptr< AstrometryTransformPolynomial > inversePolyTransform(AstrometryTransform const &forward, Frame const &domain, double const precision, std::size_t maxOrder=9, std::size_t nSteps=50)
Approximate the inverse by a polynomial, to some precision.
A base class for image defects.
T str(T... args)
table::Key< int > order