LSST Applications g180d380827+0f66a164bb,g2079a07aa2+86d27d4dc4,g2305ad1205+7d304bc7a0,g29320951ab+500695df56,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+e42ea45bea,g48712c4677+36a86eeaa5,g487adcacf7+2dd8f347ac,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+c70619cc9d,g5a732f18d5+53520f316c,g5ea96fc03c+341ea1ce94,g64a986408d+f7cd9c7162,g858d7b2824+f7cd9c7162,g8a8a8dda67+585e252eca,g99cad8db69+469ab8c039,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+c92fc63c7e,gbd866b1f37+f7cd9c7162,gc120e1dc64+02c66aa596,gc28159a63d+0e5473021a,gc3e9b769f7+b0068a2d9f,gcf0d15dbbd+e42ea45bea,gdaeeff99f8+f9a426f77a,ge6526c86ff+84383d05b3,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+f7cd9c7162,w.2024.17
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)