LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
SimpleAstrometryMapping.cc
Go to the documentation of this file.
1// -*- LSST-C++ -*-
2/*
3 * This file is part of jointcal.
4 *
5 * Developed for the LSST Data Management System.
6 * This product includes software developed by the LSST Project
7 * (https://www.lsst.org).
8 * See the COPYRIGHT file at the top-level directory of this distribution
9 * for details of code ownership.
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25#include <utility>
26
30
31namespace lsst {
32namespace jointcal {
33
35 if (indices.size() < getNpar()) {
36 indices.resize(getNpar());
37 }
38 for (std::size_t k = 0; k < getNpar(); ++k) {
39 indices[k] = index + k;
40 }
41}
42
44 transform->transformPosAndErrors(where, outPoint);
45 FatPoint tmp;
46 errorProp->transformPosAndErrors(where, tmp);
47 outPoint.vx = tmp.vx;
48 outPoint.vy = tmp.vy;
49 outPoint.vxy = tmp.vxy;
50}
51
52void SimpleAstrometryMapping::positionDerivative(Point const &where, Eigen::Matrix2d &derivative,
53 double epsilon) const {
54 errorProp->computeDerivative(where, *lin, epsilon);
55 derivative(0, 0) = lin->getCoefficient(1, 0, 0);
56 //
57 /* This does not work : it was proved by rotating the frame
58 see the compilation switch ROTATE_T2 in constrainedAstrometryModel.cc
59 derivative(1,0) = lin->getCoefficient(1,0,1);
60 derivative(0,1) = lin->getCoefficient(0,1,0);
61 */
62 derivative(1, 0) = lin->getCoefficient(0, 1, 0);
63 derivative(0, 1) = lin->getCoefficient(1, 0, 1);
64 derivative(1, 1) = lin->getCoefficient(0, 1, 1);
65}
66
68 Eigen::MatrixX2d &H) const {
69 transformPosAndErrors(where, outPoint);
70 transform->paramDerivatives(where, &H(0, 0), &H(0, 1));
71}
72
74
76 AstrometryTransformPolynomial const &transform)
77 : SimpleAstrometryMapping(transform), _centerAndScale(std::move(CenterAndScale)) {
78 // We assume that the initialization was done properly, for example that
79 // transform = pixToTangentPlane*CenterAndScale.inverted(), so we do not touch transform.
80 /* store the (spatial) derivative of _centerAndScale. For the extra
81 diagonal terms, just copied the ones in positionDerivatives */
82 preDer(0, 0) = _centerAndScale.getCoefficient(1, 0, 0);
83 preDer(1, 0) = _centerAndScale.getCoefficient(0, 1, 0);
84 preDer(0, 1) = _centerAndScale.getCoefficient(1, 0, 1);
85 preDer(1, 1) = _centerAndScale.getCoefficient(0, 1, 1);
86
87 // check of matrix indexing (once for all)
88 MatrixX2d H(3, 2);
89 assert((&H(1, 0) - &H(0, 0)) == 1);
90}
91
92void SimplePolyMapping::positionDerivative(Point const &where, Eigen::Matrix2d &derivative,
93 double epsilon) const {
94 Point tmp = _centerAndScale.apply(where);
95 errorProp->computeDerivative(tmp, *lin, epsilon);
96 derivative(0, 0) = lin->getCoefficient(1, 0, 0);
97 //
98 /* This does not work : it was proved by rotating the frame
99 see the compilation switch ROTATE_T2 in constrainedAstrometryModel.cc
100 derivative(1,0) = lin->getCoefficient(1,0,1);
101 derivative(0,1) = lin->getCoefficient(0,1,0);
102 */
103 derivative(1, 0) = lin->getCoefficient(0, 1, 0);
104 derivative(0, 1) = lin->getCoefficient(1, 0, 1);
105 derivative(1, 1) = lin->getCoefficient(0, 1, 1);
106 derivative = preDer * derivative;
107}
108
110 Eigen::MatrixX2d &H) const {
111 FatPoint mid;
112 _centerAndScale.transformPosAndErrors(where, mid);
113 transform->transformPosAndErrors(mid, outPoint);
114 FatPoint tmp;
115 errorProp->transformPosAndErrors(mid, tmp);
116 outPoint.vx = tmp.vx;
117 outPoint.vy = tmp.vy;
118 outPoint.vxy = tmp.vxy;
119 transform->paramDerivatives(mid, &H(0, 0), &H(0, 1));
120}
121
122void SimplePolyMapping::transformPosAndErrors(FatPoint const &where, FatPoint &outPoint) const {
123 FatPoint mid;
124 _centerAndScale.transformPosAndErrors(where, mid);
125 transform->transformPosAndErrors(mid, outPoint);
126 FatPoint tmp;
127 errorProp->transformPosAndErrors(mid, tmp);
128 outPoint.vx = tmp.vx;
129 outPoint.vy = tmp.vy;
130 outPoint.vxy = tmp.vxy;
131}
132
134 // Cannot fail given the contructor:
135 const auto *fittedPoly =
136 dynamic_cast<const AstrometryTransformPolynomial *>(&(*transform));
137 actualResult = (*fittedPoly) * _centerAndScale;
138 return actualResult;
139}
140
141} // namespace jointcal
142} // namespace lsst
Eigen::Matrix< double, Eigen::Dynamic, 2 > MatrixX2d
Definition Eigenstuff.h:33
a virtual (interface) class for geometric transformations.
implements the linear transformations (6 real coefficients).
void apply(double xIn, double yIn, double &xOut, double &yOut) const override
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.
virtual void transformPosAndErrors(const FatPoint &in, FatPoint &out) const override
a mix of apply and Derivative
A Point with uncertainties.
Definition FatPoint.h:34
A point in a plane.
Definition Point.h:37
Class for a simple mapping implementing a generic AstrometryTransform.
std::shared_ptr< AstrometryTransform > errorProp
void computeTransformAndDerivatives(FatPoint const &where, FatPoint &outPoint, Eigen::MatrixX2d &H) const override
Actually applies the AstrometryMapping and evaluates the derivatives w.r.t the fitted parameters.
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
std::size_t getNpar() const override
Number of parameters in total.
std::shared_ptr< AstrometryTransform > transform
void getMappingIndices(IndexVector &indices) const override
Sets how this set of parameters (of length Npar()) map into the "grand" fit Expects that indices has ...
std::unique_ptr< AstrometryTransformLinear > lin
void transformPosAndErrors(FatPoint const &where, FatPoint &outPoint) const override
The same as above but without the parameter derivatives (used to evaluate chi^2)
void positionDerivative(Point const &where, Eigen::Matrix2d &derivative, double epsilon) const override
The derivative w.r.t. position.
void computeTransformAndDerivatives(FatPoint const &where, FatPoint &outPoint, Eigen::MatrixX2d &H) const override
Calls the transforms and implements the centering and scaling of coordinates.
void positionDerivative(Point const &where, Eigen::Matrix2d &derivative, double epsilon) const override
The derivative w.r.t. position.
SimplePolyMapping(AstrometryTransformLinear CenterAndScale, AstrometryTransformPolynomial const &transform)
The transformation will be initialized to transform, so that the effective transformation reads trans...
AstrometryTransform const & getTransform() const override
Access to the (fitted) transform.
void transformPosAndErrors(FatPoint const &where, FatPoint &outPoint) const override
The same as above but without the parameter derivatives (used to evaluate chi^2)
T move(T... args)
STL namespace.
T resize(T... args)
T size(T... args)