LSST Applications g0f08755f38+82efc23009,g12f32b3c4e+e7bdf1200e,g1653933729+a8ce1bb630,g1a0ca8cf93+50eff2b06f,g28da252d5a+52db39f6a5,g2bbee38e9b+37c5a29d61,g2bc492864f+37c5a29d61,g2cdde0e794+c05ff076ad,g3156d2b45e+41e33cbcdc,g347aa1857d+37c5a29d61,g35bb328faa+a8ce1bb630,g3a166c0a6a+37c5a29d61,g3e281a1b8c+fb992f5633,g414038480c+7f03dfc1b0,g41af890bb2+11b950c980,g5fbc88fb19+17cd334064,g6b1c1869cb+12dd639c9a,g781aacb6e4+a8ce1bb630,g80478fca09+72e9651da0,g82479be7b0+04c31367b4,g858d7b2824+82efc23009,g9125e01d80+a8ce1bb630,g9726552aa6+8047e3811d,ga5288a1d22+e532dc0a0b,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+37c5a29d61,gcf0d15dbbd+2acd6d4d48,gd7358e8bfb+778a810b6e,gda3e153d99+82efc23009,gda6a2b7d83+2acd6d4d48,gdaeeff99f8+1711a396fd,ge2409df99d+6b12de1076,ge79ae78c31+37c5a29d61,gf0baf85859+d0a5978c5a,gf3967379c6+4954f8c433,gfb92a5be7c+82efc23009,gfec2e1e490+2aaed99252,w.2024.46
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)