lsst.jointcal  16.0-7-g6e35192+1
PhotometryMapping.cc
Go to the documentation of this file.
1 #include "lsst/log/Log.h"
2 
5 
6 namespace {
7 LOG_LOGGER _log = LOG_GET("jointcal.PhotometryMapping");
8 }
9 
10 namespace lsst {
11 namespace jointcal {
12 
14  double instFlux,
15  Eigen::Ref<Eigen::VectorXd> derivatives) const {
16  // TODO DM-12161: possible optimization is to merge transform and computeDerivatives,
17  // and/or save these intermediate calculations when transforming flux to use in derivatives.
18  // Like what AstrometryMappings do with `computeTransformAndDerivatives` vs. `transformPosAndErrors`.
19 
20  double chipScale = _chipMapping->getTransfo()->transform(measuredStar.x, measuredStar.y, 1);
21  double visitScale =
22  _visitMapping->getTransfo()->transform(measuredStar.getXFocal(), measuredStar.getYFocal(), 1);
23 
24  // NOTE: chipBlock is the product of the chip derivatives and the visit transforms, and vice versa.
25  // NOTE: See DMTN-036 for the math behind this.
26  if (_nParChips > 0 && !_chipMapping->isFixed()) {
27  // The chip derivatives start at 0, independent of the full-fit indices.
28  Eigen::Ref<Eigen::VectorXd> chipBlock = derivatives.segment(0, _nParChips);
29  _chipMapping->getTransfo()->computeParameterDerivatives(measuredStar.x, measuredStar.y, instFlux,
30  chipBlock);
31  chipBlock *= visitScale;
32  }
33  if (_nParVisits > 0) {
34  // The visit derivatives start at the last chip derivative, independent of the full-fit indices.
35  Eigen::Ref<Eigen::VectorXd> visitBlock = derivatives.segment(_nParChips, _nParVisits);
36  _visitMapping->getTransfo()->computeParameterDerivatives(
37  measuredStar.getXFocal(), measuredStar.getYFocal(), instFlux, visitBlock);
38  visitBlock *= chipScale;
39  }
40 }
41 
42 double ChipVisitPhotometryMapping::transformError(MeasuredStar const &measuredStar, double instFlux,
43  double instFluxErr) const {
44  // The transformed error is s_phi = dM(f,x,y)/df * s_f.
45  double tempFlux =
46  _chipMapping->getTransfoErrors()->transform(measuredStar.x, measuredStar.y, instFluxErr);
47  return _visitMapping->getTransfoErrors()->transform(measuredStar.getXFocal(), measuredStar.getYFocal(),
48  tempFlux);
49 }
50 
52  if (indices.size() < getNpar()) indices.resize(getNpar());
53  if (_nParChips > 0) {
54  _chipMapping->getMappingIndices(indices);
55  }
56  if (_nParVisits > 0) {
57  // TODO DM-12169: there is probably a better way to feed a subpart of a std::vector
58  // (maybe a view or iterators?)
59  std::vector<unsigned> tempIndices(_visitMapping->getNpar());
60  _visitMapping->getMappingIndices(tempIndices);
61  for (unsigned k = 0; k < _visitMapping->getNpar(); ++k) {
62  indices.at(k + _nParChips) = tempIndices.at(k);
63  }
64  }
65 }
66 
67 void ChipVisitPhotometryMapping::setWhatToFit(bool const fittingChips, bool const fittingVisits) {
68  if (fittingChips) {
69  _nParChips = _chipMapping->getNpar();
70  } else {
71  _nParChips = 0;
72  }
73  if (fittingVisits) {
74  _nParVisits = _visitMapping->getNpar();
75  } else {
76  _nParVisits = 0;
77  }
78 }
79 
80 } // namespace jointcal
81 } // namespace lsst
void computeParameterDerivatives(MeasuredStar const &measuredStar, double instFlux, Eigen::Ref< Eigen::VectorXd > derivatives) const override
Compute the derivatives with respect to the parameters (i.e.
void getMappingIndices(std::vector< unsigned > &indices) const override
Gets how this set of parameters (of length getNpar()) map into the "grand" fit.
void setWhatToFit(bool const fittingChips, bool const fittingVisits)
Set whether to fit chips or visits.
double transformError(MeasuredStar const &measuredStar, double instFlux, double instFluxErr) const override
Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.
T resize(T... args)
double x
coordinate
Definition: Point.h:18
T at(T... args)
Class for a simple mapping implementing a generic Gtransfo.
objects measured on actual images.
Definition: MeasuredStar.h:19
T size(T... args)
unsigned getNpar() const override
Number of total parameters in this mapping.
#define LOG_GET(logger)