LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
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
lsst::jointcal::MeasuredStar
objects measured on actual images.
Definition: MeasuredStar.h:46
lsst::jointcal::PhotometryMapping::getNpar
std::size_t getNpar() const override
Number of total parameters in this mapping.
Definition: PhotometryMapping.h:146
std::vector::resize
T resize(T... args)
lsst::jointcal::ChipVisitPhotometryMapping::ChipVisitPhotometryMapping
ChipVisitPhotometryMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
Definition: PhotometryMapping.h:220
lsst::jointcal::PhotometryMappingBase::transform
virtual double transform(MeasuredStar const &measuredStar, double value) const =0
Return the on-sky transformed flux for measuredStar on ccdImage.
lsst::jointcal::PhotometryMapping::transform
double transform(MeasuredStar const &measuredStar, double value) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
Definition: PhotometryMapping.h:155
lsst::jointcal::PhotometryMappingBase::print
virtual void print(std::ostream &out) const =0
Print a string representation of the contents of this mapping, for debugging.
PhotometryTransform.h
std::shared_ptr
STL class.
lsst::jointcal::PhotometryMappingBase::transformError
virtual double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const =0
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
lsst::jointcal::PhotometryMappingBase::PhotometryMappingBase
PhotometryMappingBase(PhotometryMappingBase const &)=delete
No copy or move: there is only ever one instance of a given mapping (i.e. per ccd+visit)
CcdImage.h
std::move
T move(T... args)
lsst::jointcal::ChipVisitPhotometryMapping::freezeErrorTransform
void freezeErrorTransform() override
Once this routine has been called, the error transform is not modified by offsetParams().
Definition: PhotometryMapping.h:239
lsst::jointcal::PhotometryMapping::getTransform
std::shared_ptr< PhotometryTransform > getTransform() const
Definition: PhotometryMapping.h:204
lsst::jointcal::ChipVisitPhotometryMapping::setWhatToFit
void setWhatToFit(bool const fittingChips, bool const fittingVisits)
Set whether to fit chips or visits.
Definition: PhotometryMapping.cc:58
lsst::jointcal::PhotometryMappingBase::~PhotometryMappingBase
virtual ~PhotometryMappingBase()
Definition: PhotometryMapping.h:47
lsst::jointcal::PhotometryMappingBase::setIndex
void setIndex(Eigen::Index i)
Set the index of this mapping in the grand fit.
Definition: PhotometryMapping.h:123
lsst::jointcal::ChipVisitMagnitudeMapping::transformError
double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
Definition: PhotometryMapping.cc:112
Eigenstuff.h
lsst::jointcal::ChipVisitPhotometryMapping
A two-level photometric transform: one for the ccd and one for the visit.
Definition: PhotometryMapping.h:218
std::vector
STL class.
MeasuredStar.h
lsst::jointcal::PhotometryMapping::getMappingIndices
void getMappingIndices(IndexVector &indices) const override
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
Definition: PhotometryMapping.h:191
std::vector::size
T size(T... args)
lsst::jointcal::PhotometryMappingBase::setFixed
void setFixed(bool _fixed)
Make this mapping's parameters fixed (i.e. not varied during fitting).
Definition: PhotometryMapping.h:100
lsst::jointcal::PhotometryMappingBase::index
Eigen::Index index
Definition: PhotometryMapping.h:127
lsst::jointcal::PhotometryMapping::computeParameterDerivatives
void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
Definition: PhotometryMapping.h:170
lsst::jointcal::ChipVisitMagnitudeMapping
Definition: PhotometryMapping.h:303
lsst::jointcal::PhotometryMappingBase::freezeErrorTransform
virtual void freezeErrorTransform()=0
Once this routine has been called, the error transform is not modified by offsetParams().
lsst::jointcal::ChipVisitPhotometryMapping::_nParVisit
std::size_t _nParVisit
Definition: PhotometryMapping.h:282
lsst::jointcal::MeasuredStar::getYFocal
double getYFocal() const
Definition: MeasuredStar.h:110
lsst::jointcal::ChipVisitPhotometryMapping::_nParChip
std::size_t _nParChip
Definition: PhotometryMapping.h:282
Point.h
lsst::jointcal::PhotometryMappingBase::computeParameterDerivatives
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.
lsst::jointcal::PhotometryMappingBase::getNpar
virtual std::size_t getNpar() const =0
Number of total parameters in this mapping.
lsst::jointcal::PhotometryMappingBase
Relates transform(s) to their position in the fitting matrix and allows interaction with the transfor...
Definition: PhotometryMapping.h:44
lsst::jointcal::PhotometryMapping::print
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
Definition: PhotometryMapping.h:199
lsst::jointcal::Point::y
double y
Definition: Point.h:41
lsst::jointcal::PhotometryMappingBase::getIndex
Eigen::Index getIndex()
Get the index of this mapping in the grand fit.
Definition: PhotometryMapping.h:120
lsst::jointcal::PhotometryMapping
A mapping containing a single photometryTransform.
Definition: PhotometryMapping.h:135
lsst::jointcal::ChipVisitPhotometryMapping::print
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
Definition: PhotometryMapping.h:266
std::ostream
STL class.
lsst::jointcal::PhotometryMapping::PhotometryMapping
PhotometryMapping(std::shared_ptr< PhotometryTransform > transform)
Value transform takes ownership of transform, error transform aliases it.
Definition: PhotometryMapping.h:142
lsst::jointcal::ChipVisitFluxMapping::computeParameterDerivatives
void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
Definition: PhotometryMapping.cc:82
lsst::jointcal::ChipVisitPhotometryMapping::getVisitMapping
std::shared_ptr< PhotometryMapping > getVisitMapping() const
Definition: PhotometryMapping.h:275
lsst::jointcal::ChipVisitPhotometryMapping::transform
double transform(MeasuredStar const &measuredStar, double value) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
Definition: PhotometryMapping.h:232
lsst::jointcal::PhotometryMapping::getTransformErrors
std::shared_ptr< PhotometryTransform > getTransformErrors() const
Definition: PhotometryMapping.h:206
lsst::jointcal::ChipVisitPhotometryMapping::getChipMapping
std::shared_ptr< PhotometryMapping > getChipMapping() const
Definition: PhotometryMapping.h:274
lsst::jointcal::PhotometryMappingBase::operator=
PhotometryMappingBase & operator=(PhotometryMappingBase &&)=delete
lsst::jointcal::PhotometryMapping::freezeErrorTransform
void freezeErrorTransform() override
Once this routine has been called, the error transform is not modified by offsetParams().
Definition: PhotometryMapping.h:165
lsst::jointcal::ChipVisitPhotometryMapping::_visitMapping
std::shared_ptr< PhotometryMapping > _visitMapping
Definition: PhotometryMapping.h:286
lsst::jointcal
Definition: Associations.h:49
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::jointcal::ChipVisitPhotometryMapping::getNParChip
std::size_t getNParChip() const
Definition: PhotometryMapping.h:277
lsst::jointcal::ChipVisitFluxMapping
Definition: PhotometryMapping.h:289
lsst::jointcal::ChipVisitPhotometryMapping::getNParVisit
std::size_t getNParVisit() const
Definition: PhotometryMapping.h:278
std::endl
T endl(T... args)
lsst::jointcal::PhotometryMappingBase::PhotometryMappingBase
PhotometryMappingBase()
Definition: PhotometryMapping.h:46
lsst::jointcal::ChipVisitFluxMapping::ChipVisitFluxMapping
ChipVisitFluxMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
Definition: PhotometryMapping.h:291
PhotoCalib.h
Implementation of the Photometric Calibration class.
lsst::jointcal::PhotometryMappingBase::PhotometryMappingBase
PhotometryMappingBase(PhotometryMappingBase &&)=delete
lsst::jointcal::ChipVisitPhotometryMapping::_chipMapping
std::shared_ptr< PhotometryMapping > _chipMapping
Definition: PhotometryMapping.h:285
std
STL namespace.
lsst::jointcal::PhotometryMapping::transformError
double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
Definition: PhotometryMapping.h:160
lsst::jointcal::ChipVisitMagnitudeMapping::computeParameterDerivatives
void computeParameterDerivatives(MeasuredStar const &measuredStar, double value, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
Definition: PhotometryMapping.cc:119
lsst::jointcal::ChipVisitPhotometryMapping::getMappingIndices
void getMappingIndices(IndexVector &indices) const override
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
Definition: PhotometryMapping.cc:39
std::size_t
lsst::jointcal::PhotometryMapping::getParameters
Eigen::VectorXd getParameters() override
Definition: PhotometryMapping.h:188
lsst::jointcal::ChipVisitPhotometryMapping::getNpar
std::size_t getNpar() const override
Number of total parameters in this mapping.
Definition: PhotometryMapping.h:229
lsst::jointcal::PhotometryMappingBase::operator=
PhotometryMappingBase & operator=(PhotometryMappingBase const &)=delete
lsst::jointcal::Point::x
double x
coordinate
Definition: Point.h:41
lsst::jointcal::PhotometryMapping::offsetParams
void offsetParams(Eigen::VectorXd const &delta)
Offset the transform parameters by delta.
Definition: PhotometryMapping.h:185
lsst::jointcal::PhotometryMappingBase::getParameters
virtual Eigen::VectorXd getParameters()=0
lsst::jointcal::MeasuredStar::getXFocal
double getXFocal() const
Definition: MeasuredStar.h:108
lsst::jointcal::PhotometryMappingBase::fixed
bool fixed
Definition: PhotometryMapping.h:129
lsst::jointcal::ChipVisitFluxMapping::transformError
double transformError(MeasuredStar const &measuredStar, double value, double valueErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
Definition: PhotometryMapping.cc:73
lsst::jointcal::ChipVisitPhotometryMapping::getParameters
Eigen::VectorXd getParameters() override
Definition: PhotometryMapping.h:245
lsst::jointcal::PhotometryMappingBase::isFixed
bool isFixed()
Definition: PhotometryMapping.h:101
lsst::jointcal::ChipVisitMagnitudeMapping::ChipVisitMagnitudeMapping
ChipVisitMagnitudeMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
Definition: PhotometryMapping.h:305
lsst::jointcal::PhotometryMappingBase::getMappingIndices
virtual void getMappingIndices(IndexVector &indices) const =0
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.