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-25-g07af9f2+1,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-9-g85d1a16+16,16.0-9-gf5c1f43,master-g07ce7b41a7,w.2018.48
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst::jointcal::GtransfoIdentity Class Reference

A do-nothing transformation. It anyway has dummy routines to mimick a Gtransfo. More...

#include <Gtransfo.h>

Inheritance diagram for lsst::jointcal::GtransfoIdentity:
lsst::jointcal::Gtransfo

Public Member Functions

 GtransfoIdentity ()
 constructor. More...
 
void apply (const double xIn, const double yIn, double &xOut, double &yOut) const override
 xOut = xIn; yOut = yIn ! More...
 
double fit (StarMatchList const &starMatchList) override
 fits a transfo to a std::list of Point pairs (p1,p2, the Point fields in StarMatch). More...
 
std::unique_ptr< GtransfocomposeAndReduce (Gtransfo const &right) const override
 Return a reduced composition of newTransfo = this(right()), or nullptr if it cannot be reduced. More...
 
void dump (std::ostream &stream=std::cout) const override
 dumps the transfo coefficients to stream. More...
 
int getNpar () const override
 returns the number of parameters (to compute chi2's) More...
 
std::unique_ptr< Gtransfoclone () const override
 returns a copy (allocated by new) of the transformation. More...
 
void computeDerivative (Point const &where, GtransfoLin &derivative, const double step=0.01) const override
 Computes the local Derivative of a transfo, w.r.t. More...
 
virtual GtransfoLin linearApproximation (Point const &where, const double step=0.01) const override
 linear approximation. 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 read (std::istream &s)
 
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 void transformPosAndErrors (const FatPoint &in, FatPoint &out) const
 
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...
 
virtual std::unique_ptr< GtransfoinverseTransfo (const double precision, const Frame &region) const
 returns an inverse transfo. Numerical if not overloaded. 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 std::unique_ptr< GtransforoughInverse (const Frame &region) const
 Rough inverse. More...
 
void write (const std::string &fileName) const
 

Detailed Description

A do-nothing transformation. It anyway has dummy routines to mimick a Gtransfo.

Definition at line 219 of file Gtransfo.h.

Constructor & Destructor Documentation

◆ GtransfoIdentity()

lsst::jointcal::GtransfoIdentity::GtransfoIdentity ( )
inline

constructor.

Definition at line 222 of file Gtransfo.h.

222 {}

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::GtransfoIdentity::apply ( const double  xIn,
const double  yIn,
double &  xOut,
double &  yOut 
) const
inlineoverridevirtual

xOut = xIn; yOut = yIn !

Implements lsst::jointcal::Gtransfo.

Definition at line 225 of file Gtransfo.h.

225  {
226  xOut = xIn;
227  yOut = yIn;
228  } // to speed up

◆ clone()

std::unique_ptr<Gtransfo> lsst::jointcal::GtransfoIdentity::clone ( ) const
inlineoverridevirtual

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

Implements lsst::jointcal::Gtransfo.

Definition at line 242 of file Gtransfo.h.

242  {
244  }
GtransfoIdentity()
constructor.
Definition: Gtransfo.h:222
STL class.

◆ composeAndReduce()

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

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

Definition at line 236 of file Gtransfo.h.

236 { return right.clone(); }
T right(T... args)

◆ computeDerivative()

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

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

Definition at line 420 of file Gtransfo.cc.

420  {
421  derivative = GtransfoLin();
422 }

◆ dump()

void lsst::jointcal::GtransfoIdentity::dump ( std::ostream stream = std::cout) const
inlineoverridevirtual

dumps the transfo coefficients to stream.

Implements lsst::jointcal::Gtransfo.

Definition at line 238 of file Gtransfo.h.

238 { stream << "x' = x\ny' = y" << std::endl; }
T endl(T... args)

◆ fit()

double lsst::jointcal::GtransfoIdentity::fit ( StarMatchList const &  starMatchList)
inlineoverridevirtual

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 230 of file Gtransfo.h.

230  {
231  throw pexExcept::TypeError(
232  "GtransfoIdentity is the identity transformation: it cannot be fit to anything.");
233  }
Reports errors from accepting an object of an unexpected or inappropriate type.
Definition: Runtime.h:167

◆ 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

◆ getNpar()

int lsst::jointcal::GtransfoIdentity::getNpar ( ) const
inlineoverridevirtual

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

Reimplemented from lsst::jointcal::Gtransfo.

Definition at line 240 of file Gtransfo.h.

240 { 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

◆ inverseTransfo()

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

returns an inverse transfo. Numerical if not overloaded.

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

Reimplemented in lsst::jointcal::TanRaDecToPixel, lsst::jointcal::TanSipPixelToRaDec, lsst::jointcal::TanPixelToRaDec, lsst::jointcal::GtransfoLin, and lsst::jointcal::GtransfoInverse.

Definition at line 292 of file Gtransfo.cc.

292  {
293  return std::unique_ptr<Gtransfo>(new GtransfoInverse(this, precision, region));
294 }
STL class.

◆ linearApproximation()

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

linear approximation.

Reimplemented from lsst::jointcal::Gtransfo.

Definition at line 424 of file Gtransfo.cc.

424  {
425  GtransfoLin result;
426  return result; // rely on default Gtransfolin constructor;
427 }
py::object result
Definition: schema.cc:284

◆ 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

◆ read()

void lsst::jointcal::GtransfoIdentity::read ( std::istream s)

Definition at line 435 of file Gtransfo.cc.

435  {
436  int format;
437  stream >> format;
438  if (format != 1)
439  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
440  " GtransfoIdentity::read : format is not 1 ");
441 }
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:129
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ roughInverse()

std::unique_ptr< Gtransfo > lsst::jointcal::Gtransfo::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::GtransfoInverse.

Definition at line 190 of file Gtransfo.cc.

190  {
191  // "in" and "out" refer to the inverse direction.
192  Point centerOut = region.getCenter();
193  Point centerIn = apply(centerOut);
194  GtransfoLin der;
195  computeDerivative(centerOut, der, std::sqrt(region.getArea()) / 5.);
196  der = der.inverted();
197  der = GtransfoLinShift(centerOut.x, centerOut.y) * der * GtransfoLinShift(-centerIn.x, -centerIn.y);
198  return std::unique_ptr<Gtransfo>(new GtransfoLin(der));
199 }
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
STL class.
T sqrt(T... args)
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0

◆ toAstMap()

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

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

Definition at line 429 of file Gtransfo.cc.

429  {
430  return std::make_shared<ast::UnitMap>(2); // a GtransfoIdentity is identically ast::UnitMap(2)
431 }

◆ 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::Gtransfo::transformPosAndErrors ( const FatPoint in,
FatPoint out 
) const
virtualinherited

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

Definition at line 140 of file Gtransfo.cc.

140  {
141  FatPoint res; // in case in and out are the same address...
142  res = apply(in);
143  GtransfoLin der;
144  // could save a call here, since Derivative needs the transform of where that we already have
145  // 0.01 may not be a very good idea in all cases. May be we should provide a way of altering that.
146  computeDerivative(in, der, 0.01);
147  double a11 = der.A11();
148  double a22 = der.A22();
149  double a21 = der.A21();
150  double a12 = der.A12();
151  res.vx = a11 * (a11 * in.vx + 2 * a12 * in.vxy) + a12 * a12 * in.vy;
152  res.vy = a21 * a21 * in.vx + a22 * a22 * in.vy + 2. * a21 * a22 * in.vxy;
153  res.vxy = a21 * a11 * in.vx + a22 * a12 * in.vy + (a21 * a12 + a11 * a22) * in.vxy;
154  out = res;
155 }
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
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const =0

◆ 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::GtransfoIdentity::write ( std::ostream s) const
overridevirtual

Reimplemented from lsst::jointcal::Gtransfo.

Definition at line 433 of file Gtransfo.cc.

433 { stream << "GtransfoIdentity 1" << endl; }
T endl(T... args)

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