lsst.jointcal  master-ge1f85bc4d5+2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PhotometryTransfo.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #ifndef LSST_JOINTCAL_PHOTOMETRY_TRANSFO_H
3 #define LSST_JOINTCAL_PHOTOMETRY_TRANSFO_H
4 
5 #include <iostream>
6 #include <sstream>
7 #include <memory>
8 
9 #include "lsst/jointcal/Point.h"
10 
11 namespace lsst {
12 namespace jointcal {
13 
14 class Point;
15 
16 class PhotometryTransfoSpatiallyInvariant;
17 
18 /*
19  * A photometric transform, defined as a scale factor of the input calibration.
20  *
21  * initialCalibFlux (Maggies) * transfo(x,y) -> correctedFlux (Maggies)
22  *
23  * @todo Eventually will be defined the same as PhotoCalib:
24  * instFlux (ADU) -> flux (maggies)
25  *
26  * @seealso lsst::afw::image::PhotoCalib
27  */
29 public:
31  virtual double apply(double x, double y, double instFlux) const = 0;
32 
33  double apply(Point const &in, double instFlux) const { return apply(in.x, in.y, instFlux); }
34 
36  virtual void dump(std::ostream &stream = std::cout) const = 0;
37 
39  std::string __str__() const {
40  std::stringstream s;
41  dump(s);
42  return s.str();
43  }
44 
46  virtual int getNpar() const { return 0; }
47 
49  virtual void offsetParams(double const *delta) = 0;
50 
52  virtual std::unique_ptr<PhotometryTransfo> clone() const = 0;
53 
54  void computeDerivative(Point const &where, PhotometryTransfoSpatiallyInvariant &derivative,
55  const double step = 0.01) const;
56 };
57 
58 /*
59  * Photometric offset independent of position.
60  *
61  * initialCalibFlux (Maggies) * SpatiallyInvariantTransfo -> correctedFlux (Maggies)
62  *
63  * @todo Eventually to be defined as:
64  * instFlux / value = flux
65  */
67 public:
68  PhotometryTransfoSpatiallyInvariant(double value = 1) : _value(value) {}
69 
70  double apply(double x, double y, double instFlux) const override { return instFlux * _value; }
71 
72  void dump(std::ostream &stream = std::cout) const override { stream << _value; }
73 
74  int getNpar() const override { return 1; }
75 
76  void offsetParams(const double *delta) override { _value -= *delta; };
77 
78  std::unique_ptr<PhotometryTransfo> clone() const override {
79  return std::unique_ptr<PhotometryTransfo>(new PhotometryTransfoSpatiallyInvariant(_value));
80  }
81 
84  const double step = 0.01) const {
85  derivative.setValue(1);
86  }
87 
88 protected:
89  void setValue(double value) { _value = value; }
90 
91  friend class PhotometryTransfo;
92 
93 private:
95  double _value;
96 };
97 
98 } // namespace jointcal
99 } // namespace lsst
100 
101 #endif // LSST_JOINTCAL_PHOTOMETRY_TRANSFO_H
virtual std::unique_ptr< PhotometryTransfo > clone() const =0
return a copy (allocated by new) of the transformation.
A point in a plane.
Definition: Point.h:13
virtual void dump(std::ostream &stream=std::cout) const =0
dumps the transfo coefficients to stream.
std::string __str__() const
Return a string describing this transfo. For the pybind11/python layer.
double x
coordinate
Definition: Point.h:18
void offsetParams(const double *delta) override
Offset the parameters by some amount during fitting.
void computeDerivative(Point const &where, PhotometryTransfoSpatiallyInvariant &derivative, const double step=0.01) const
double apply(Point const &in, double instFlux) const
double apply(double x, double y, double instFlux) const override
Apply the transform to instFlux at (x,y), put result in flux.
void computeDerivative(Point const &where, PhotometryTransfoSpatiallyInvariant &derivative, const double step=0.01) const
The spatial derivative of a constant zeropoint is 1.
std::unique_ptr< PhotometryTransfo > clone() const override
return a copy (allocated by new) of the transformation.
void dump(std::ostream &stream=std::cout) const override
dumps the transfo coefficients to stream.
virtual int getNpar() const
Return the number of parameters (used to compute chisq)
virtual void offsetParams(double const *delta)=0
Offset the parameters by some amount during fitting.
virtual double apply(double x, double y, double instFlux) const =0
Apply the transform to instFlux at (x,y), put result in flux.
int getNpar() const override
Return the number of parameters (used to compute chisq)