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
Public Member Functions | Protected Member Functions | List of all members
lsst::jointcal::AstrometryTransformLinearScale Class Reference

just here to provide specialized constructors. AstrometryTransformLinear fit routine. More...

#include <AstrometryTransform.h>

Inheritance diagram for lsst::jointcal::AstrometryTransformLinearScale:
lsst::jointcal::AstrometryTransformLinear lsst::jointcal::AstrometryTransformPolynomial lsst::jointcal::AstrometryTransform

Public Member Functions

 AstrometryTransformLinearScale (const double scale=1)
 
 AstrometryTransformLinearScale (const double scaleX, const double scaleY)
 
std::size_t getNpar () const
 total number of parameters More...
 
virtual void apply (const double xIn, const double yIn, double &xOut, double &yOut) const=0
 
void apply (Point const &in, Point &out) const
 applies the tranfo to in and writes into out. Is indeed virtual. More...
 
Point apply (Point const &in) const
 All these apply(..) shadow the virtual one in derived classes, unless one writes "using AstrometryTransform::apply". More...
 
Frame apply (Frame const &inputframe, bool inscribed) const
 Transform a bounding box, taking either the inscribed or circumscribed box. More...
 
AstrometryTransformLinear operator* (AstrometryTransformLinear const &right) const
 enables to combine linear tranformations: T1=T2*T3 is legal. More...
 
AstrometryTransformPolynomial operator* (AstrometryTransformPolynomial const &right) const
 Composition (internal stuff in quadruple precision) More...
 
AstrometryTransformLinear inverted () const
 returns the inverse: T1 = T2.inverted(); More...
 
void print (std::ostream &out) const override
 print out of coefficients in a readable form. More...
 
void computeDerivative (Point const &where, AstrometryTransformLinear &derivative, const double step=0.01) const override
 specialised analytic routine More...
 
AstrometryTransformLinear linearApproximation (Point const &where, const double step=0.01) const override
 linear (local) approximation. More...
 
std::unique_ptr< AstrometryTransformclone () const override
 returns a copy (allocated by new) of the transformation. More...
 
std::unique_ptr< AstrometryTransforminverseTransform (const double precision, const Frame &region) const override
 returns an inverse transform. Numerical if not overloaded. More...
 
double A11 () const
 
double A12 () const
 
double A21 () const
 
double A22 () const
 
double Dx () const
 
double Dy () const
 
void apply (const double xIn, const double yIn, double &xOut, double &yOut) const override
 
void apply (Point const &in, Point &out) const
 applies the tranfo to in and writes into out. Is indeed virtual. More...
 
Point apply (Point const &in) const
 All these apply(..) shadow the virtual one in derived classes, unless one writes "using AstrometryTransform::apply". More...
 
Frame apply (Frame const &inputframe, bool inscribed) const
 Transform a bounding box, taking either the inscribed or circumscribed box. More...
 
std::size_t getOrder () const
 Returns the polynomial order. More...
 
virtual void transformPosAndErrors (const FatPoint &in, FatPoint &out) const override
 a mix of apply and Derivative More...
 
double fit (StarMatchList const &starMatchList) override
 guess what More...
 
AstrometryTransformPolynomial operator+ (AstrometryTransformPolynomial const &right) const
 Addition. More...
 
AstrometryTransformPolynomial operator- (AstrometryTransformPolynomial const &right) const
 Subtraction. More...
 
std::unique_ptr< AstrometryTransformcomposeAndReduce (AstrometryTransformPolynomial const &right) const
 Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced. More...
 
virtual std::unique_ptr< AstrometryTransformcomposeAndReduce (AstrometryTransform const &right) const
 Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced. More...
 
virtual std::unique_ptr< AstrometryTransformcomposeAndReduce (AstrometryTransform const &right) const
 Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced. More...
 
double coeffOrZero (std::size_t powX, std::size_t powY, std::size_t whichCoord) const
 read access, zero if beyond order More...
 
double determinant () const
 
double paramRef (Eigen::Index const i) const override
 
double & paramRef (Eigen::Index const i) override
 
void paramDerivatives (Point const &where, double *dx, double *dy) const override
 Derivative w.r.t parameters. More...
 
std::shared_ptr< ast::MappingtoAstMap (jointcal::Frame const &domain) const override
 Create an equivalent AST mapping for this transformation, including an analytic inverse if possible. More...
 
void write (std::ostream &s) const override
 
void write (const std::string &fileName) const
 
void read (std::istream &s)
 
std::string __str__ ()
 
void transformStar (FatPoint &in) const
 
virtual double getJacobian (Point const &point) const
 returns the local jacobian. More...
 
virtual double getJacobian (const double x, const double y) const
 returns the local jacobian. More...
 
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)) More...
 
void getParams (double *params) const
 params should be at least Npar() long More...
 
void offsetParams (Eigen::VectorXd const &delta)
 
virtual std::unique_ptr< AstrometryTransformroughInverse (const Frame &region) const
 Rough inverse. More...
 
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. More...
 
double & getCoefficient (std::size_t powX, std::size_t powY, std::size_t whichCoord)
 Get the coefficient of a given power in x and y, for either the x or y coordinate. More...
 

Protected Member Functions

double & a11 ()
 
double & a12 ()
 
double & a21 ()
 
double & a22 ()
 
double & dx ()
 
double & dy ()
 

Detailed Description

just here to provide specialized constructors. AstrometryTransformLinear fit routine.

Definition at line 527 of file AstrometryTransform.h.

Constructor & Destructor Documentation

◆ AstrometryTransformLinearScale() [1/2]

lsst::jointcal::AstrometryTransformLinearScale::AstrometryTransformLinearScale ( const double  scale = 1)
inline

Definition at line 531 of file AstrometryTransform.h.

532  : AstrometryTransformLinear(0.0, 0.0, scale, 0., 0., scale){};
AstrometryTransformLinear()
the default constructor constructs the do-nothing transformation.
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108

◆ AstrometryTransformLinearScale() [2/2]

lsst::jointcal::AstrometryTransformLinearScale::AstrometryTransformLinearScale ( const double  scaleX,
const double  scaleY 
)
inline

Definition at line 534 of file AstrometryTransform.h.

535  : AstrometryTransformLinear(0.0, 0.0, scaleX, 0., 0., scaleY){};

Member Function Documentation

◆ __str__()

std::string lsst::jointcal::AstrometryTransform::__str__ ( )
inlineinherited

Definition at line 94 of file AstrometryTransform.h.

94  {
96  print(s);
97  return s.str();
98  }
virtual void print(std::ostream &out) const =0
prints the transform coefficients to stream.
T str(T... args)

◆ a11()

double& lsst::jointcal::AstrometryTransformLinear::a11 ( )
inlineprotectedinherited

Definition at line 479 of file AstrometryTransform.h.

479 { return getCoefficient(1, 0, 0); }
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.

◆ A11()

double lsst::jointcal::AstrometryTransformLinear::A11 ( ) const
inlineinherited

Definition at line 471 of file AstrometryTransform.h.

471 { return getCoefficient(1, 0, 0); }

◆ a12()

double& lsst::jointcal::AstrometryTransformLinear::a12 ( )
inlineprotectedinherited

Definition at line 480 of file AstrometryTransform.h.

480 { return getCoefficient(0, 1, 0); }

◆ A12()

double lsst::jointcal::AstrometryTransformLinear::A12 ( ) const
inlineinherited

Definition at line 472 of file AstrometryTransform.h.

472 { return getCoefficient(0, 1, 0); }

◆ a21()

double& lsst::jointcal::AstrometryTransformLinear::a21 ( )
inlineprotectedinherited

Definition at line 481 of file AstrometryTransform.h.

481 { return getCoefficient(1, 0, 1); }

◆ A21()

double lsst::jointcal::AstrometryTransformLinear::A21 ( ) const
inlineinherited

Definition at line 473 of file AstrometryTransform.h.

473 { return getCoefficient(1, 0, 1); }

◆ a22()

double& lsst::jointcal::AstrometryTransformLinear::a22 ( )
inlineprotectedinherited

Definition at line 482 of file AstrometryTransform.h.

482 { return getCoefficient(0, 1, 1); }

◆ A22()

double lsst::jointcal::AstrometryTransformLinear::A22 ( ) const
inlineinherited

Definition at line 474 of file AstrometryTransform.h.

474 { return getCoefficient(0, 1, 1); }

◆ apply() [1/8]

void lsst::jointcal::AstrometryTransformPolynomial::apply ( const double  xIn,
const double  yIn,
double &  xOut,
double &  yOut 
) const
overridevirtualinherited

Implements lsst::jointcal::AstrometryTransform.

Definition at line 572 of file AstrometryTransform.cc.

573  {
574  /*
575  This routine computes the monomials only once for both
576  polynomials. This is why AstrometryTransformPolynomial does not use an auxilary
577  class (such as PolyXY) to handle each polynomial.
578 
579  The code works even if &xIn == &xOut (or &yIn == &yOut)
580  It uses Variable Length Allocation (VLA) rather than a vector<double>
581  because allocating the later costs about 50 ns. All VLA uses are tagged.
582  */
583  double monomials[_nterms]; // this is VLA, which is (perhaps) not casher C++
584  computeMonomials(xIn, yIn, monomials);
585 
586  xOut = 0;
587  yOut = 0;
588  const double *c = &_coeffs[0];
589  const double *pm = &monomials[0];
590  // the ordering of the coefficients and the monomials are identical.
591  for (int k = _nterms; k--;) xOut += (*(pm++)) * (*(c++));
592  pm = &monomials[0];
593  for (int k = _nterms; k--;) yOut += (*(pm++)) * (*(c++));
594 }

◆ apply() [2/8]

virtual void lsst::jointcal::AstrometryTransform::apply

◆ apply() [3/8]

Frame lsst::jointcal::AstrometryTransform::apply ( Frame const &  inputframe,
bool  inscribed 
) const
inherited

Transform a bounding box, taking either the inscribed or circumscribed box.

Parameters
[in]inputframeThe frame to be transformed.
[in]inscribedReturn the inscribed (true) or circumscribed (false) box.
Returns
The transformed frame.

Definition at line 76 of file AstrometryTransform.cc.

76  {
77  // 2 opposite corners
78  double xtmin1, xtmax1, ytmin1, ytmax1;
79  apply(inputframe.xMin, inputframe.yMin, xtmin1, ytmin1);
80  apply(inputframe.xMax, inputframe.yMax, xtmax1, ytmax1);
81  Frame fr1(std::min(xtmin1, xtmax1), std::min(ytmin1, ytmax1), std::max(xtmin1, xtmax1),
82  std::max(ytmin1, ytmax1));
83  // 2 other corners
84  double xtmin2, xtmax2, ytmin2, ytmax2;
85  apply(inputframe.xMin, inputframe.yMax, xtmin2, ytmax2);
86  apply(inputframe.xMax, inputframe.yMin, xtmax2, ytmin2);
87  Frame fr2(std::min(xtmin2, xtmax2), std::min(ytmin2, ytmax2), std::max(xtmin2, xtmax2),
88  std::max(ytmin2, ytmax2));
89 
90  if (inscribed) return fr1 * fr2;
91  return fr1 + fr2;
92 }
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0
T max(T... args)
T min(T... args)

◆ apply() [4/8]

Frame lsst::jointcal::AstrometryTransform::apply

Transform a bounding box, taking either the inscribed or circumscribed box.

Parameters
[in]inputframeThe frame to be transformed.
[in]inscribedReturn the inscribed (true) or circumscribed (false) box.
Returns
The transformed frame.

Definition at line 89 of file AstrometryTransform.cc.

76  {
77  // 2 opposite corners
78  double xtmin1, xtmax1, ytmin1, ytmax1;
79  apply(inputframe.xMin, inputframe.yMin, xtmin1, ytmin1);
80  apply(inputframe.xMax, inputframe.yMax, xtmax1, ytmax1);
81  Frame fr1(std::min(xtmin1, xtmax1), std::min(ytmin1, ytmax1), std::max(xtmin1, xtmax1),
82  std::max(ytmin1, ytmax1));
83  // 2 other corners
84  double xtmin2, xtmax2, ytmin2, ytmax2;
85  apply(inputframe.xMin, inputframe.yMax, xtmin2, ytmax2);
86  apply(inputframe.xMax, inputframe.yMin, xtmax2, ytmin2);
87  Frame fr2(std::min(xtmin2, xtmax2), std::min(ytmin2, ytmax2), std::max(xtmin2, xtmax2),
88  std::max(ytmin2, ytmax2));
89 
90  if (inscribed) return fr1 * fr2;
91  return fr1 + fr2;
92 }
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0

◆ apply() [5/8]

Point lsst::jointcal::AstrometryTransform::apply ( Point const &  in) const
inlineinherited

All these apply(..) shadow the virtual one in derived classes, unless one writes "using AstrometryTransform::apply".

Definition at line 75 of file AstrometryTransform.h.

75  {
76  double xout, yout;
77  apply(in.x, in.y, xout, yout);
78  return Point(xout, yout);
79  }

◆ apply() [6/8]

Point lsst::jointcal::AstrometryTransform::apply
inline

All these apply(..) shadow the virtual one in derived classes, unless one writes "using AstrometryTransform::apply".

Definition at line 75 of file AstrometryTransform.h.

75  {
76  double xout, yout;
77  apply(in.x, in.y, xout, yout);
78  return Point(xout, yout);
79  }

◆ apply() [7/8]

void lsst::jointcal::AstrometryTransform::apply ( Point const &  in,
Point out 
) const
inlineinherited

applies the tranfo to in and writes into out. Is indeed virtual.

Definition at line 71 of file AstrometryTransform.h.

71 { apply(in.x, in.y, out.x, out.y); }

◆ apply() [8/8]

void lsst::jointcal::AstrometryTransform::apply
inline

applies the tranfo to in and writes into out. Is indeed virtual.

Definition at line 71 of file AstrometryTransform.h.

71 { apply(in.x, in.y, out.x, out.y); }

◆ clone()

std::unique_ptr<AstrometryTransform> lsst::jointcal::AstrometryTransformLinear::clone ( ) const
inlineoverridevirtualinherited

returns a copy (allocated by new) of the transformation.

Reimplemented from lsst::jointcal::AstrometryTransformPolynomial.

Definition at line 464 of file AstrometryTransform.h.

◆ coeffOrZero()

double lsst::jointcal::AstrometryTransformPolynomial::coeffOrZero ( std::size_t  powX,
std::size_t  powY,
std::size_t  whichCoord 
) const
inherited

read access, zero if beyond order

Definition at line 755 of file AstrometryTransform.cc.

756  {
757  // assert((degX+degY<=order) && whichCoord<2);
758  assert(whichCoord < 2);
759  if (degX + degY <= _order)
760  return _coeffs[(degX + degY) * (degX + degY + 1) / 2 + degY + whichCoord * _nterms];
761  return 0;
762 }

◆ composeAndReduce() [1/3]

std::unique_ptr< AstrometryTransform > lsst::jointcal::AstrometryTransform::composeAndReduce ( AstrometryTransform const &  right) const
virtualinherited

Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.

"Reduced" in this context means that they are capable of being merged into a single transform, for example, for two polynomials:

\[ f(x) = 1 + x^2, g(x) = -1 + 3x \]

we would have h = f.composeAndReduce(g) == 2 - 6x + 9x^2.

To be overloaded by derived classes if they can properly reduce the composition.

Parameters
rightThe transform to apply first.
Returns
The new reduced and composed AstrometryTransform, or nullptr if no such reduction is possible.

Reimplemented in lsst::jointcal::AstrometryTransformIdentity.

Definition at line 94 of file AstrometryTransform.cc.

95  { // by default no way to compose
97 }

◆ composeAndReduce() [2/3]

std::unique_ptr< AstrometryTransform > lsst::jointcal::AstrometryTransform::composeAndReduce
inherited

Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.

"Reduced" in this context means that they are capable of being merged into a single transform, for example, for two polynomials:

\[ f(x) = 1 + x^2, g(x) = -1 + 3x \]

we would have h = f.composeAndReduce(g) == 2 - 6x + 9x^2.

To be overloaded by derived classes if they can properly reduce the composition.

Parameters
rightThe transform to apply first.
Returns
The new reduced and composed AstrometryTransform, or nullptr if no such reduction is possible.

Definition at line 131 of file AstrometryTransform.cc.

95  { // by default no way to compose
97 }

◆ composeAndReduce() [3/3]

std::unique_ptr< AstrometryTransform > lsst::jointcal::AstrometryTransformPolynomial::composeAndReduce ( AstrometryTransformPolynomial const &  right) const
inherited

Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.

"Reduced" in this context means that they are capable of being merged into a single transform, for example, for two polynomials:

\[ f(x) = 1 + x^2, g(x) = -1 + 3x \]

we would have h = f.composeAndReduce(g) == 2 - 6x + 9x^2.

To be overloaded by derived classes if they can properly reduce the composition.

Parameters
rightThe transform to apply first.
Returns
The new reduced and composed AstrometryTransform, or nullptr if no such reduction is possible.

Definition at line 945 of file AstrometryTransform.cc.

946  {
947  if (getOrder() == 1 && right.getOrder() == 1)
948  return std::make_unique<AstrometryTransformLinear>((*this) * (right)); // does the composition
949  else
950  return std::make_unique<AstrometryTransformPolynomial>((*this) * (right)); // does the composition
951 }
std::size_t getOrder() const
Returns the polynomial order.
T right(T... args)

◆ computeDerivative()

void lsst::jointcal::AstrometryTransformLinear::computeDerivative ( Point const &  where,
AstrometryTransformLinear derivative,
const double  step = 0.01 
) const
overridevirtualinherited

specialised analytic routine

Reimplemented from lsst::jointcal::AstrometryTransformPolynomial.

Definition at line 1252 of file AstrometryTransform.cc.

1253  {
1254  derivative = *this;
1255  derivative.getCoefficient(0, 0, 0) = 0;
1256  derivative.getCoefficient(0, 0, 1) = 0;
1257 }

◆ determinant()

double lsst::jointcal::AstrometryTransformPolynomial::determinant ( ) const
inherited

Definition at line 825 of file AstrometryTransform.cc.

825  {
826  if (_order >= 1)
827  return getCoefficient(1, 0, 0) * getCoefficient(0, 1, 1) -
828  getCoefficient(0, 1, 0) * getCoefficient(1, 0, 1);
829  return 0;
830 }

◆ dx()

double& lsst::jointcal::AstrometryTransformLinear::dx ( )
inlineprotectedinherited

Definition at line 483 of file AstrometryTransform.h.

483 { return getCoefficient(0, 0, 0); }

◆ Dx()

double lsst::jointcal::AstrometryTransformLinear::Dx ( ) const
inlineinherited

Definition at line 475 of file AstrometryTransform.h.

475 { return getCoefficient(0, 0, 0); }

◆ dy()

double& lsst::jointcal::AstrometryTransformLinear::dy ( )
inlineprotectedinherited

Definition at line 484 of file AstrometryTransform.h.

484 { return getCoefficient(0, 0, 1); }

◆ Dy()

double lsst::jointcal::AstrometryTransformLinear::Dy ( ) const
inlineinherited

Definition at line 476 of file AstrometryTransform.h.

476 { return getCoefficient(0, 0, 1); }

◆ fit()

double lsst::jointcal::AstrometryTransformPolynomial::fit ( StarMatchList const &  starMatchList)
overridevirtualinherited

guess what

Implements lsst::jointcal::AstrometryTransform.

Reimplemented in lsst::jointcal::AstrometryTransformLinearRot, and lsst::jointcal::AstrometryTransformLinearShift.

Definition at line 927 of file AstrometryTransform.cc.

927  {
928  if (starMatchList.size() < _nterms) {
929  LOGLS_FATAL(_log, "AstrometryTransformPolynomial::fit trying to fit a polynomial transform of order "
930  << _order << " with only " << starMatchList.size() << " matches.");
931  return -1;
932  }
933 
934  AstrometryTransformPolynomial conditionner = shiftAndNormalize(starMatchList);
935 
936  computeFit(starMatchList, conditionner, false); // get a rough solution
937  computeFit(starMatchList, conditionner, true); // weight with it
938  double chi2 = computeFit(starMatchList, conditionner, true); // once more
939 
940  (*this) = (*this) * conditionner;
941  if (starMatchList.size() == _nterms) return 0;
942  return chi2;
943 }
#define LOGLS_FATAL(logger, message)
Log a fatal-level message using an iostream-based interface.
Definition: Log.h:699
AstrometryTransformPolynomial(std::size_t order=1)
Default transform : identity for all orders (>=1 ).

◆ getCoefficient() [1/2]

double & lsst::jointcal::AstrometryTransformPolynomial::getCoefficient ( std::size_t  powX,
std::size_t  powY,
std::size_t  whichCoord 
)
inherited

Get the coefficient of a given power in x and y, for either the x or y coordinate.

Definition at line 749 of file AstrometryTransform.cc.

750  {
751  assert((degX + degY <= _order) && whichCoord < 2);
752  return _coeffs[(degX + degY) * (degX + degY + 1) / 2 + degY + whichCoord * _nterms];
753 }

◆ getCoefficient() [2/2]

double lsst::jointcal::AstrometryTransformPolynomial::getCoefficient ( std::size_t  powX,
std::size_t  powY,
std::size_t  whichCoord 
) const
inherited

Get the coefficient of a given power in x and y, for either the x or y coordinate.

Definition at line 740 of file AstrometryTransform.cc.

741  {
742  assert((degX + degY <= _order) && whichCoord < 2);
743  /* this assertion above is enough to ensure that the index used just
744  below is within bounds since the reserved length is
745  2*_nterms=(order+1)*(order+2) */
746  return _coeffs[(degX + degY) * (degX + degY + 1) / 2 + degY + whichCoord * _nterms];
747 }

◆ getJacobian() [1/2]

double lsst::jointcal::AstrometryTransform::getJacobian ( const double  x,
const double  y 
) const
virtualinherited

returns the local jacobian.

Definition at line 99 of file AstrometryTransform.cc.

99  {
100  double x2, y2;
101  double eps = x * 0.01;
102  if (eps == 0) eps = 0.01;
103  apply(x, y, x2, y2);
104  double dxdx, dydx;
105  apply(x + eps, y, dxdx, dydx);
106  dxdx -= x2;
107  dydx -= y2;
108  double dxdy, dydy;
109  apply(x, y + eps, dxdy, dydy);
110  dxdy -= x2;
111  dydy -= y2;
112  return ((dxdx * dydy - dxdy * dydx) / (eps * eps));
113 }
double x
int y
Definition: SpanSet.cc:48

◆ getJacobian() [2/2]

virtual double lsst::jointcal::AstrometryTransform::getJacobian ( Point const &  point) const
inlinevirtualinherited

returns the local jacobian.

Definition at line 110 of file AstrometryTransform.h.

110 { return getJacobian(point.x, point.y); }
virtual double getJacobian(Point const &point) const
returns the local jacobian.

◆ getNpar()

std::size_t lsst::jointcal::AstrometryTransformLinearScale::getNpar ( ) const
inlinevirtual

total number of parameters

Reimplemented from lsst::jointcal::AstrometryTransformPolynomial.

Definition at line 537 of file AstrometryTransform.h.

537 { return 2; }

◆ getOrder()

std::size_t lsst::jointcal::AstrometryTransformPolynomial::getOrder ( ) const
inlineinherited

Returns the polynomial order.

Definition at line 307 of file AstrometryTransform.h.

307 { return _order; }

◆ getParams()

void lsst::jointcal::AstrometryTransform::getParams ( double *  params) const
inherited

params should be at least Npar() long

Definition at line 216 of file AstrometryTransform.cc.

216  {
217  std::size_t npar = getNpar();
218  for (std::size_t i = 0; i < npar; ++i) params[i] = paramRef(i);
219 }
virtual double paramRef(Eigen::Index const i) const
virtual std::size_t getNpar() const
returns the number of parameters (to compute chi2's)

◆ inverseTransform()

std::unique_ptr< AstrometryTransform > lsst::jointcal::AstrometryTransformLinear::inverseTransform ( const double  precision,
const Frame region 
) const
overridevirtualinherited

returns an inverse transform. Numerical if not overloaded.

precision and region refer to the "input" side of this, and hence to the output side of the returned AstrometryTransform.

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 1290 of file AstrometryTransform.cc.

1291  {
1293 }
AstrometryTransformLinear inverted() const
returns the inverse: T1 = T2.inverted();

◆ inverted()

AstrometryTransformLinear lsst::jointcal::AstrometryTransformLinear::inverted ( ) const
inherited

returns the inverse: T1 = T2.inverted();

Definition at line 1263 of file AstrometryTransform.cc.

1263  {
1264  //
1265  // (T1,M1) * (T2,M2) = 1 i.e (0,1) implies
1266  // T1 = -M1 * T2
1267  // M1 = M2^(-1)
1268  //
1269 
1270  double a11 = A11();
1271  double a12 = A12();
1272  double a21 = A21();
1273  double a22 = A22();
1274  double d = (a11 * a22 - a12 * a21);
1275  if (d == 0) {
1276  LOGL_FATAL(_log,
1277  "AstrometryTransformLinear::invert singular transformation: transform contents will be "
1278  "dumped to stderr.");
1279  print(cerr);
1280  }
1281 
1282  AstrometryTransformLinear result(0, 0, a22 / d, -a12 / d, -a21 / d, a11 / d);
1283  double rdx, rdy;
1284  result.apply(Dx(), Dy(), rdx, rdy);
1285  result.dx() = -rdx;
1286  result.dy() = -rdy;
1287  return result;
1288 }
py::object result
Definition: _schema.cc:429
#define LOGL_FATAL(logger, message...)
Log a fatal-level message using a varargs/printf style interface.
Definition: Log.h:579
void print(std::ostream &out) const override
print out of coefficients in a readable form.

◆ linearApproximation()

AstrometryTransformLinear lsst::jointcal::AstrometryTransformLinear::linearApproximation ( Point const &  where,
const double  step = 0.01 
) const
overridevirtualinherited

linear (local) approximation.

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 1259 of file AstrometryTransform.cc.

1259  {
1260  return *this;
1261 }

◆ offsetParams()

void lsst::jointcal::AstrometryTransform::offsetParams ( Eigen::VectorXd const &  delta)
inherited

Definition at line 221 of file AstrometryTransform.cc.

221  {
222  std::size_t npar = getNpar();
223  for (std::size_t i = 0; i < npar; ++i) paramRef(i) += delta[i];
224 }

◆ operator*() [1/2]

AstrometryTransformLinear lsst::jointcal::AstrometryTransformLinear::operator* ( AstrometryTransformLinear const &  right) const
inherited

enables to combine linear tranformations: T1=T2*T3 is legal.

Definition at line 1237 of file AstrometryTransform.cc.

1237  {
1238  // There is a general routine in AstrometryTransformPolynomial that would do the job:
1239  // return AstrometryTransformLinear(AstrometryTransformPolynomial::operator*(right));
1240  // however, we are using this composition of linear stuff heavily in
1241  // AstrometryTransform::linearApproximation, itself used in inverseTransform::apply.
1242  // So, for sake of efficiency, and since it is easy, we take a shortcut:
1244  apply(right.Dx(), right.Dy(), result.dx(), result.dy());
1245  result.a11() = A11() * right.A11() + A12() * right.A21();
1246  result.a12() = A11() * right.A12() + A12() * right.A22();
1247  result.a21() = A21() * right.A11() + A22() * right.A21();
1248  result.a22() = A21() * right.A12() + A22() * right.A22();
1249  return result;
1250 }
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const override

◆ operator*() [2/2]

AstrometryTransformPolynomial lsst::jointcal::AstrometryTransformPolynomial::operator* ( AstrometryTransformPolynomial const &  right) const
inherited

Composition (internal stuff in quadruple precision)

Definition at line 1053 of file AstrometryTransform.cc.

1054  {
1055  // split each transform into 2d polynomials
1056  PolyXY plx(*this, 0);
1057  PolyXY ply(*this, 1);
1058  PolyXY prx(right, 0);
1059  PolyXY pry(right, 1);
1060 
1061  // compute the compositions
1062  PolyXY rx(composition(plx, prx, pry));
1063  PolyXY ry(composition(ply, prx, pry));
1064 
1065  // copy the results the hard way.
1066  AstrometryTransformPolynomial result(_order * right._order);
1067  for (std::size_t px = 0; px <= result._order; ++px)
1068  for (std::size_t py = 0; py <= result._order - px; ++py) {
1069  result.getCoefficient(px, py, 0) = rx.getCoefficient(px, py);
1070  result.getCoefficient(px, py, 1) = ry.getCoefficient(px, py);
1071  }
1072  return result;
1073 }

◆ operator+()

AstrometryTransformPolynomial lsst::jointcal::AstrometryTransformPolynomial::operator+ ( AstrometryTransformPolynomial const &  right) const
inherited

Addition.

Definition at line 1075 of file AstrometryTransform.cc.

1076  {
1077  if (_order >= right._order) {
1078  AstrometryTransformPolynomial res(*this);
1079  for (std::size_t i = 0; i <= right._order; ++i)
1080  for (std::size_t j = 0; j <= right._order - i; ++j) {
1081  res.getCoefficient(i, j, 0) += right.getCoefficient(i, j, 0);
1082  res.getCoefficient(i, j, 1) += right.getCoefficient(i, j, 1);
1083  }
1084  return res;
1085  } else
1086  return (right + (*this));
1087 }

◆ operator-()

AstrometryTransformPolynomial lsst::jointcal::AstrometryTransformPolynomial::operator- ( AstrometryTransformPolynomial const &  right) const
inherited

Subtraction.

Definition at line 1089 of file AstrometryTransform.cc.

1090  {
1091  AstrometryTransformPolynomial res(std::max(_order, right._order));
1092  for (std::size_t i = 0; i <= res._order; ++i)
1093  for (std::size_t j = 0; j <= res._order - i; ++j) {
1094  res.getCoefficient(i, j, 0) = coeffOrZero(i, j, 0) - right.coeffOrZero(i, j, 0);
1095  res.getCoefficient(i, j, 1) = coeffOrZero(i, j, 1) - right.coeffOrZero(i, j, 1);
1096  }
1097  return res;
1098 }
double coeffOrZero(std::size_t powX, std::size_t powY, std::size_t whichCoord) const
read access, zero if beyond order

◆ paramDerivatives()

void lsst::jointcal::AstrometryTransformPolynomial::paramDerivatives ( Point const &  where,
double *  dx,
double *  dy 
) const
overridevirtualinherited

Derivative w.r.t parameters.

Derivatives should be al least 2*NPar long. first Npar, for x, last Npar for y.

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 775 of file AstrometryTransform.cc.

776  { /* first half : dxout/dpar, second half : dyout/dpar */
777  computeMonomials(where.x, where.y, dx);
778  for (std::size_t k = 0; k < _nterms; ++k) {
779  dy[_nterms + k] = dx[k];
780  dx[_nterms + k] = dy[k] = 0;
781  }
782 }

◆ paramRef() [1/2]

double lsst::jointcal::AstrometryTransformPolynomial::paramRef ( Eigen::Index const  i) const
overridevirtualinherited

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 765 of file AstrometryTransform.cc.

765  {
766  assert(i < 2 * Eigen::Index(_nterms));
767  return _coeffs[i];
768 }

◆ paramRef() [2/2]

double & lsst::jointcal::AstrometryTransformPolynomial::paramRef ( Eigen::Index const  i)
overridevirtualinherited

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 770 of file AstrometryTransform.cc.

770  {
771  assert(i < 2 * Eigen::Index(_nterms));
772  return _coeffs[i];
773 }

◆ print()

void lsst::jointcal::AstrometryTransformLinear::print ( std::ostream out) const
overridevirtualinherited

print out of coefficients in a readable form.

Reimplemented from lsst::jointcal::AstrometryTransformPolynomial.

Definition at line 1295 of file AstrometryTransform.cc.

1295  {
1296  auto oldPrecision = stream.precision();
1297  stream.precision(12);
1298  stream << "Linear AstrometryTransform:" << std::endl;
1299  stream << A11() << " " << A12() << " + " << Dx() << std::endl;
1300  stream << A21() << " " << A22() << " + " << Dy() << std::endl;
1301  stream.precision(oldPrecision);
1302  stream << "determinant = " << determinant();
1303  stream.precision(oldPrecision);
1304 }
T endl(T... args)

◆ read()

void lsst::jointcal::AstrometryTransformPolynomial::read ( std::istream s)
inherited

Definition at line 1115 of file AstrometryTransform.cc.

1115  {
1116  int format;
1117  s >> format;
1118  if (format != 1)
1119  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1120  " AstrometryTransformPolynomial::read : format is not 1 ");
1121 
1122  string order;
1123  s >> order >> _order;
1124  if (order != "order")
1125  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1126  " AstrometryTransformPolynomial::read : expecting \"order\" and found " + order);
1127  setOrder(_order);
1128  for (std::size_t k = 0; k < 2 * _nterms; ++k) s >> _coeffs[k];
1129 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
void setOrder(std::size_t order)
Sets the polynomial order (the highest sum of exponents of the largest monomial).
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
table::Key< int > order

◆ roughInverse()

std::unique_ptr< AstrometryTransform > lsst::jointcal::AstrometryTransform::roughInverse ( const Frame region) const
virtualinherited

Rough inverse.

Stored by the numerical inverter to guess starting point for the trials. Just here to enable overloading.

Reimplemented in lsst::jointcal::TanRaDecToPixel, lsst::jointcal::TanPixelToRaDec, and lsst::jointcal::AstrometryTransformInverse.

Definition at line 195 of file AstrometryTransform.cc.

195  {
196  // "in" and "out" refer to the inverse direction.
197  Point centerOut = region.getCenter();
198  Point centerIn = apply(centerOut);
199  AstrometryTransformLinear der;
200  computeDerivative(centerOut, der, std::sqrt(region.getArea()) / 5.);
201  der = der.inverted();
202  der = AstrometryTransformLinearShift(centerOut.x, centerOut.y) * der *
203  AstrometryTransformLinearShift(-centerIn.x, -centerIn.y);
204  return std::unique_ptr<AstrometryTransform>(new AstrometryTransformLinear(der));
205 }
virtual void computeDerivative(Point const &where, AstrometryTransformLinear &derivative, const double step=0.01) const
Computes the local Derivative of a transform, w.r.t.
T sqrt(T... args)

◆ toAstMap()

std::shared_ptr< ast::Mapping > lsst::jointcal::AstrometryTransformPolynomial::toAstMap ( jointcal::Frame const &  domain) const
overridevirtualinherited

Create an equivalent AST mapping for this transformation, including an analytic inverse if possible.

Parameters
domainThe domain of the transform, to help find an inverse.
Returns
An AST Mapping that represents this transformation.

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 1100 of file AstrometryTransform.cc.

1100  {
1101  auto inverse = inversePolyTransform(*this, domain, 1e-7, _order + 2, 100);
1102  return std::make_shared<ast::PolyMap>(toAstPolyMapCoefficients(), inverse->toAstPolyMapCoefficients());
1103 }
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.

◆ transformErrors()

void lsst::jointcal::AstrometryTransform::transformErrors ( Point const &  where,
const double *  vIn,
double *  vOut 
) const
virtualinherited

transform errors (represented as double[3] in order V(xx),V(yy),Cov(xy))

Definition at line 162 of file AstrometryTransform.cc.

162  {
163  AstrometryTransformLinear der;
164  computeDerivative(where, der, 0.01);
165  double a11 = der.A11();
166  double a22 = der.A22();
167  double a21 = der.A21();
168  double a12 = der.A12();
169 
170  /* (a11 a12) (vxx vxy)
171  M = ( ) and V = ( )
172  (a21 a22) (xvy vyy)
173 
174  Vxx = Vin[0], vyy = Vin[1], Vxy = Vin[2];
175  we want to compute M*V*tp(M)
176  A lin alg light package would be perfect...
177  */
178  int xx = 0;
179  int yy = 1;
180  int xy = 2;
181  // M*V :
182 
183  double b11 = a11 * vIn[xx] + a12 * vIn[xy];
184  double b22 = a21 * vIn[xy] + a22 * vIn[yy];
185  double b12 = a11 * vIn[xy] + a12 * vIn[yy];
186  double b21 = a21 * vIn[xx] + a22 * vIn[xy];
187 
188  // (M*V) * tp(M)
189 
190  vOut[xx] = b11 * a11 + b12 * a12;
191  vOut[xy] = b11 * a21 + b12 * a22;
192  vOut[yy] = b21 * a21 + b22 * a22;
193 }

◆ transformPosAndErrors()

void lsst::jointcal::AstrometryTransformPolynomial::transformPosAndErrors ( const FatPoint in,
FatPoint out 
) const
overridevirtualinherited

a mix of apply and Derivative

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 656 of file AstrometryTransform.cc.

656  {
657  /*
658  The results from this routine were compared to what comes out
659  from apply and transformErrors. The Derivative routine was
660  checked against numerical derivatives from
661  AstrometryTransform::Derivative. (P.A dec 2009).
662 
663  This routine could be made much simpler by calling apply and
664  Derivative (i.e. you just suppress it, and the fallback is the
665  generic version in AstrometryTransform). BTW, I checked that both routines
666  provide the same result. This version is however faster
667  (monomials get recycled).
668  */
669  double monomials[_nterms]; // VLA
670 
671  FatPoint res; // to store the result, because nothing forbids &in == &out.
672 
673  double dermx[2 * _nterms]; // monomials for derivative w.r.t. x (VLA)
674  double *dermy = dermx + _nterms; // same for y
675  double xin = in.x;
676  double yin = in.y;
677 
678  double xx = 1;
679  double xxm1 = 1; // xx^(ix-1)
680  for (std::size_t ix = 0; ix <= _order; ++ix) {
681  std::size_t k = (ix) * (ix + 1) / 2;
682  // iy = 0
683  dermx[k] = ix * xxm1;
684  dermy[k] = 0;
685  monomials[k] = xx;
686  k += ix + 2;
687  double yy = yin;
688  double yym1 = 1; // yy^(iy-1)
689  for (std::size_t iy = 1; iy <= _order - ix; ++iy) {
690  monomials[k] = xx * yy;
691  dermx[k] = ix * xxm1 * yy;
692  dermy[k] = iy * xx * yym1;
693  yym1 *= yin;
694  yy *= yin;
695  k += ix + iy + 2;
696  }
697  xx *= xin;
698  if (ix >= 1) xxm1 *= xin;
699  }
700 
701  // output position
702  double xout = 0, yout = 0;
703  const double *c = &_coeffs[0];
704  const double *pm = &monomials[0];
705  for (int k = _nterms; k--;) xout += (*(pm++)) * (*(c++));
706  pm = &monomials[0];
707  for (int k = _nterms; k--;) yout += (*(pm++)) * (*(c++));
708  res.x = xout;
709  res.y = yout;
710 
711  // derivatives
712  c = &_coeffs[0];
713  const double *mx = &dermx[0];
714  const double *my = &dermy[0];
715  double a11 = 0, a12 = 0;
716  for (int k = _nterms; k--;) {
717  a11 += (*(mx++)) * (*c);
718  a12 += (*(my++)) * (*(c++));
719  }
720 
721  double a21 = 0, a22 = 0;
722  mx = &dermx[0];
723  my = &dermy[0];
724  for (int k = _nterms; k--;) {
725  a21 += (*(mx++)) * (*c);
726  a22 += (*(my++)) * (*(c++));
727  }
728 
729  // output co-variance
730  res.vx = a11 * (a11 * in.vx + 2 * a12 * in.vxy) + a12 * a12 * in.vy;
731  res.vy = a21 * a21 * in.vx + a22 * a22 * in.vy + 2. * a21 * a22 * in.vxy;
732  res.vxy = a21 * a11 * in.vx + a22 * a12 * in.vy + (a21 * a12 + a11 * a22) * in.vxy;
733  out = res;
734 }

◆ transformStar()

void lsst::jointcal::AstrometryTransform::transformStar ( FatPoint in) const
inlineinherited

Definition at line 107 of file AstrometryTransform.h.

107 { transformPosAndErrors(in, in); }
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const

◆ write() [1/2]

void lsst::jointcal::AstrometryTransform::write ( const std::string fileName) const
inherited

Definition at line 246 of file AstrometryTransform.cc.

246  {
247  ofstream s(fileName.c_str());
248  write(s);
249  bool ok = !s.fail();
250  s.close();
251  if (!ok)
252  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
253  "AstrometryTransform::write, something went wrong for file " + fileName);
254 }
T c_str(T... args)
void write(const std::string &fileName) const

◆ write() [2/2]

void lsst::jointcal::AstrometryTransformPolynomial::write ( std::ostream s) const
overridevirtualinherited

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 1105 of file AstrometryTransform.cc.

1105  {
1106  s << " AstrometryTransformPolynomial 1" << endl;
1107  s << "order " << _order << endl;
1108  int oldprec = s.precision();
1109  s << setprecision(12);
1110  for (std::size_t k = 0; k < 2 * _nterms; ++k) s << _coeffs[k] << ' ';
1111  s << endl;
1112  s << setprecision(oldprec);
1113 }
T precision(T... args)
T setprecision(T... args)

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