LSSTApplications  16.0-10-g4f78f78+16,16.0-10-gc1446dd+42,16.0-11-g09ed895+1,16.0-13-g7649090,16.0-14-g0a28612+1,16.0-14-g6c7ed55+16,16.0-15-ga29f190+1,16.0-16-g89065d4+14,16.0-16-gd8e3590+16,16.0-16-ge6a35c8+6,16.0-17-g7e0e4ff+10,16.0-17-ga3d2e9f,16.0-19-gb830ed4e+16,16.0-2-g0febb12+21,16.0-2-g9d5294e+61,16.0-2-ga8830df+5,16.0-24-gc1c7f52+9,16.0-24-gd8faad8+3,16.0-3-ge00e371+21,16.0-36-g07840cb1,16.0-4-g18f3627+5,16.0-4-g5f3a788+20,16.0-4-ga3eb747+10,16.0-4-gabf74b7+16,16.0-4-gade8416+9,16.0-4-gb13d127+5,16.0-5-g6a53317+21,16.0-5-gb3f8a4b+74,16.0-5-gef99c9f+12,16.0-6-g9321be7+4,16.0-6-gcbc7b31+22,16.0-6-gf49912c+16,16.0-63-gae20905ba,16.0-7-gd2eeba5+31,16.0-8-g21fd5fe+16,16.0-8-g3a9f023+12,16.0-8-g4734f7a,16.0-8-ge230541+3,16.0-9-g85d1a16+16,master-g72da5ad0b5+6,w.2018.47
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst::jointcal::TanRaDec2Pix Class Reference

This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) More...

#include <Gtransfo.h>

Inheritance diagram for lsst::jointcal::TanRaDec2Pix:
lsst::jointcal::Gtransfo

Public Member Functions

 TanRaDec2Pix (GtransfoLin const &tan2Pix, Point const &tangentPoint)
 assume degrees everywhere. More...
 
 TanRaDec2Pix ()
 
GtransfoLin getLinPart () const
 The Linear part (corresponding to CD's and CRPIX's) More...
 
void setTangentPoint (Point const &tangentPoint)
 Resets the projection (or tangent) point. More...
 
Point getTangentPoint () const
 tangent point coordinates (degrees) More...
 
void apply (const double xIn, const double yIn, double &xOut, double &yOut) const
 
void transformPosAndErrors (const FatPoint &in, FatPoint &out) const
 transform with analytical derivatives More...
 
TanPix2RaDec inverted () const
 exact typed inverse: More...
 
std::unique_ptr< GtransforoughInverse (const Frame &region) const
 Overload the "generic routine" (available for all Gtransfo types. More...
 
std::unique_ptr< GtransfoinverseTransfo (const double precision, const Frame &region) const
 Inverse transfo: returns a TanPix2RaDec. More...
 
void dump (std::ostream &stream) const
 dumps the transfo coefficients to stream. More...
 
std::unique_ptr< Gtransfoclone () const
 returns a copy (allocated by new) of the transformation. More...
 
double fit (StarMatchList const &starMatchList)
 fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch). More...
 
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 Gtransfo::apply". More...
 
Frame apply (Frame const &inputframe, bool inscribed) const
 Transform a bounding box, taking either the inscribed or circumscribed box. More...
 
std::string __str__ ()
 
void transformStar (FatPoint &in) const
 allows to write MyTransfo(MyStar) More...
 
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 std::unique_ptr< GtransfocomposeAndReduce (Gtransfo const &right) const
 Return a reduced composition of newTransfo = this(right()), or nullptr if it cannot be reduced. More...
 
virtual void computeDerivative (Point const &where, GtransfoLin &derivative, const double step=0.01) const
 Computes the local Derivative of a transfo, w.r.t. More...
 
virtual GtransfoLin linearApproximation (Point const &where, const double step=0.01) const
 linear (local) approximation. 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 double paramRef (const int i) const
 
virtual double & paramRef (const int i)
 
virtual void paramDerivatives (Point const &where, double *dx, double *dy) const
 Derivative w.r.t parameters. More...
 
virtual int getNpar () const
 returns the number of parameters (to compute chi2's) More...
 
virtual std::shared_ptr< ast::MappingtoAstMap (jointcal::Frame const &domain) const
 Create an equivalent AST mapping for this transformation, including an analytic inverse if possible. More...
 
void write (const std::string &fileName) const
 
virtual void write (std::ostream &stream) const
 

Detailed Description

This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane)

this transfo does not implement corrections, since they are defined the other way around (from pixels to sky), and not invertible analytically. The inversion of tangent point WCS (TanPix2RaDec) is obtained via inverseTransfo().

Definition at line 676 of file Gtransfo.h.

Constructor & Destructor Documentation

◆ TanRaDec2Pix() [1/2]

lsst::jointcal::TanRaDec2Pix::TanRaDec2Pix ( GtransfoLin const &  tan2Pix,
Point const &  tangentPoint 
)

assume degrees everywhere.

Definition at line 1572 of file Gtransfo.cc.

1572  : linTan2Pix(tan2Pix) {
1573  setTangentPoint(tangentPoint);
1574 }
void setTangentPoint(Point const &tangentPoint)
Resets the projection (or tangent) point.
Definition: Gtransfo.cc:1576

◆ TanRaDec2Pix() [2/2]

lsst::jointcal::TanRaDec2Pix::TanRaDec2Pix ( )

Definition at line 1585 of file Gtransfo.cc.

1585  : linTan2Pix() {
1586  ra0 = dec0 = 0;
1587  cos0 = 1;
1588  sin0 = 0;
1589 }

Member Function Documentation

◆ __str__()

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

Definition at line 94 of file Gtransfo.h.

94  {
96  dump(s);
97  return s.str();
98  }
T str(T... args)
solver_t * s
virtual void dump(std::ostream &stream=std::cout) const =0
dumps the transfo coefficients to stream.

◆ apply() [1/4]

void lsst::jointcal::Gtransfo::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 Gtransfo.h.

71 { apply(in.x, in.y, out.x, out.y); }
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0

◆ apply() [2/4]

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

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

Definition at line 75 of file Gtransfo.h.

75  {
76  double xout, yout;
77  apply(in.x, in.y, xout, yout);
78  return Point(xout, yout);
79  }
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0

◆ apply() [3/4]

Frame lsst::jointcal::Gtransfo::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 74 of file Gtransfo.cc.

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

◆ apply() [4/4]

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

Implements lsst::jointcal::Gtransfo.

Definition at line 1648 of file Gtransfo.cc.

1648  {
1649  double ra = deg2rad(xIn);
1650  double dec = deg2rad(yIn);
1651  if (ra - ra0 > M_PI) ra -= (2. * M_PI);
1652  if (ra - ra0 < -M_PI) ra += (2. * M_PI);
1653  // Code inspired from worldpos.c in wcssubs (ancestor of the wcslib)
1654  // The same code is copied in ::transformPosAndErrors()
1655  double coss = std::cos(dec);
1656  double sins = std::sin(dec);
1657  double l = std::sin(ra - ra0) * coss;
1658  double m = sins * sin0 + coss * cos0 * std::cos(ra - ra0);
1659  l = l / m;
1660  m = (sins * cos0 - coss * sin0 * std::cos(ra - ra0)) / m;
1661  // l and m are now coordinates in the tangent plane, in radians.
1662  l = rad2deg(l);
1663  m = rad2deg(m);
1664  linTan2Pix.apply(l, m, xOut, yOut);
1665 }
double dec
Definition: Match.cc:41
#define M_PI
Definition: ListMatch.cc:31
T sin(T... args)
T cos(T... args)
int m
Definition: SpanSet.cc:49
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const override
Definition: Gtransfo.cc:546

◆ clone()

std::unique_ptr< Gtransfo > lsst::jointcal::TanRaDec2Pix::clone ( ) const
virtual

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

Implements lsst::jointcal::Gtransfo.

Definition at line 1684 of file Gtransfo.cc.

1684  {
1685  return std::unique_ptr<Gtransfo>(new TanRaDec2Pix(*this));
1686 }
STL class.

◆ composeAndReduce()

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

Return a reduced composition of newTransfo = 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 gtransfo, or nullptr if no such reduction is possible.

Reimplemented in lsst::jointcal::GtransfoIdentity.

Definition at line 92 of file Gtransfo.cc.

93  { // by default no way to compose
94  return std::unique_ptr<Gtransfo>(nullptr);
95 }
STL class.

◆ computeDerivative()

void lsst::jointcal::Gtransfo::computeDerivative ( Point const &  where,
GtransfoLin derivative,
const double  step = 0.01 
) const
virtualinherited

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

the Derivative is represented by a GtransfoLin, 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 in lsst::jointcal::GtransfoLin, lsst::jointcal::GtransfoPoly, and lsst::jointcal::GtransfoIdentity.

Definition at line 116 of file Gtransfo.cc.

116  {
117  double x = where.x;
118  double y = where.y;
119  double xp0, yp0;
120  apply(x, y, xp0, yp0);
121 
122  double xp, yp;
123  apply(x + step, y, xp, yp);
124  derivative.a11() = (xp - xp0) / step;
125  derivative.a21() = (yp - yp0) / step;
126  apply(x, y + step, xp, yp);
127  derivative.a12() = (xp - xp0) / step;
128  derivative.a22() = (yp - yp0) / step;
129  derivative.dx() = 0;
130  derivative.dy() = 0;
131 }
int y
Definition: SpanSet.cc:49
int const step
double x
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0

◆ dump()

void lsst::jointcal::TanRaDec2Pix::dump ( std::ostream stream) const
virtual

dumps the transfo coefficients to stream.

Implements lsst::jointcal::Gtransfo.

Definition at line 1671 of file Gtransfo.cc.

1671  {
1672  Point tp = getTangentPoint();
1673  stream << " tan2pix " << linTan2Pix << " tangent point " << tp.x << ' ' << tp.y << endl;
1674 }
T endl(T... args)
Point getTangentPoint() const
tangent point coordinates (degrees)
Definition: Gtransfo.cc:1591

◆ fit()

double lsst::jointcal::TanRaDec2Pix::fit ( StarMatchList const &  starMatchList)
virtual

fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch).

After the fit this(p1) yields approximately p2. The returned value is the sum of squared residuals. If you want to fit a partial transfo (e.g. such that this(T1(p1)) = T2(p2), use StarMatchList::applyTransfo beforehand.

Implements lsst::jointcal::Gtransfo.

Definition at line 1688 of file Gtransfo.cc.

1688  {
1689  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1690  "TanRaDec2Pix::fit is NOT implemented (although it is doable)) ");
1691  return -1;
1692 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getJacobian() [1/2]

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

returns the local jacobian.

Definition at line 111 of file Gtransfo.h.

111 { return getJacobian(point.x, point.y); }
virtual double getJacobian(Point const &point) const
returns the local jacobian.
Definition: Gtransfo.h:111

◆ getJacobian() [2/2]

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

returns the local jacobian.

Definition at line 97 of file Gtransfo.cc.

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

◆ getLinPart()

GtransfoLin lsst::jointcal::TanRaDec2Pix::getLinPart ( ) const

The Linear part (corresponding to CD's and CRPIX's)

Definition at line 1593 of file Gtransfo.cc.

1593 { return linTan2Pix; }

◆ getNpar()

virtual int lsst::jointcal::Gtransfo::getNpar ( ) const
inlinevirtualinherited

returns the number of parameters (to compute chi2's)

Reimplemented in lsst::jointcal::GtransfoLinScale, lsst::jointcal::GtransfoLinRot, lsst::jointcal::GtransfoLinShift, lsst::jointcal::GtransfoPoly, and lsst::jointcal::GtransfoIdentity.

Definition at line 180 of file Gtransfo.h.

180 { return 0; }

◆ getParams()

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

params should be at least Npar() long

Definition at line 210 of file Gtransfo.cc.

210  {
211  int npar = getNpar();
212  for (int i = 0; i < npar; ++i) params[i] = paramRef(i);
213 }
virtual int getNpar() const
returns the number of parameters (to compute chi2&#39;s)
Definition: Gtransfo.h:180
virtual double paramRef(const int i) const
Definition: Gtransfo.cc:220

◆ getTangentPoint()

Point lsst::jointcal::TanRaDec2Pix::getTangentPoint ( ) const

tangent point coordinates (degrees)

Definition at line 1591 of file Gtransfo.cc.

1591 { return Point(rad2deg(ra0), rad2deg(dec0)); }

◆ inverseTransfo()

std::unique_ptr< Gtransfo > lsst::jointcal::TanRaDec2Pix::inverseTransfo ( const double  precision,
const Frame region 
) const
virtual

Inverse transfo: returns a TanPix2RaDec.

Reimplemented from lsst::jointcal::Gtransfo.

Definition at line 1680 of file Gtransfo.cc.

1680  {
1681  return std::unique_ptr<Gtransfo>(new TanPix2RaDec(getLinPart().inverted(), getTangentPoint()));
1682 }
Point getTangentPoint() const
tangent point coordinates (degrees)
Definition: Gtransfo.cc:1591
STL class.
GtransfoLin getLinPart() const
The Linear part (corresponding to CD&#39;s and CRPIX&#39;s)
Definition: Gtransfo.cc:1593
TanPix2RaDec inverted() const
exact typed inverse:
Definition: Gtransfo.cc:1667

◆ inverted()

TanPix2RaDec lsst::jointcal::TanRaDec2Pix::inverted ( ) const

exact typed inverse:

Definition at line 1667 of file Gtransfo.cc.

1667  {
1668  return TanPix2RaDec(getLinPart().inverted(), getTangentPoint());
1669 }
Point getTangentPoint() const
tangent point coordinates (degrees)
Definition: Gtransfo.cc:1591
GtransfoLin getLinPart() const
The Linear part (corresponding to CD&#39;s and CRPIX&#39;s)
Definition: Gtransfo.cc:1593
TanPix2RaDec inverted() const
exact typed inverse:
Definition: Gtransfo.cc:1667

◆ linearApproximation()

GtransfoLin lsst::jointcal::Gtransfo::linearApproximation ( Point const &  where,
const double  step = 0.01 
) const
virtualinherited

linear (local) approximation.

Reimplemented in lsst::jointcal::GtransfoLin, and lsst::jointcal::GtransfoIdentity.

Definition at line 133 of file Gtransfo.cc.

133  {
134  Point outwhere = apply(where);
135  GtransfoLin der;
136  computeDerivative(where, der, step);
137  return GtransfoLinShift(outwhere.x, outwhere.y) * der * GtransfoLinShift(-where.x, -where.y);
138 }
virtual void computeDerivative(Point const &where, GtransfoLin &derivative, const double step=0.01) const
Computes the local Derivative of a transfo, w.r.t.
Definition: Gtransfo.cc:116
int const step
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0

◆ offsetParams()

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

Definition at line 215 of file Gtransfo.cc.

215  {
216  int npar = getNpar();
217  for (int i = 0; i < npar; ++i) paramRef(i) += delta[i];
218 }
virtual int getNpar() const
returns the number of parameters (to compute chi2&#39;s)
Definition: Gtransfo.h:180
virtual double paramRef(const int i) const
Definition: Gtransfo.cc:220

◆ paramDerivatives()

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

Derivative w.r.t parameters.

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

Reimplemented in lsst::jointcal::GtransfoPoly.

Definition at line 229 of file Gtransfo.cc.

229  {
230  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
231  "Gtransfo::paramDerivatives() should never be called ");
232 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ paramRef() [1/2]

double lsst::jointcal::Gtransfo::paramRef ( const int  i) const
virtualinherited

Reimplemented in lsst::jointcal::GtransfoPoly.

Definition at line 220 of file Gtransfo.cc.

220  {
221  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
222  std::string("Gtransfo::paramRef should never be called "));
223 }
STL class.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ paramRef() [2/2]

double & lsst::jointcal::Gtransfo::paramRef ( const int  i)
virtualinherited

Reimplemented in lsst::jointcal::GtransfoPoly.

Definition at line 225 of file Gtransfo.cc.

225  {
226  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Gtransfo::paramRef should never be called ");
227 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ roughInverse()

std::unique_ptr< Gtransfo > lsst::jointcal::TanRaDec2Pix::roughInverse ( const Frame region) const
virtual

Overload the "generic routine" (available for all Gtransfo types.

Reimplemented from lsst::jointcal::Gtransfo.

Definition at line 1676 of file Gtransfo.cc.

1676  {
1677  return std::unique_ptr<Gtransfo>(new TanPix2RaDec(getLinPart().inverted(), getTangentPoint()));
1678 }
Point getTangentPoint() const
tangent point coordinates (degrees)
Definition: Gtransfo.cc:1591
STL class.
GtransfoLin getLinPart() const
The Linear part (corresponding to CD&#39;s and CRPIX&#39;s)
Definition: Gtransfo.cc:1593
TanPix2RaDec inverted() const
exact typed inverse:
Definition: Gtransfo.cc:1667

◆ setTangentPoint()

void lsst::jointcal::TanRaDec2Pix::setTangentPoint ( Point const &  tangentPoint)

Resets the projection (or tangent) point.

Definition at line 1576 of file Gtransfo.cc.

1576  {
1577  /* the radian to degrees conversion after projection
1578  is handled in apply */
1579  ra0 = deg2rad(tangentPoint.x);
1580  dec0 = deg2rad(tangentPoint.y);
1581  cos0 = std::cos(dec0);
1582  sin0 = std::sin(dec0);
1583 }
T sin(T... args)
T cos(T... args)

◆ toAstMap()

virtual std::shared_ptr<ast::Mapping> lsst::jointcal::Gtransfo::toAstMap ( jointcal::Frame const &  domain) const
inlinevirtualinherited

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

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

Reimplemented in lsst::jointcal::GtransfoPoly, and lsst::jointcal::GtransfoIdentity.

Definition at line 189 of file Gtransfo.h.

189  {
190  throw std::logic_error("toAstMap is not implemented for this class.");
191  }
STL class.

◆ transformErrors()

void lsst::jointcal::Gtransfo::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 157 of file Gtransfo.cc.

157  {
158  GtransfoLin der;
159  computeDerivative(where, der, 0.01);
160  double a11 = der.A11();
161  double a22 = der.A22();
162  double a21 = der.A21();
163  double a12 = der.A12();
164 
165  /* (a11 a12) (vxx vxy)
166  M = ( ) and V = ( )
167  (a21 a22) (xvy vyy)
168 
169  Vxx = Vin[0], vyy = Vin[1], Vxy = Vin[2];
170  we want to compute M*V*tp(M)
171  A lin alg light package would be perfect...
172  */
173  int xx = 0;
174  int yy = 1;
175  int xy = 2;
176  // M*V :
177 
178  double b11 = a11 * vIn[xx] + a12 * vIn[xy];
179  double b22 = a21 * vIn[xy] + a22 * vIn[yy];
180  double b12 = a11 * vIn[xy] + a12 * vIn[yy];
181  double b21 = a21 * vIn[xx] + a22 * vIn[xy];
182 
183  // (M*V) * tp(M)
184 
185  vOut[xx] = b11 * a11 + b12 * a12;
186  vOut[xy] = b11 * a21 + b12 * a22;
187  vOut[yy] = b21 * a21 + b22 * a22;
188 }
virtual void computeDerivative(Point const &where, GtransfoLin &derivative, const double step=0.01) const
Computes the local Derivative of a transfo, w.r.t.
Definition: Gtransfo.cc:116

◆ transformPosAndErrors()

void lsst::jointcal::TanRaDec2Pix::transformPosAndErrors ( const FatPoint in,
FatPoint out 
) const
virtual

transform with analytical derivatives

Reimplemented from lsst::jointcal::Gtransfo.

Definition at line 1596 of file Gtransfo.cc.

1596  {
1597  /* this routine is very similar to apply, but also propagates errors.
1598  The deg2rad and rad2deg are ignored for errors because they act as
1599  2 global scalings that cancel each other.
1600  Derivatives were computed using maple:
1601 
1602  l1 := sin(a - a0)*cos(d);
1603  m1 := sin(d)*sin(d0)+cos(d)*cos(d0)*cos(a-a0);
1604  l2 := sin(d)*cos(d0)-cos(d)*sin(d0)*cos(a-a0);
1605  simplify(diff(l1/m1,a));
1606  simplify(diff(l1/m1,d));
1607  simplify(diff(l2/m1,a));
1608  simplify(diff(l2/m1,d));
1609 
1610  Checked against Gtransfo::transformPosAndErrors (dec 09)
1611  */
1612  double ra = deg2rad(in.x);
1613  double dec = deg2rad(in.y);
1614  if (ra - ra0 > M_PI) ra -= (2. * M_PI);
1615  if (ra - ra0 < -M_PI) ra += (2. * M_PI);
1616  // Code inspired from worldpos.c in wcssubs (ancestor of the wcslib)
1617  // The same code is copied in ::apply()
1618 
1619  double coss = std::cos(dec);
1620  double sins = std::sin(dec);
1621  double sinda = std::sin(ra - ra0);
1622  double cosda = std::cos(ra - ra0);
1623  double l = sinda * coss;
1624  double m = sins * sin0 + coss * cos0 * cosda;
1625  l = l / m;
1626  m = (sins * cos0 - coss * sin0 * cosda) / m;
1627 
1628  // derivatives
1629  double deno =
1630  sq(sin0) - sq(coss) + sq(coss * cos0) * (1 + sq(cosda)) + 2 * sins * sin0 * coss * cos0 * cosda;
1631  double a11 = coss * (cosda * sins * sin0 + coss * cos0) / deno;
1632  double a12 = -sinda * sin0 / deno;
1633  double a21 = coss * sinda * sins / deno;
1634  double a22 = cosda / deno;
1635 
1636  FatPoint tmp;
1637  tmp.vx = a11 * (a11 * in.vx + 2 * a12 * in.vxy) + a12 * a12 * in.vy;
1638  tmp.vy = a21 * a21 * in.vx + a22 * a22 * in.vy + 2. * a21 * a22 * in.vxy;
1639  tmp.vxy = a21 * a11 * in.vx + a22 * a12 * in.vy + (a21 * a12 + a11 * a22) * in.vxy;
1640 
1641  // l and m are now coordinates in the tangent plane, in radians.
1642  tmp.x = rad2deg(l);
1643  tmp.y = rad2deg(m);
1644 
1645  linTan2Pix.transformPosAndErrors(tmp, out);
1646 }
double dec
Definition: Match.cc:41
#define M_PI
Definition: ListMatch.cc:31
T sin(T... args)
T cos(T... args)
int m
Definition: SpanSet.cc:49
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const override
a mix of apply and Derivative
Definition: Gtransfo.cc:627

◆ transformStar()

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

allows to write MyTransfo(MyStar)

Definition at line 108 of file Gtransfo.h.

108 { transformPosAndErrors(in, in); }
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const
Definition: Gtransfo.cc:140

◆ write() [1/2]

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

Definition at line 239 of file Gtransfo.cc.

239  {
240  ofstream s(fileName.c_str());
241  write(s);
242  bool ok = !s.fail();
243  s.close();
244  if (!ok)
245  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
246  "Gtransfo::write, something went wrong for file " + fileName);
247 }
void write(const std::string &fileName) const
Definition: Gtransfo.cc:239
STL class.
solver_t * s
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T c_str(T... args)

◆ write() [2/2]

void lsst::jointcal::Gtransfo::write ( std::ostream stream) const
virtualinherited

Reimplemented in lsst::jointcal::GtransfoPoly, and lsst::jointcal::GtransfoIdentity.

Definition at line 249 of file Gtransfo.cc.

249  {
250  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
251  "Gtransfo::write(ostream), should never be called. MEans that it is missing in some "
252  "derived class ");
253 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

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