LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
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.
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.
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)