31 if (wcs->hasDistortion()) {
37 int sipOrder =
std::max(wcsMeta->
get<
int>(
"A_ORDER"), wcsMeta->
get<
int>(
"B_ORDER"));
40 for (
int i = 0; i <= sipOrder; ++i) {
41 for (
int j = 0; j <= sipOrder; ++j) {
42 if (i < sipA.cols() && j < sipA.rows() && (i + j) <= sipOrder)
43 sipPoly.
coeff(i, j, 0) = sipA(i, j);
44 if (i < sipB.cols() && j < sipB.rows() && (i + j) <= sipOrder)
45 sipPoly.
coeff(i, j, 1) = sipB(i, j);
67 Eigen::Matrix2d cdMat = wcs->getCDMatrix();
69 cdTrans.
coeff(1, 0, 0) = cdMat(0, 0);
70 cdTrans.
coeff(0, 1, 0) = cdMat(0, 1);
71 cdTrans.
coeff(1, 0, 1) = cdMat(1, 0);
72 cdTrans.
coeff(0, 1, 1) = cdMat(1, 1);
81 double ra = wcsMeta->
get<
double>(
"CRVAL1");
82 double dec = wcsMeta->
get<
double>(
"CRVAL2");
94 const
bool noLowOrderSipTerms) {
105 linPart.
invert().
apply(0., 0., crpix_lsst[0], crpix_lsst[1]);
110 if (noLowOrderSipTerms) {
111 Point ctmp =
Point(crpix_lsst[0], crpix_lsst[1]);
116 r->apply(0, 0, crpix_lsst[0], crpix_lsst[1]);
127 crval[0] = wcsTransfo.getTangentPoint().x;
128 crval[1] = wcsTransfo.getTangentPoint().y;
131 Eigen::Matrix2d cdMat;
132 cdMat(0, 0) = linPart.
coeff(1, 0, 0);
133 cdMat(0, 1) = linPart.
coeff(0, 1, 0);
134 cdMat(1, 0) = linPart.
coeff(1, 0, 1);
135 cdMat(1, 1) = linPart.
coeff(0, 1, 1);
137 if (!wcsTransfo.getCorr())
138 return std::make_shared<afwImg::TanWcs>(crval, crpix_lsst, cdMat);
163 "GtransfoToSip: could not invert the input wcs ");
170 Eigen::MatrixXd sipA(Eigen::MatrixXd::Zero(sipOrder + 1, sipOrder + 1));
171 Eigen::MatrixXd sipB(Eigen::MatrixXd::Zero(sipOrder + 1, sipOrder + 1));
172 for (
int i = 0; i <= sipOrder; ++i)
173 for (
int j = 0; j <= sipOrder - i; ++j) {
174 sipA(i, j) = sipPoly.
coeff(i, j, 0);
175 sipB(i, j) = sipPoly.
coeff(i, j, 1);
180 Eigen::MatrixXd sipAp(Eigen::MatrixXd::Zero(sipOrder + 1, sipOrder + 1));
181 Eigen::MatrixXd sipBp(Eigen::MatrixXd::Zero(sipOrder + 1, sipOrder + 1));
182 for (
int i = 0; i <= sipOrder; ++i)
183 for (
int j = 0; j <= sipOrder - i; ++j) {
184 sipAp(i, j) = sipPolyInv.
coeff(i, j, 0);
185 sipBp(i, j) = sipPolyInv.
coeff(i, j, 1);
188 return std::make_shared<afwImg::TanWcs>(crval, crpix_lsst, cdMat, sipA, sipB, sipAp, sipBp);
Implements the (forward) SIP distorsion scheme.
implements the linear transformations (6 real coefficients).
void apply(const double xIn, const double yIn, double &xOut, double &yOut) const
GtransfoLin invert() const
returns the inverse: T1 = T2.invert();
table::PointKey< double > crval
static void decodeSipHeader(daf::base::PropertySet const &fitsMetadata, std::string const &which, Eigen::MatrixXd &m)
Polynomial transformation class.
std::unique_ptr< GtransfoPoly > inversePolyTransfo(const Gtransfo &Direct, const Frame &frame, const double Prec)
approximates the inverse by a polynomial, up to required precision.
rectangle with sides parallel to axes.
Class for a simple mapping implementing a generic Gtransfo.
unsigned getDegree() const
returns degree
#define LSST_EXCEPT(type,...)
boost::shared_ptr< lsst::afw::image::TanWcs > gtransfoToTanWcs(const lsst::jointcal::TanSipPix2RaDec wcsTransfo, const lsst::jointcal::Frame &ccdFrame, const bool noLowOrderSipTerms=false)
Transform the other way around.
virtual GtransfoLin linearApproximation(const Point &where, const double step=0.01) const
linear (local) approximation.
just here to provide a specialized constructor, and fit.
double coeff(const unsigned powX, const unsigned powY, const unsigned whichCoord) const
access to coefficients (read only)
std::shared_ptr< jointcal::GtransfoPoly > GtPoly_Ptr
virtual std::unique_ptr< Gtransfo > inverseTransfo(const double precision, const Frame ®ion) const
returns an inverse transfo. Numerical if not overloaded.
TanSipPix2RaDec convertTanWcs(const std::shared_ptr< lsst::afw::image::TanWcs > wcs)
Transform an afw TanWcs into a Gtransfo.