lsst.jointcal  16.0-2-g90dae03
SimplePhotometryModel.cc
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "lsst/log/Log.h"
9 
10 namespace {
11 LOG_LOGGER _log = LOG_GET("jointcal.SimplePhotometryModel");
12 }
13 
14 namespace lsst {
15 namespace jointcal {
16 
18  _myMap.reserve(ccdImageList.size());
19  for (auto const &ccdImage : ccdImageList) {
20  auto photoCalib = ccdImage->getPhotoCalib();
21  // Use the single-frame processing calibration from the PhotoCalib as the default.
22  auto transfo =
23  std::make_shared<PhotometryTransfoSpatiallyInvariant>(photoCalib->getCalibrationMean());
24  _myMap.emplace(ccdImage->getHashKey(),
26  }
27  LOGLS_INFO(_log, "SimplePhotometryModel got " << _myMap.size() << " ccdImage mappings.");
28 }
29 
30 unsigned SimplePhotometryModel::assignIndices(std::string const &whatToFit, unsigned firstIndex) {
31  unsigned ipar = firstIndex;
32  for (auto const &i : _myMap) {
33  auto mapping = i.second.get();
34  mapping->setIndex(ipar);
35  ipar += mapping->getNpar();
36  }
37  return ipar;
38 }
39 
40 void SimplePhotometryModel::offsetParams(Eigen::VectorXd const &delta) {
41  for (auto &i : _myMap) {
42  auto mapping = i.second.get();
43  mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
44  }
45 }
46 
48  double instFlux) const {
49  auto mapping = findMapping(ccdImage);
50  return mapping->transform(star, instFlux);
51 }
52 
54  double instFluxErr) const {
55  auto mapping = findMapping(ccdImage);
56  return mapping->transformError(star, instFluxErr);
57 }
58 
60  for (auto &i : _myMap) {
61  i.second->freezeErrorTransform();
62  }
63 }
64 
66  std::vector<unsigned> &indices) const {
67  auto mapping = findMapping(ccdImage);
68  if (indices.size() < mapping->getNpar()) indices.resize(mapping->getNpar());
69  indices[0] = mapping->getIndex();
70 }
71 
73  int total = 0;
74  for (auto &i : _myMap) {
75  total += i.second->getNpar();
76  }
77  return total;
78 }
79 
81  CcdImage const &ccdImage,
82  Eigen::VectorXd &derivatives) const {
83  auto mapping = findMapping(ccdImage);
84  mapping->computeParameterDerivatives(measuredStar, measuredStar.getInstFlux(), derivatives);
85 }
86 
88  double calibration = (findMapping(ccdImage)->getParameters()[0]);
89  auto oldPhotoCalib = ccdImage.getPhotoCalib();
91  new afw::image::PhotoCalib(calibration, oldPhotoCalib->getCalibrationErr()));
92 }
93 
95  for (auto &i : _myMap) {
96  stream << i.first << ": ";
97  i.second->dump(stream);
98  stream << ", ";
99  }
100 }
101 
102 PhotometryMappingBase *SimplePhotometryModel::findMapping(CcdImage const &ccdImage) const {
103  auto i = _myMap.find(ccdImage.getHashKey());
104  if (i == _myMap.end())
106  "SimplePhotometryModel cannot find CcdImage " + ccdImage.getName());
107  return i->second.get();
108 }
109 
110 } // namespace jointcal
111 } // namespace lsst
std::shared_ptr< afw::image::PhotoCalib > toPhotoCalib(CcdImage const &ccdImage) const override
Return the mapping of ccdImage represented as a PhotoCalib.
double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar, double instFlux) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
Relates transfo(s) to their position in the fitting matrix and allows interaction with the transfo(s)...
virtual Eigen::VectorXd getParameters()=0
std::string getName() const
Return the _name that identifies this ccdImage.
Definition: CcdImage.h:50
int getTotalParameters() const override
Return the total number of parameters in this model.
SimplePhotometryModel(CcdImageList const &ccdImageList)
T end(T... args)
void computeParameterDerivatives(MeasuredStar const &measuredStar, CcdImage const &ccdImage, Eigen::VectorXd &derivatives) const override
Compute the parametric derivatives of this model.
T resize(T... args)
#define LOGLS_INFO(logger, message)
STL class.
void getMappingIndices(CcdImage const &ccdImage, std::vector< unsigned > &indices) const override
Get how this set of parameters (of length Npar()) map into the "grand" fit.
std::shared_ptr< afw::image::PhotoCalib > getPhotoCalib() const
Return the exposure&#39;s photometric calibration.
Definition: CcdImage.h:131
Class for a simple mapping implementing a generic Gtransfo.
objects measured on actual images.
Definition: MeasuredStar.h:19
double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar, double instFluxErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex) override
Assign indices to parameters involved in mappings, starting at firstIndex.
T find(T... args)
T size(T... args)
#define LSST_EXCEPT(type,...)
void offsetParams(Eigen::VectorXd const &delta) override
Offset the parameters by the provided amounts.
T emplace(T... args)
CcdImageKey getHashKey() const
Definition: CcdImage.h:122
void dump(std::ostream &stream=std::cout) const override
Dump the contents of the transfos, for debugging.
Handler of an actual image from a single CCD.
Definition: CcdImage.h:35
A mapping containing a single photometryTransfo.
STL class.
#define LOG_GET(logger)
void freezeErrorTransform() override
Once this routine has been called, the error transform is not modified by offsetParams().
T reserve(T... args)