LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
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
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
table::Key< int > transform
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
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)
A base class for image defects.
STL namespace.
T resize(T... args)
T size(T... args)