lsst.jointcal  master-ga8493ae4fe
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  for (auto const &ccdImage : ccdImageList) {
19  _myMap[ccdImage.get()] = std::unique_ptr<PhotometryMapping>(
21  }
22  LOGLS_INFO(_log, "SimplePhotometryModel got " << _myMap.size() << " ccdImage mappings.");
23 }
24 
25 unsigned SimplePhotometryModel::assignIndices(std::string const &whatToFit, unsigned firstIndex) {
26  unsigned ipar = firstIndex;
27  for (auto const &i : _myMap) {
28  auto mapping = i.second.get();
29  mapping->setIndex(ipar);
30  ipar += mapping->getNpar();
31  }
32  return ipar;
33 }
34 
35 void SimplePhotometryModel::offsetParams(Eigen::VectorXd const &delta) {
36  for (auto &i : _myMap) {
37  auto mapping = i.second.get();
38  mapping->offsetParams(&delta[mapping->getIndex()]);
39  }
40 }
41 
42 double SimplePhotometryModel::photomFactor(CcdImage const &ccdImage, Point const &where) const {
43  auto mapping = this->findMapping(ccdImage, "photomFactor");
44  return mapping->getTransfo().apply(where, 1.0);
45 }
46 
47 void SimplePhotometryModel::getMappingIndices(CcdImage const &ccdImage, std::vector<unsigned> &indices) {
48  auto mapping = this->findMapping(ccdImage, "getMappingIndices");
49  if (indices.size() < mapping->getNpar()) indices.resize(mapping->getNpar());
50  indices[0] = mapping->getIndex();
51 }
52 
54  CcdImage const &ccdImage,
55  Eigen::VectorXd &derivatives) {
56  // auto mapping = this->findMapping(ccdImage, "computeParameterDerivatives");
57  // TODO: use mapping->computeDerivative(measuredStar)*measuredStar.getFlux() here instead.
58  derivatives[0] = 1. * measuredStar.getFlux();
59 }
60 
61 PhotometryMapping *SimplePhotometryModel::findMapping(CcdImage const &ccdImage, std::string name) const {
62  auto i = _myMap.find(&ccdImage);
63  if (i == _myMap.end())
64  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
65  "SimplePolyModel::" + name + ", cannot find CcdImage " + ccdImage.getName());
66  return i->second.get();
67 }
68 
69 } // namespace jointcal
70 } // namespace lsst
A point in a plane.
Definition: Point.h:13
std::string getName() const
Return the _name that identifies this ccdImage.
Definition: CcdImage.h:83
SimplePhotometryModel(CcdImageList const &ccdImageList)
Class for a simple mapping implementing a generic Gtransfo.
Definition: Associations.h:24
void computeParameterDerivatives(MeasuredStar const &measuredStar, CcdImage const &ccdImage, Eigen::VectorXd &derivatives) override
Compute the parametric derivatives of this model.
objects measured on actual images.
Definition: MeasuredStar.h:18
void getMappingIndices(CcdImage const &ccdImage, std::vector< unsigned > &indices) override
Get how this set of parameters (of length Npar()) map into the "grand" fit.
double getFlux() const
Definition: BaseStar.h:71
double photomFactor(CcdImage const &ccdImage, Point const &where=Point()) const override
Return the "photometric factor" for this ccdImage.
unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex) override
Assign indices to parameters involved in mappings, starting at firstIndex.
void offsetParams(Eigen::VectorXd const &delta) override
Offset the parameters by the provided amounts.
std::list< std::shared_ptr< CcdImage > > CcdImageList
Definition: CcdImage.h:22
Handler of an actual image from a single CCD.
Definition: CcdImage.h:31