LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
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 
31 
32 #include "lsst/jointcal/CcdImage.h"
35 #include "lsst/jointcal/Point.h"
37 
38 namespace lsst {
39 namespace jointcal {
40 
45 public:
46  PhotometryMappingBase() : index(-1), fixed(false) {}
48 
54 
56  virtual std::size_t getNpar() const = 0;
57 
66  virtual double transform(MeasuredStar const &measuredStar, double value) const = 0;
67 
78  virtual double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const = 0;
79 
87  virtual void freezeErrorTransform() = 0;
88 
96  virtual void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
97  Eigen::Ref<Eigen::VectorXd> derivatives) const = 0;
98 
100  void setFixed(bool _fixed) { fixed = _fixed; }
101  bool isFixed() { return fixed; }
102 
103  virtual Eigen::VectorXd getParameters() = 0;
104 
109  virtual void getMappingIndices(IndexVector &indices) const = 0;
110 
117  virtual void print(std::ostream &out) const = 0;
118 
120  Eigen::Index getIndex() { return index; }
121 
123  void setIndex(Eigen::Index i) { index = i; }
124 
125 protected:
126  // Start index of this mapping in the "grand" fit
127  Eigen::Index index;
128  // Should this mapping be varied during fitting?
129  bool fixed;
130 };
131 
136 public:
143  : PhotometryMappingBase(), _transform(std::move(transform)), _transformErrors(_transform) {}
144 
146  std::size_t getNpar() const override {
147  if (fixed) {
148  return 0;
149  } else {
150  return _transform->getNpar();
151  }
152  }
153 
155  double transform(MeasuredStar const &measuredStar, double value) const override {
156  return _transform->transform(measuredStar.x, measuredStar.y, value);
157  }
158 
160  double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override {
161  return _transformErrors->transformError(measuredStar.x, measuredStar.y, value, valueErr);
162  }
163 
165  void freezeErrorTransform() override {
166  _transformErrors = std::shared_ptr<PhotometryTransform>(_transform->clone());
167  }
168 
170  void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
171  Eigen::Ref<Eigen::VectorXd> derivatives) const override {
172  if (fixed) {
173  return;
174  } else {
175  _transform->computeParameterDerivatives(measuredStar.x, measuredStar.y, value, derivatives);
176  }
177  }
178 
185  void offsetParams(Eigen::VectorXd const &delta) { _transform->offsetParams(delta); }
186 
188  Eigen::VectorXd getParameters() override { return _transform->getParameters(); }
189 
191  void getMappingIndices(IndexVector &indices) const override {
192  if (indices.size() < getNpar()) indices.resize(getNpar());
193  for (std::size_t k = 0; k < getNpar(); ++k) {
194  indices[k] = index + k;
195  }
196  }
197 
199  void print(std::ostream &out) const override {
200  out << "index: " << index << " fixed: " << fixed << " ";
201  _transform->print(out);
202  }
203 
204  std::shared_ptr<PhotometryTransform> getTransform() const { return _transform; }
205 
206  std::shared_ptr<PhotometryTransform> getTransformErrors() const { return _transformErrors; }
207 
208 private:
209  // the actual transformation to be fit
211  // the transformation used for errors
212  std::shared_ptr<PhotometryTransform> _transformErrors;
213 };
214 
219 public:
223  _nParChip(0),
224  _nParVisit(0),
225  _chipMapping(std::move(chipMapping)),
226  _visitMapping(std::move(visitMapping)) {}
227 
229  std::size_t getNpar() const override { return _nParChip + _nParVisit; }
230 
232  double transform(MeasuredStar const &measuredStar, double value) const override {
233  double temp = _chipMapping->getTransform()->transform(measuredStar.x, measuredStar.y, value);
234  return _visitMapping->getTransform()->transform(measuredStar.getXFocal(), measuredStar.getYFocal(),
235  temp);
236  }
237 
239  void freezeErrorTransform() override {
240  _chipMapping->freezeErrorTransform();
241  _visitMapping->freezeErrorTransform();
242  }
243 
245  Eigen::VectorXd getParameters() override {
246  Eigen::VectorXd joined(getNpar());
247  joined << _chipMapping->getParameters(), _visitMapping->getParameters();
248  return joined;
249  }
250 
252  void getMappingIndices(IndexVector &indices) const override;
253 
263  void setWhatToFit(bool const fittingChips, bool const fittingVisits);
264 
266  void print(std::ostream &out) const override {
267  out << "index: " << index << std::endl;
268  out << "chip mapping: ";
269  _chipMapping->print(out);
270  out << std::endl << "visit mapping: ";
271  _visitMapping->print(out);
272  }
273 
276 
277  std::size_t getNParChip() const { return _nParChip; }
278  std::size_t getNParVisit() const { return _nParVisit; }
279 
280 protected:
281  // These are either transform.getNpar() or 0, depending on whether we are fitting that component or not.
283 
284  // the actual transformation to be fit
287 };
288 
290 public:
293  : ChipVisitPhotometryMapping(chipMapping, visitMapping) {}
294 
296  double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override;
297 
299  void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
300  Eigen::Ref<Eigen::VectorXd> derivatives) const override;
301 };
302 
304 public:
307  : ChipVisitPhotometryMapping(chipMapping, visitMapping) {}
308 
315  double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override;
316 
318  void computeParameterDerivatives(MeasuredStar const &measuredStar, double value,
319  Eigen::Ref<Eigen::VectorXd> derivatives) const override;
320 };
321 
322 } // namespace jointcal
323 } // namespace lsst
324 
325 #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 > _visitMapping
std::shared_ptr< PhotometryMapping > getChipMapping() const
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::shared_ptr< PhotometryMapping > getVisitMapping() const
std::size_t getNpar() const override
Number of total parameters in this mapping.
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)
void setWhatToFit(bool const fittingChips, bool const fittingVisits)
Set whether to fit chips or visits.
objects measured on actual images.
Definition: MeasuredStar.h:46
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)
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).
Eigen::Index getIndex()
Get the index of this mapping in the grand fit.
virtual void print(std::ostream &out) const =0
Print a string representation of the contents of this mapping, for debugging.
PhotometryMappingBase & operator=(PhotometryMappingBase const &)=delete
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.
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.
std::shared_ptr< PhotometryTransform > getTransform() const
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
std::shared_ptr< PhotometryTransform > getTransformErrors() const
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.
double transform(MeasuredStar const &measuredStar, double value) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
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:41
T endl(T... args)
T move(T... args)
A base class for image defects.
STL namespace.
T resize(T... args)
T size(T... args)