lsst.jointcal  16.0-5-g82b7855+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 
43  if (indices.size() < getNpar()) indices.resize(getNpar());
44  if (_nParChips > 0) {
45  _chipMapping->getMappingIndices(indices);
46  }
47  if (_nParVisits > 0) {
48  // TODO DM-12169: there is probably a better way to feed a subpart of a std::vector
49  // (maybe a view or iterators?)
50  std::vector<unsigned> tempIndices(_visitMapping->getNpar());
51  _visitMapping->getMappingIndices(tempIndices);
52  for (unsigned k = 0; k < _visitMapping->getNpar(); ++k) {
53  indices.at(k + _nParChips) = tempIndices.at(k);
54  }
55  }
56 }
57 
58 void ChipVisitPhotometryMapping::setWhatToFit(bool const fittingChips, bool const fittingVisits) {
59  if (fittingChips) {
60  _nParChips = _chipMapping->getNpar();
61  } else {
62  _nParChips = 0;
63  }
64  if (fittingVisits) {
65  _nParVisits = _visitMapping->getNpar();
66  } else {
67  _nParVisits = 0;
68  }
69 }
70 
71 } // namespace jointcal
72 } // 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.
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)