lsst.jointcal  master-gc935ebf72c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SimplePhotometryModel.cc
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "lsst/log/Log.h"
7 
8 namespace {
9 LOG_LOGGER _log = LOG_GET("jointcal.SimplePhotometryModel");
10 }
11 
12 namespace lsst {
13 namespace jointcal {
14 
16  VisitIdType refVisit = -1;
17  for (auto const &ccdImage : ccdImageList) {
18  VisitIdType visit = ccdImage->getVisit();
19  if (refVisit == -1) refVisit = visit;
20  if (visit == refVisit)
21  _myMap[ccdImage.get()].fixed = true;
22  else
23  _myMap[ccdImage.get()].fixed = false;
24  }
25  LOGLS_INFO(_log, "SimplePhotometryModel: using exposure " << refVisit << " as photometric reference ");
26 }
27 
28 unsigned SimplePhotometryModel::assignIndices(const std::string &whatToFit, unsigned firstIndex) {
29  unsigned ipar = firstIndex;
30  for (auto const &i : _myMap) {
31  PhotomStuff pf = i.second;
32  if (pf.fixed) continue;
33  pf.index = ipar;
34  ipar++;
35  }
36  return ipar;
37 }
38 
39 void SimplePhotometryModel::offsetParams(const Eigen::VectorXd &delta) {
40  for (auto const &i : _myMap) {
41  PhotomStuff pf = i.second;
42  if (!pf.fixed) pf.factor += delta[pf.index];
43  }
44 }
45 
46 SimplePhotometryModel::PhotomStuff &SimplePhotometryModel::find(const CcdImage &ccdImage) {
47  auto i = _myMap.find(&ccdImage);
48  if (i == _myMap.end())
49  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
50  "SimplePolyModel::find, cannot find CcdImage " + ccdImage.getName());
51  return (i->second);
52 }
53 
54 const SimplePhotometryModel::PhotomStuff &SimplePhotometryModel::find(const CcdImage &ccdImage) const {
55  auto i = _myMap.find(&ccdImage);
56  if (i == _myMap.end())
57  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
58  "SimplePolyModel::find, cannot find CcdImage " + ccdImage.getName());
59  return (i->second);
60 }
61 
62 double SimplePhotometryModel::photomFactor(const CcdImage &ccdImage, const Point &where) const {
63  const PhotomStuff &pf = find(ccdImage);
64  return pf.factor;
65 }
66 
68  const CcdImage &ccdImage, std::vector<unsigned> &indices,
69  Eigen::VectorXd &D) {
70  PhotomStuff &pf = find(ccdImage);
71  if (pf.fixed) {
72  indices.resize(0);
73  return;
74  }
75  indices.resize(1);
76  indices[0] = pf.index;
77  D[0] = 1;
78 }
79 } // namespace jointcal
80 } // namespace lsst
A point in a plane.
Definition: Point.h:13
void getIndicesAndDerivatives(const MeasuredStar &measuredStar, const CcdImage &ccdImage, std::vector< unsigned > &indices, Eigen::VectorXd &D)
number of parameters to be read in indices.size()
unsigned assignIndices(const std::string &whatToFit, unsigned firstIndex)
Assign indices to parameters involved in mappings, starting at firstIndex.
objects measured on actual images.
Definition: MeasuredStar.h:18
SimplePhotometryModel(const CcdImageList &ccdImageList)
std::list< std::shared_ptr< CcdImage > > CcdImageList
Definition: CcdImage.h:22
void offsetParams(const Eigen::VectorXd &delta)
Offset the parameters by the provided amounts.
int VisitIdType
Definition: CcdImage.h:24
double photomFactor(const CcdImage &ccdImage, const Point &where=Point()) const
Return the &quot;photometric factor&quot; for this ccdImage.
Handler of an actual image from a single CCD.
Definition: CcdImage.h:31
std::string getName() const
Return the _name that identifies this ccdImage.
Definition: CcdImage.h:78