LSST Applications g180d380827+6621f76652,g2079a07aa2+86d27d4dc4,g2305ad1205+f5a9e323a1,g2bbee38e9b+c6a8a0fb72,g337abbeb29+c6a8a0fb72,g33d1c0ed96+c6a8a0fb72,g3a166c0a6a+c6a8a0fb72,g3ddfee87b4+9a10e1fe7b,g48712c4677+c9a099281a,g487adcacf7+f2e03ea30b,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+aead732c78,g64a986408d+eddffb812c,g858d7b2824+eddffb812c,g864b0138d7+aa38e45daa,g974c55ee3d+f37bf00e57,g99cad8db69+119519a52d,g9c22b2923f+e2510deafe,g9ddcbc5298+9a081db1e4,ga1e77700b3+03d07e1c1f,gb0e22166c9+60f28cb32d,gb23b769143+eddffb812c,gba4ed39666+c2a2e4ac27,gbb8dafda3b+27317ec8e9,gbd998247f1+585e252eca,gc120e1dc64+5817c176a8,gc28159a63d+c6a8a0fb72,gc3e9b769f7+6707aea8b4,gcf0d15dbbd+9a10e1fe7b,gdaeeff99f8+f9a426f77a,ge6526c86ff+6a2e01d432,ge79ae78c31+c6a8a0fb72,gee10cc3b42+585e252eca,gff1a9f87cc+eddffb812c,v27.0.0.rc1
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)