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
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:
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:
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:
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.
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.
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)