lsst.jointcal  14.0-14-g932474c+11
PhotometryMapping.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_PHOTOMETRY_MAPPING_H
3 #define LSST_JOINTCAL_PHOTOMETRY_MAPPING_H
4 
5 #include <memory>
6 
8 
12 #include "lsst/jointcal/Point.h"
14 
15 namespace lsst {
16 namespace jointcal {
17 
22 public:
23  PhotometryMappingBase() : index(-1), fixed(false) {}
25 
31 
33  virtual unsigned getNpar() const = 0;
34 
44  virtual double transform(MeasuredStar const &measuredStar, double instFlux) const = 0;
45 
53  virtual void computeParameterDerivatives(MeasuredStar const &measuredStar, double instFlux,
54  Eigen::Ref<Eigen::VectorXd> derivatives) const = 0;
55 
62  virtual void offsetParams(Eigen::VectorXd const &delta) = 0;
63 
65  void setFixed(bool _fixed) { fixed = _fixed; }
66  bool isFixed() { return fixed; }
67 
68  virtual Eigen::VectorXd getParameters() = 0;
69 
74  virtual void getMappingIndices(std::vector<unsigned> &indices) const = 0;
75 
77  virtual void dump(std::ostream &stream = std::cout) const = 0;
78 
80  unsigned getIndex() { return index; }
81 
83  void setIndex(unsigned i) { index = i; }
84 
85 protected:
86  // Start index of this mapping in the "grand" fit
87  unsigned index;
88  // Should this mapping be varied during fitting?
89  bool fixed;
90 };
91 
96 public:
98  : PhotometryMappingBase(), _transfo(std::move(transfo)) {}
99 
101  unsigned getNpar() const override {
102  if (fixed) {
103  return 0;
104  } else {
105  return _transfo->getNpar();
106  }
107  }
108 
110  double transform(MeasuredStar const &measuredStar, double instFlux) const override {
111  return _transfo->transform(measuredStar.x, measuredStar.y, instFlux);
112  }
113 
115  void computeParameterDerivatives(MeasuredStar const &measuredStar, double instFlux,
116  Eigen::Ref<Eigen::VectorXd> derivatives) const override {
117  if (fixed) {
118  return;
119  } else {
120  _transfo->computeParameterDerivatives(measuredStar.x, measuredStar.y, instFlux, derivatives);
121  }
122  }
123 
125  void offsetParams(Eigen::VectorXd const &delta) override { _transfo->offsetParams(delta); }
126 
128  Eigen::VectorXd getParameters() override { return _transfo->getParameters(); }
129 
131  void getMappingIndices(std::vector<unsigned> &indices) const override {
132  if (indices.size() < getNpar()) indices.resize(getNpar());
133  for (unsigned k = 0; k < getNpar(); ++k) {
134  indices[k] = index + k;
135  }
136  }
137 
139  void dump(std::ostream &stream = std::cout) const override {
140  stream << "index: " << index << " params: ";
141  _transfo->dump(stream);
142  }
143 
144  std::shared_ptr<PhotometryTransfo> getTransfo() const { return _transfo; }
145 
146 private:
147  // the actual transformation to be fit
149 };
150 
155 public:
159  _chipMapping(std::move(chipMapping)),
160  _visitMapping(std::move(visitMapping)) {}
161 
163  unsigned getNpar() const override { return _chipMapping->getNpar() + _visitMapping->getNpar(); }
164 
166  double transform(MeasuredStar const &measuredStar, double instFlux) const override {
167  double tempFlux = _chipMapping->getTransfo()->transform(measuredStar.x, measuredStar.y, instFlux);
168  return _visitMapping->getTransfo()->transform(measuredStar.getXFocal(), measuredStar.getYFocal(),
169  tempFlux);
170  }
171 
173  void computeParameterDerivatives(MeasuredStar const &measuredStar, double instFlux,
174  Eigen::Ref<Eigen::VectorXd> derivatives) const override;
175 
177  void offsetParams(Eigen::VectorXd const &delta) override {
178  _chipMapping->offsetParams(delta.segment(0, _chipMapping->getNpar()));
179  _visitMapping->offsetParams(delta.segment(_chipMapping->getNpar(), _visitMapping->getNpar()));
180  }
181 
183  Eigen::VectorXd getParameters() override {
184  Eigen::VectorXd joined(getNpar());
185  joined << _chipMapping->getParameters(), _visitMapping->getParameters();
186  return joined;
187  }
188 
190  void getMappingIndices(std::vector<unsigned> &indices) const override;
191 
193  void dump(std::ostream &stream = std::cout) const override {
194  stream << "index: " << index << " chipMapping: ";
195  _chipMapping->dump(stream);
196  stream << "visitMapping: ";
197  _visitMapping->dump(stream);
198  }
199 
200  std::shared_ptr<PhotometryMapping> getChipMapping() const { return _chipMapping; }
201  std::shared_ptr<PhotometryMapping> getVisitMapping() const { return _visitMapping; }
202 
203 private:
204  // the actual transformation to be fit
207 };
208 
209 } // namespace jointcal
210 } // namespace lsst
211 
212 #endif // LSST_JOINTCAL_PHOTOMETRY_MAPPING_H
virtual double transform(MeasuredStar const &measuredStar, double instFlux) const =0
Return the on-sky transformed flux at (x,y).
PhotometryMapping(std::shared_ptr< PhotometryTransfo > transfo)
void computeParameterDerivatives(MeasuredStar const &measuredStar, double instFlux, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
Relates transfo(s) to their position in the fitting matrix and allows interaction with the transfo(s)...
virtual Eigen::VectorXd getParameters()=0
std::shared_ptr< PhotometryMapping > getChipMapping() const
void dump(std::ostream &stream=std::cout) const override
Dump the contents of the transfos, for debugging.
void offsetParams(Eigen::VectorXd const &delta) override
Offset the transfo parameters by delta.
STL namespace.
double transform(MeasuredStar const &measuredStar, double instFlux) const override
Return the on-sky transformed flux at (x,y).
T resize(T... args)
double x
coordinate
Definition: Point.h:18
std::shared_ptr< PhotometryMapping > getVisitMapping() const
void setIndex(unsigned i)
Set the index of this mapping in the grand fit.
void getMappingIndices(std::vector< unsigned > &indices) const override
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
Class for a simple mapping implementing a generic Gtransfo.
void dump(std::ostream &stream=std::cout) const override
Dump the contents of the transfos, for debugging.
void offsetParams(Eigen::VectorXd const &delta) override
Offset the transfo parameters by delta.
objects measured on actual images.
Definition: MeasuredStar.h:18
T move(T... args)
double transform(MeasuredStar const &measuredStar, double instFlux) const override
Return the on-sky transformed flux at (x,y).
T size(T... args)
ChipVisitPhotometryMapping(std::shared_ptr< PhotometryMapping > chipMapping, std::shared_ptr< PhotometryMapping > visitMapping)
unsigned getNpar() const override
Number of total parameters in this mapping.
PhotometryMappingBase & operator=(PhotometryMappingBase const &)=delete
void setFixed(bool _fixed)
Make this mapping&#39;s parameters fixed (i.e. not varied during fitting).
unsigned getIndex()
Get the index of this mapping in the grand fit.
std::shared_ptr< PhotometryTransfo > getTransfo() const
virtual void offsetParams(Eigen::VectorXd const &delta)=0
Offset the transfo parameters by delta.
A mapping containing a single photometryTransfo.
STL class.
virtual void dump(std::ostream &stream=std::cout) const =0
Dump the contents of the transfos, for debugging.
virtual void computeParameterDerivatives(MeasuredStar const &measuredStar, double instFlux, Eigen::Ref< Eigen::VectorXd > derivatives) const =0
Compute the derivatives with respect to the parameters (i.e.
virtual unsigned getNpar() const =0
Number of total parameters in this mapping.
virtual void getMappingIndices(std::vector< unsigned > &indices) const =0
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
A two-level photometric transform: one for the ccd and one for the visit.
unsigned getNpar() const override
Number of total parameters in this mapping.
Eigen::VectorXd getParameters() override