LSST Applications g063fba187b+fee0456c91,g0f08755f38+ea96e5a5a3,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+90257ff92a,g20f6ffc8e0+ea96e5a5a3,g217e2c1bcf+937a289c59,g28da252d5a+daa7da44eb,g2bbee38e9b+253935c60e,g2bc492864f+253935c60e,g3156d2b45e+6e55a43351,g32e5bea42b+31359a2a7a,g347aa1857d+253935c60e,g35bb328faa+a8ce1bb630,g3a166c0a6a+253935c60e,g3b1af351f3+a8ce1bb630,g3e281a1b8c+c5dd892a6c,g414038480c+416496e02f,g41af890bb2+afe91b1188,g599934f4f4+0db33f7991,g7af13505b9+e36de7bce6,g80478fca09+da231ba887,g82479be7b0+a4516e59e3,g858d7b2824+ea96e5a5a3,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+bc6ab8dfbd,gb58c049af0+d64f4d3760,gc28159a63d+253935c60e,gcab2d0539d+3f2b72788c,gcf0d15dbbd+4ea9c45075,gda6a2b7d83+4ea9c45075,gdaeeff99f8+1711a396fd,ge79ae78c31+253935c60e,gef2f8181fd+3031e3cf99,gf0baf85859+c1f95f4921,gfa517265be+ea96e5a5a3,gfa999e8aa5+17cd334064,w.2024.50
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
lsst::jointcal::AstrometryTransformLinear Class Reference

implements the linear transformations (6 real coefficients). More...

#include <AstrometryTransform.h>

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

Public Member Functions

 AstrometryTransformLinear ()
 the default constructor constructs the do-nothing transformation.
 
 AstrometryTransformLinear (AstrometryTransformPolynomial const &transform)
 This triggers an exception if P.getOrder() != 1.
 
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();
 
void print (std::ostream &out) const override
 prints the transform coefficients to stream.
 
void computeDerivative (Point const &where, AstrometryTransformLinear &derivative, double step=0.01) const override
 Computes the local Derivative of a transform, w.r.t.
 
AstrometryTransformLinear linearApproximation (Point const &where, double step=0.01) const override
 linear (local) approximation.
 
 AstrometryTransformLinear (double ox, double oy, double aa11, double aa12, double aa21, double aa22)
 Construct a AstrometryTransformLinear from parameters.
 
 AstrometryTransformLinear (AstrometryTransformIdentity const &)
 Handy converter:
 
std::unique_ptr< AstrometryTransformclone () const override
 returns a copy (allocated by new) of the transformation.
 
std::unique_ptr< AstrometryTransforminverseTransform (double precision, const Frame &region) const override
 returns an inverse transform. Numerical if not overloaded.
 
double A11 () const
 
double A12 () const
 
double A21 () const
 
double A22 () const
 
double Dx () const
 
double Dy () const
 
void apply (double xIn, double yIn, double &xOut, double &yOut) const override
 
virtual void apply (double xIn, 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.
 
Point apply (Point const &in) const
 All these apply(..) shadow the virtual one in derived classes, unless one writes "using AstrometryTransform::apply".
 
Frame apply (Frame const &inputframe, bool inscribed) const
 Transform a bounding box, taking either the inscribed or circumscribed box.
 
std::size_t getOrder () const
 Returns the polynomial order.
 
virtual void transformPosAndErrors (const FatPoint &in, FatPoint &out) const override
 a mix of apply and Derivative
 
std::size_t getNpar () const override
 total number of parameters
 
double fit (StarMatchList const &starMatchList) override
 guess what
 
AstrometryTransformPolynomial operator* (AstrometryTransformPolynomial const &right) const
 Composition (internal stuff in quadruple precision)
 
AstrometryTransformPolynomial operator+ (AstrometryTransformPolynomial const &right) const
 Addition.
 
AstrometryTransformPolynomial operator- (AstrometryTransformPolynomial const &right) const
 Subtraction.
 
std::unique_ptr< AstrometryTransformcomposeAndReduce (AstrometryTransformPolynomial const &right) const
 Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.
 
virtual std::unique_ptr< AstrometryTransformcomposeAndReduce (AstrometryTransform const &right) const
 Return a reduced composition of newTransform = this(right()), or nullptr if it cannot be reduced.
 
double coeffOrZero (std::size_t powX, std::size_t powY, std::size_t whichCoord) const
 read access, zero if beyond order
 
double determinant () const
 
double paramRef (Eigen::Index i) const override
 
double & paramRef (Eigen::Index i) override
 
void paramDerivatives (Point const &where, double *dx, double *dy) const override
 Derivative w.r.t parameters.
 
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.
 
void write (std::ostream &s) const override
 
void write (const std::string &fileName) const
 
void read (std::istream &s)
 
std::string __str__ () const
 
void transformStar (FatPoint &in) const
 
virtual double getJacobian (Point const &point) const
 returns the local jacobian.
 
virtual double getJacobian (double x, double y) const
 returns the local jacobian.
 
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))
 
void getParams (double *params) const
 params should be at least Npar() long
 
void offsetParams (Eigen::VectorXd const &delta)
 
virtual std::unique_ptr< AstrometryTransformroughInverse (const Frame &region) const
 Rough inverse.
 
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.
 
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.
 

Protected Member Functions

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

Friends

class AstrometryTransform
 
class AstrometryTransformIdentity
 
class AstrometryTransformPolynomial
 

Detailed Description

implements the linear transformations (6 real coefficients).

Definition at line 426 of file AstrometryTransform.h.

Constructor & Destructor Documentation

◆ AstrometryTransformLinear() [1/4]

lsst::jointcal::AstrometryTransformLinear::AstrometryTransformLinear ( )
inline

the default constructor constructs the do-nothing transformation.

Definition at line 431 of file AstrometryTransform.h.

◆ AstrometryTransformLinear() [2/4]

lsst::jointcal::AstrometryTransformLinear::AstrometryTransformLinear ( AstrometryTransformPolynomial const & transform)
explicit

This triggers an exception if P.getOrder() != 1.

Definition at line 1228 of file AstrometryTransform.cc.

1230 if (transform.getOrder() != 1)
1232 "Trying to build a AstrometryTransformLinear from a higher order transform. Aborting. ");
1234}
table::Key< int > transform
Reports invalid arguments.
Definition Runtime.h:66

◆ AstrometryTransformLinear() [3/4]

lsst::jointcal::AstrometryTransformLinear::AstrometryTransformLinear ( double ox,
double oy,
double aa11,
double aa12,
double aa21,
double aa22 )

◆ AstrometryTransformLinear() [4/4]

lsst::jointcal::AstrometryTransformLinear::AstrometryTransformLinear ( AstrometryTransformIdentity const & )
inline

Handy converter:

Definition at line 462 of file AstrometryTransform.h.

Member Function Documentation

◆ __str__()

std::string lsst::jointcal::AstrometryTransform::__str__ ( ) const
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.

◆ a11()

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

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
inline

Definition at line 471 of file AstrometryTransform.h.

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

◆ a12()

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

Definition at line 480 of file AstrometryTransform.h.

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

◆ A12()

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

Definition at line 472 of file AstrometryTransform.h.

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

◆ a21()

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

Definition at line 481 of file AstrometryTransform.h.

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

◆ A21()

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

Definition at line 473 of file AstrometryTransform.h.

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

◆ a22()

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

Definition at line 482 of file AstrometryTransform.h.

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

◆ A22()

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

Definition at line 474 of file AstrometryTransform.h.

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

◆ apply() [1/5]

virtual void lsst::jointcal::AstrometryTransform::apply ( double xIn,
double yIn,
double & xOut,
double & yOut ) const
virtual

◆ apply() [2/5]

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

Implements lsst::jointcal::AstrometryTransform.

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

Definition at line 311 of file AstrometryTransform.cc.

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

◆ apply() [3/5]

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

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 309 of file AstrometryTransform.cc.

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

◆ apply() [4/5]

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

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

Definition at line 309 of file AstrometryTransform.h.

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

◆ apply() [5/5]

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

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

Definition at line 309 of file AstrometryTransform.h.

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

◆ clone()

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

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

Implements lsst::jointcal::AstrometryTransform.

Definition at line 464 of file AstrometryTransform.h.

464 {
466 }
AstrometryTransformLinear()
the default constructor constructs the do-nothing transformation.

◆ 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 756 of file AstrometryTransform.cc.

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

◆ composeAndReduce() [1/2]

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 from lsst::jointcal::AstrometryTransform.

Definition at line 131 of file AstrometryTransform.cc.

96 { // by default no way to compose
98}

◆ composeAndReduce() [2/2]

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 944 of file AstrometryTransform.cc.

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

◆ computeDerivative()

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

Computes the local Derivative of a transform, w.r.t.

the Derivative is represented by a AstrometryTransformLinear, in which (hopefully), the offset terms are zero.

position.

Step is used for numerical derivation.

Derivative should transform a vector of offsets into a vector of offsets.

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 1251 of file AstrometryTransform.cc.

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

◆ determinant()

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

Definition at line 826 of file AstrometryTransform.cc.

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

◆ dx()

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

Definition at line 483 of file AstrometryTransform.h.

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

◆ Dx()

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

Definition at line 475 of file AstrometryTransform.h.

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

◆ dy()

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

Definition at line 484 of file AstrometryTransform.h.

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

◆ Dy()

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

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.

Definition at line 926 of file AstrometryTransform.cc.

926 {
927 if (starMatchList.size() < _nterms) {
928 LOGLS_FATAL(_log, "AstrometryTransformPolynomial::fit trying to fit a polynomial transform of order "
929 << _order << " with only " << starMatchList.size() << " matches.");
930 return -1;
931 }
932
933 AstrometryTransformPolynomial conditionner = shiftAndNormalize(starMatchList);
934
935 computeFit(starMatchList, conditionner, false); // get a rough solution
936 computeFit(starMatchList, conditionner, true); // weight with it
937 double chi2 = computeFit(starMatchList, conditionner, true); // once more
938
939 (*this) = (*this) * conditionner;
940 if (starMatchList.size() == _nterms) return 0;
941 return chi2;
942}
#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 750 of file AstrometryTransform.cc.

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

◆ 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 741 of file AstrometryTransform.cc.

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

◆ getJacobian() [1/2]

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

returns the local jacobian.

Definition at line 100 of file AstrometryTransform.cc.

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

◆ 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::AstrometryTransformPolynomial::getNpar ( ) const
inlineoverridevirtualinherited

total number of parameters

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 321 of file AstrometryTransform.h.

321{ return 2 * _nterms; }

◆ 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 217 of file AstrometryTransform.cc.

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

◆ inverseTransform()

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

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 1289 of file AstrometryTransform.cc.

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

◆ inverted()

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

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

Definition at line 1262 of file AstrometryTransform.cc.

1262 {
1263 //
1264 // (T1,M1) * (T2,M2) = 1 i.e (0,1) implies
1265 // T1 = -M1 * T2
1266 // M1 = M2^(-1)
1267 //
1268
1269 double a11 = A11();
1270 double a12 = A12();
1271 double a21 = A21();
1272 double a22 = A22();
1273 double d = (a11 * a22 - a12 * a21);
1274 if (d == 0) {
1275 LOGL_FATAL(_log,
1276 "AstrometryTransformLinear::invert singular transformation: transform contents will be "
1277 "dumped to stderr.");
1278 print(cerr);
1279 }
1280
1281 AstrometryTransformLinear result(0, 0, a22 / d, -a12 / d, -a21 / d, a11 / d);
1282 double rdx, rdy;
1283 result.apply(Dx(), Dy(), rdx, rdy);
1284 result.dx() = -rdx;
1285 result.dy() = -rdy;
1286 return result;
1287}
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
prints the transform coefficients to stream.

◆ linearApproximation()

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

linear (local) approximation.

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 1258 of file AstrometryTransform.cc.

1258 {
1259 return *this;
1260}

◆ offsetParams()

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

Definition at line 222 of file AstrometryTransform.cc.

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

◆ operator*() [1/2]

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

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

Definition at line 1236 of file AstrometryTransform.cc.

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

◆ operator*() [2/2]

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

Composition (internal stuff in quadruple precision)

Definition at line 1052 of file AstrometryTransform.cc.

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

◆ operator+()

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

Addition.

Definition at line 1074 of file AstrometryTransform.cc.

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

◆ operator-()

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

Subtraction.

Definition at line 1088 of file AstrometryTransform.cc.

1089 {
1090 AstrometryTransformPolynomial res(std::max(_order, right._order));
1091 for (std::size_t i = 0; i <= res._order; ++i)
1092 for (std::size_t j = 0; j <= res._order - i; ++j) {
1093 res.getCoefficient(i, j, 0) = coeffOrZero(i, j, 0) - right.coeffOrZero(i, j, 0);
1094 res.getCoefficient(i, j, 1) = coeffOrZero(i, j, 1) - right.coeffOrZero(i, j, 1);
1095 }
1096 return res;
1097}
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 776 of file AstrometryTransform.cc.

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

◆ paramRef() [1/2]

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

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 766 of file AstrometryTransform.cc.

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

◆ paramRef() [2/2]

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

Reimplemented from lsst::jointcal::AstrometryTransform.

Definition at line 771 of file AstrometryTransform.cc.

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

◆ print()

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

prints the transform coefficients to stream.

Implements lsst::jointcal::AstrometryTransform.

Definition at line 1294 of file AstrometryTransform.cc.

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

◆ read()

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

Definition at line 1114 of file AstrometryTransform.cc.

1114 {
1115 int format;
1116 s >> format;
1117 if (format != 1)
1118 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1119 " AstrometryTransformPolynomial::read : format is not 1 ");
1120
1121 string order;
1122 s >> order >> _order;
1123 if (order != "order")
1124 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1125 " AstrometryTransformPolynomial::read : expecting \"order\" and found " + order);
1126 setOrder(_order);
1127 for (std::size_t k = 0; k < 2 * _nterms; ++k) s >> _coeffs[k];
1128}
#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).
format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition history.py:173
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::AstrometryTransformInverse, lsst::jointcal::TanPixelToRaDec, and lsst::jointcal::TanRaDecToPixel.

Definition at line 196 of file AstrometryTransform.cc.

196 {
197 // "in" and "out" refer to the inverse direction.
198 Point centerOut = region.getCenter();
199 Point centerIn = apply(centerOut);
200 AstrometryTransformLinear der;
201 computeDerivative(centerOut, der, std::sqrt(region.getArea()) / 5.);
202 der = der.inverted();
203 der = AstrometryTransformLinearShift(centerOut.x, centerOut.y) * der *
204 AstrometryTransformLinearShift(-centerIn.x, -centerIn.y);
205 return std::unique_ptr<AstrometryTransform>(new AstrometryTransformLinear(der));
206}
virtual void computeDerivative(Point const &where, AstrometryTransformLinear &derivative, 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 1099 of file AstrometryTransform.cc.

1099 {
1100 auto inverse = inversePolyTransform(*this, domain, 1e-7, _order + 2, 100);
1101 return std::make_shared<ast::PolyMap>(toAstPolyMapCoefficients(), inverse->toAstPolyMapCoefficients());
1102}
std::shared_ptr< AstrometryTransformPolynomial > inversePolyTransform(AstrometryTransform const &forward, Frame const &domain, double 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 163 of file AstrometryTransform.cc.

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

◆ 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 657 of file AstrometryTransform.cc.

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

◆ 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 247 of file AstrometryTransform.cc.

247 {
248 ofstream s(fileName.c_str());
249 write(s);
250 bool ok = !s.fail();
251 s.close();
252 if (!ok)
253 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
254 "AstrometryTransform::write, something went wrong for file " + fileName);
255}
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 1104 of file AstrometryTransform.cc.

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

Friends And Related Symbol Documentation

◆ AstrometryTransform

friend class AstrometryTransform
friend

Definition at line 486 of file AstrometryTransform.h.

◆ AstrometryTransformIdentity

friend class AstrometryTransformIdentity
friend

Definition at line 487 of file AstrometryTransform.h.

◆ AstrometryTransformPolynomial

friend class AstrometryTransformPolynomial
friend

Definition at line 488 of file AstrometryTransform.h.


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