LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
PhotometryMapping.h
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#ifndef LSST_JOINTCAL_PHOTOMETRY_MAPPING_H
26#define LSST_JOINTCAL_PHOTOMETRY_MAPPING_H
27
28#include <memory>
29#include <utility>
30
32
36#include "lsst/jointcal/Point.h"
38
39namespace lsst {
40namespace jointcal {
41
46public:
48 virtual ~PhotometryMappingBase() = default;;
49
55
57 virtual std::size_t getNpar() const = 0;
58
67 virtual double transform(MeasuredStar const &measuredStar, double value) const = 0;
68
79 virtual double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const = 0;
80
88 virtual void freezeErrorTransform() = 0;
89
97 virtual void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
98 Eigen::Ref<Eigen::VectorXd> derivatives) const = 0;
99
101 void setFixed(bool _fixed) { fixed = _fixed; }
102 bool isFixed() const { return fixed; }
103
104 virtual Eigen::VectorXd getParameters() = 0;
105
110 virtual void getMappingIndices(IndexVector &indices) const = 0;
111
118 virtual void print(std::ostream &out) const = 0;
119
121 Eigen::Index getIndex() const { return index; }
122
124 void setIndex(Eigen::Index i) { index = i; }
125
126protected:
127 // Start index of this mapping in the "grand" fit
128 Eigen::Index index;
129 // Should this mapping be varied during fitting?
130 bool fixed;
131};
132
137public:
144 : PhotometryMappingBase(), _transform(std::move(transform)), _transformErrors(_transform) {}
145
147 std::size_t getNpar() const override {
148 if (fixed) {
149 return 0;
150 } else {
151 return _transform->getNpar();
152 }
153 }
154
156 double transform(MeasuredStar const &measuredStar, double value) const override {
157 return _transform->transform(measuredStar.x, measuredStar.y, value);
158 }
159
161 double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override {
162 return _transformErrors->transformError(measuredStar.x, measuredStar.y, value, valueErr);
163 }
164
166 void freezeErrorTransform() override {
167 _transformErrors = std::shared_ptr<PhotometryTransform>(_transform->clone());
168 }
169
171 void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
172 Eigen::Ref<Eigen::VectorXd> derivatives) const override {
173 if (fixed) {
174 return;
175 } else {
176 _transform->computeParameterDerivatives(measuredStar.x, measuredStar.y, value, derivatives);
177 }
178 }
179
186 void offsetParams(Eigen::VectorXd const &delta) { _transform->offsetParams(delta); }
187
189 Eigen::VectorXd getParameters() override { return _transform->getParameters(); }
190
192 void getMappingIndices(IndexVector &indices) const override {
193 if (indices.size() < getNpar()) indices.resize(getNpar());
194 for (std::size_t k = 0; k < getNpar(); ++k) {
195 indices[k] = index + k;
196 }
197 }
198
200 void print(std::ostream &out) const override {
201 out << "index: " << index << " fixed: " << fixed << " ";
202 _transform->print(out);
203 }
204
206
207 std::shared_ptr<PhotometryTransform> getTransformErrors() const { return _transformErrors; }
208
209private:
210 // the actual transformation to be fit
212 // the transformation used for errors
214};
215
220public:
224 _nParChip(0),
225 _nParVisit(0),
226 _chipMapping(std::move(chipMapping)),
227 _visitMapping(std::move(visitMapping)) {}
228
230 std::size_t getNpar() const override { return _nParChip + _nParVisit; }
231
233 double transform(MeasuredStar const &measuredStar, double value) const override {
234 double temp = _chipMapping->getTransform()->transform(measuredStar.x, measuredStar.y, value);
235 return _visitMapping->getTransform()->transform(measuredStar.getXFocal(), measuredStar.getYFocal(),
236 temp);
237 }
238
240 void freezeErrorTransform() override {
241 _chipMapping->freezeErrorTransform();
242 _visitMapping->freezeErrorTransform();
243 }
244
246 Eigen::VectorXd getParameters() override {
247 Eigen::VectorXd joined(getNpar());
248 joined << _chipMapping->getParameters(), _visitMapping->getParameters();
249 return joined;
250 }
251
253 void getMappingIndices(IndexVector &indices) const override;
254
264 void setWhatToFit(bool fittingChips, bool fittingVisits);
265
267 void print(std::ostream &out) const override {
268 out << "index: " << index << std::endl;
269 out << "chip mapping: ";
270 _chipMapping->print(out);
271 out << std::endl << "visit mapping: ";
272 _visitMapping->print(out);
273 }
274
277
280
281protected:
282 // These are either transform.getNpar() or 0, depending on whether we are fitting that component or not.
284
285 // the actual transformation to be fit
288};
289
291public:
294 : ChipVisitPhotometryMapping(std::move(chipMapping), std::move(visitMapping)) {}
295
297 double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override;
298
300 void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
301 Eigen::Ref<Eigen::VectorXd> derivatives) const override;
302};
303
305public:
308 : ChipVisitPhotometryMapping(std::move(chipMapping), std::move(visitMapping)) {}
309
316 double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override;
317
319 void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
320 Eigen::Ref<Eigen::VectorXd> derivatives) const override;
321};
322
323} // namespace jointcal
324} // namespace lsst
325
326#endif // LSST_JOINTCAL_PHOTOMETRY_MAPPING_H
Implementation of the Photometric Calibration class.
table::Key< int > transform
void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
ChipVisitFluxMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
ChipVisitMagnitudeMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
A two-level photometric transform: one for the ccd and one for the visit.
double transform(MeasuredStar const &measuredStar, double value) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
std::shared_ptr< PhotometryMapping > getChipMapping() const
std::shared_ptr< PhotometryMapping > _visitMapping
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
std::shared_ptr< PhotometryMapping > _chipMapping
void freezeErrorTransform() override
Once this routine has been called, the error transform is not modified by offsetParams().
std::size_t getNpar() const override
Number of total parameters in this mapping.
void setWhatToFit(bool fittingChips, bool fittingVisits)
Set whether to fit chips or visits.
void getMappingIndices(IndexVector &indices) const override
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
ChipVisitPhotometryMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
std::shared_ptr< PhotometryMapping > getVisitMapping() const
Sources measured on images.
Definition: MeasuredStar.h:51
Relates transform(s) to their position in the fitting matrix and allows interaction with the transfor...
PhotometryMappingBase & operator=(PhotometryMappingBase &&)=delete
PhotometryMappingBase(PhotometryMappingBase const &)=delete
No copy or move: there is only ever one instance of a given mapping (i.e. per ccd+visit)
PhotometryMappingBase & operator=(PhotometryMappingBase const &)=delete
virtual Eigen::VectorXd getParameters()=0
virtual std::size_t getNpar() const =0
Number of total parameters in this mapping.
void setFixed(bool _fixed)
Make this mapping's parameters fixed (i.e. not varied during fitting).
virtual void print(std::ostream &out) const =0
Print a string representation of the contents of this mapping, for debugging.
void setIndex(Eigen::Index i)
Set the index of this mapping in the grand fit.
PhotometryMappingBase(PhotometryMappingBase &&)=delete
virtual void getMappingIndices(IndexVector &indices) const =0
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
virtual double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const =0
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
virtual void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const =0
Compute the derivatives with respect to the parameters (i.e.
Eigen::Index getIndex() const
Get the index of this mapping in the grand fit.
virtual void freezeErrorTransform()=0
Once this routine has been called, the error transform is not modified by offsetParams().
virtual double transform(MeasuredStar const &measuredStar, double value) const =0
Return the on-sky transformed flux for measuredStar on ccdImage.
A mapping containing a single photometryTransform.
void getMappingIndices(IndexVector &indices) const override
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
void freezeErrorTransform() override
Once this routine has been called, the error transform is not modified by offsetParams().
Eigen::VectorXd getParameters() override
PhotometryMapping(std::shared_ptr< PhotometryTransform > transform)
Value transform takes ownership of transform, error transform aliases it.
double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
std::shared_ptr< PhotometryTransform > getTransform() const
double transform(MeasuredStar const &measuredStar, double value) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
std::shared_ptr< PhotometryTransform > getTransformErrors() const
void offsetParams(Eigen::VectorXd const &delta)
Offset the transform parameters by delta.
std::size_t getNpar() const override
Number of total parameters in this mapping.
double x
coordinate
Definition: Point.h:42
T endl(T... args)
T move(T... args)
STL namespace.
T resize(T... args)
T size(T... args)