lsst.jointcal  16.0-2-g90dae03
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: the chip derivatives start at 0, and the visit derivatives start at the last chip derivative.
25  // This is independent of the full-fit indices.
26  Eigen::Ref<Eigen::VectorXd> chipBlock = derivatives.segment(0, _chipMapping->getNpar());
27  Eigen::Ref<Eigen::VectorXd> visitBlock =
28  derivatives.segment(_chipMapping->getNpar(), _visitMapping->getNpar());
29 
30  // NOTE: chipBlock is the product of the chip derivatives and the visit transforms, and vice versa.
31  // NOTE: See DMTN-036 for the math behind this.
32  if (!_chipMapping->isFixed()) {
33  _chipMapping->getTransfo()->computeParameterDerivatives(measuredStar.x, measuredStar.y, instFlux,
34  chipBlock);
35  chipBlock *= visitScale;
36  }
37  _visitMapping->getTransfo()->computeParameterDerivatives(measuredStar.getXFocal(),
38  measuredStar.getYFocal(), instFlux, visitBlock);
39  visitBlock *= chipScale;
40 }
41 
43  if (indices.size() < getNpar()) indices.resize(getNpar());
44  _chipMapping->getMappingIndices(indices);
45  // TODO DM-12169: there is probably a better way to feed a subpart of a std::vector (a view or iterators?)
46  std::vector<unsigned> tempIndices(_visitMapping->getNpar());
47  _visitMapping->getMappingIndices(tempIndices);
48  for (unsigned k = 0; k < _visitMapping->getNpar(); ++k) {
49  indices.at(k + _chipMapping->getNpar()) = tempIndices.at(k);
50  }
51 }
52 
53 } // namespace jointcal
54 } // 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.
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)