LSSTApplications  20.0.0
LSSTDataManagementBasePackage
SimplePhotometryModel.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_SIMPLE_PHOTOMETRY_MODEL_H
26 #define LSST_JOINTCAL_SIMPLE_PHOTOMETRY_MODEL_H
27 
28 #include <map>
29 
30 #include "lsst/jointcal/CcdImage.h"
34 #include "lsst/jointcal/Point.h"
35 
36 namespace lsst {
37 namespace jointcal {
38 
39 class CcdImage;
40 class Point;
41 
44 public:
47  _myMap.reserve(ccdImageList.size());
48  }
49 
55 
57  Eigen::Index assignIndices(std::string const &whatToFit, Eigen::Index firstIndex) override;
58 
60  void offsetParams(Eigen::VectorXd const &delta) override;
61 
63  void freezeErrorTransform() override;
64 
66  void getMappingIndices(CcdImage const &ccdImage, IndexVector &indices) const override;
67 
69  std::size_t getTotalParameters() const override;
70 
72  void computeParameterDerivatives(MeasuredStar const &measuredStar, CcdImage const &ccdImage,
73  Eigen::VectorXd &derivatives) const override;
74 
76  virtual void print(std::ostream &out) const override;
77 
78 protected:
81 
83  PhotometryMappingBase *findMapping(CcdImage const &ccdImage) const override;
84 };
85 
87 public:
88  SimpleFluxModel(CcdImageList const &ccdImageList, double errorPedestal = 0);
89 
91  void offsetFittedStar(FittedStar &fittedStar, double delta) const override {
92  fittedStar.getFlux() -= delta;
93  }
94 
96  double computeResidual(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override;
97 
99  double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override;
100 
102  double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override;
103 
105  double getRefError(RefStar const &refStar) const override { return refStar.getFluxErr(); }
106 
108  double computeRefResidual(FittedStar const &fittedStar, RefStar const &refStar) const override {
109  return fittedStar.getFlux() - refStar.getFlux();
110  };
111 
117  std::shared_ptr<afw::image::PhotoCalib> toPhotoCalib(CcdImage const &ccdImage) const override;
118 
120  void print(std::ostream &out) const override;
121 };
122 
124 public:
125  SimpleMagnitudeModel(CcdImageList const &ccdImageList, double errorPedestal = 0);
126 
128  void offsetFittedStar(FittedStar &fittedStar, double delta) const override {
129  fittedStar.getMag() -= delta;
130  }
131 
133  double computeResidual(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override;
134 
136  double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override;
137 
139  double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override;
140 
142  double getRefError(RefStar const &refStar) const override { return refStar.getMagErr(); }
143 
145  double computeRefResidual(FittedStar const &fittedStar, RefStar const &refStar) const override {
146  return fittedStar.getMag() - refStar.getMag();
147  };
148 
154  std::shared_ptr<afw::image::PhotoCalib> toPhotoCalib(CcdImage const &ccdImage) const override;
155 
157  void print(std::ostream &out) const override;
158 };
159 
160 } // namespace jointcal
161 } // namespace lsst
162 
163 #endif // LSST_JOINTCAL_SIMPLE_PHOTOMETRY_MODEL_H
lsst::jointcal::SimplePhotometryModel::offsetParams
void offsetParams(Eigen::VectorXd const &delta) override
Offset the parameters by the provided amounts (by -delta).
Definition: SimplePhotometryModel.cc:48
lsst::jointcal::MeasuredStar
objects measured on actual images.
Definition: MeasuredStar.h:46
LOG_LOGGER
#define LOG_LOGGER
Definition: Log.h:703
std::string
STL class.
std::shared_ptr
STL class.
std::list< std::shared_ptr< CcdImage > >
CcdImage.h
lsst::jointcal::SimplePhotometryModel::findMapping
PhotometryMappingBase * findMapping(CcdImage const &ccdImage) const override
Return the mapping associated with this ccdImage.
Definition: SimplePhotometryModel.cc:91
lsst::jointcal::SimpleMagnitudeModel::transform
double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
Definition: SimplePhotometryModel.cc:153
lsst::jointcal::SimpleFluxModel::transform
double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
Definition: SimplePhotometryModel.cc:114
std::unordered_map::reserve
T reserve(T... args)
Eigenstuff.h
lsst::jointcal::PhotometryModel
Definition: PhotometryModel.h:44
std::vector
STL class.
std::list::size
T size(T... args)
lsst::jointcal::SimplePhotometryModel::SimplePhotometryModel
SimplePhotometryModel(SimplePhotometryModel &&)=delete
lsst::jointcal::SimpleMagnitudeModel::offsetFittedStar
void offsetFittedStar(FittedStar &fittedStar, double delta) const override
Offset the appropriate flux or magnitude (by -delta).
Definition: SimplePhotometryModel.h:128
lsst::jointcal::SimpleMagnitudeModel
Definition: SimplePhotometryModel.h:123
lsst::jointcal::FittedStar
The objects which have been measured several times.
Definition: FittedStar.h:61
lsst::jointcal::RefStar
Objects used as position anchors, typically USNO stars.
Definition: RefStar.h:39
lsst::jointcal::SimpleFluxModel::computeRefResidual
double computeRefResidual(FittedStar const &fittedStar, RefStar const &refStar) const override
Return the fittedStar - refStar residual appropriate for this model (e.g. flux - flux or mag - mag).
Definition: SimplePhotometryModel.h:108
lsst::jointcal::BaseStar::getFluxErr
double getFluxErr() const
Definition: BaseStar.h:100
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::SimplePhotometryModel::assignIndices
Eigen::Index assignIndices(std::string const &whatToFit, Eigen::Index firstIndex) override
Assign indices in the full matrix to the parameters being fit in the mappings, starting at firstIndex...
Definition: SimplePhotometryModel.cc:38
lsst::jointcal::SimpleMagnitudeModel::computeResidual
double computeResidual(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override
Compute the residual between the model applied to a star and its associated fittedStar.
Definition: SimplePhotometryModel.cc:148
lsst::jointcal::SimplePhotometryModel::getTotalParameters
std::size_t getTotalParameters() const override
Return the total number of parameters in this model.
Definition: SimplePhotometryModel.cc:68
Point.h
lsst::jointcal::SimplePhotometryModel::SimplePhotometryModel
SimplePhotometryModel(SimplePhotometryModel const &)=delete
No copy or move: there is only ever one instance of a given model.
lsst::jointcal::SimpleFluxModel::computeResidual
double computeResidual(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override
Compute the residual between the model applied to a star and its associated fittedStar.
Definition: SimplePhotometryModel.cc:110
std::ostream
STL class.
lsst::jointcal::CcdImage
Handler of an actual image from a single CCD.
Definition: CcdImage.h:64
lsst::jointcal::SimpleFluxModel::offsetFittedStar
void offsetFittedStar(FittedStar &fittedStar, double delta) const override
Offset the appropriate flux or magnitude (by -delta).
Definition: SimplePhotometryModel.h:91
lsst::jointcal::SimpleMagnitudeModel::computeRefResidual
double computeRefResidual(FittedStar const &fittedStar, RefStar const &refStar) const override
Return the fittedStar - refStar residual appropriate for this model (e.g. flux - flux or mag - mag).
Definition: SimplePhotometryModel.h:145
lsst::jointcal::BaseStar::getMag
double getMag() const
Definition: BaseStar.h:103
lsst::jointcal::SimpleMagnitudeModel::toPhotoCalib
std::shared_ptr< afw::image::PhotoCalib > toPhotoCalib(CcdImage const &ccdImage) const override
Return the mapping of ccdImage represented as a PhotoCalib.
Definition: SimplePhotometryModel.cc:164
lsst::jointcal::SimplePhotometryModel::SimplePhotometryModel
SimplePhotometryModel(CcdImageList const &ccdImageList, LOG_LOGGER log, double errorPedestal=0)
Definition: SimplePhotometryModel.h:45
lsst::jointcal::SimpleMagnitudeModel::transformError
double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
Definition: SimplePhotometryModel.cc:158
lsst::jointcal::BaseStar::getFlux
double getFlux() const
Definition: BaseStar.h:96
lsst::jointcal::SimplePhotometryModel::operator=
SimplePhotometryModel & operator=(SimplePhotometryModel &&)=delete
lsst::jointcal::SimpleFluxModel
Definition: SimplePhotometryModel.h:86
lsst::jointcal
Definition: Associations.h:49
lsst::jointcal::SimpleFluxModel::transformError
double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
Definition: SimplePhotometryModel.cc:119
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::jointcal::SimplePhotometryModel::freezeErrorTransform
void freezeErrorTransform() override
Once this routine has been called, the error transform is not modified by offsetParams().
Definition: SimplePhotometryModel.cc:55
lsst::jointcal::SimplePhotometryModel
Photometric response model which has a single photometric factor per CcdImage.
Definition: SimplePhotometryModel.h:43
lsst::jointcal::BaseStar::getMagErr
double getMagErr() const
Definition: BaseStar.h:106
lsst::jointcal::SimplePhotometryModel::_myMap
MapType _myMap
Definition: SimplePhotometryModel.h:80
lsst::jointcal::SimplePhotometryModel::computeParameterDerivatives
void computeParameterDerivatives(MeasuredStar const &measuredStar, CcdImage const &ccdImage, Eigen::VectorXd &derivatives) const override
Compute the parametric derivatives of this model.
Definition: SimplePhotometryModel.cc:76
base.packages.log
log
Definition: packages.py:35
PhotometryModel.h
lsst::jointcal::SimpleFluxModel::SimpleFluxModel
SimpleFluxModel(CcdImageList const &ccdImageList, double errorPedestal=0)
Definition: SimplePhotometryModel.cc:99
lsst::jointcal::SimpleMagnitudeModel::print
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
Definition: SimplePhotometryModel.cc:172
lsst::jointcal::SimplePhotometryModel::getMappingIndices
void getMappingIndices(CcdImage const &ccdImage, IndexVector &indices) const override
Get how this set of parameters (of length Npar()) map into the "grand" fit.
Definition: SimplePhotometryModel.cc:61
std::size_t
lsst::jointcal::PhotometryModel::errorPedestal
double errorPedestal
Definition: PhotometryModel.h:224
lsst::jointcal::SimpleFluxModel::toPhotoCalib
std::shared_ptr< afw::image::PhotoCalib > toPhotoCalib(CcdImage const &ccdImage) const override
Return the mapping of ccdImage represented as a PhotoCalib.
Definition: SimplePhotometryModel.cc:125
lsst::jointcal::SimplePhotometryModel::print
virtual void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
Definition: SimplePhotometryModel.cc:83
std::unordered_map
STL class.
lsst::jointcal::SimpleFluxModel::print
void print(std::ostream &out) const override
Print a string representation of the contents of this mapping, for debugging.
Definition: SimplePhotometryModel.cc:131
lsst::jointcal::SimpleMagnitudeModel::SimpleMagnitudeModel
SimpleMagnitudeModel(CcdImageList const &ccdImageList, double errorPedestal=0)
Definition: SimplePhotometryModel.cc:136
lsst::jointcal::SimpleMagnitudeModel::getRefError
double getRefError(RefStar const &refStar) const override
Return the refStar error appropriate for this model (e.g. fluxErr or magErr).
Definition: SimplePhotometryModel.h:142
PhotometryMapping.h
lsst::jointcal::SimplePhotometryModel::MapType
std::unordered_map< CcdImageKey, std::unique_ptr< PhotometryMapping > > MapType
Definition: SimplePhotometryModel.h:79
lsst::jointcal::SimplePhotometryModel::operator=
SimplePhotometryModel & operator=(SimplePhotometryModel const &)=delete
lsst::jointcal::SimpleFluxModel::getRefError
double getRefError(RefStar const &refStar) const override
Return the refStar error appropriate for this model (e.g. fluxErr or magErr).
Definition: SimplePhotometryModel.h:105