3 #include "lsst/log/Log.h" 11 LOG_LOGGER _log = LOG_GET(
"jointcal.SimplePhotometryModel");
18 _myMap.reserve(ccdImageList.size());
19 for (
auto const &
ccdImage : ccdImageList) {
20 auto photoCalib =
ccdImage->getPhotoCalib();
23 std::make_shared<PhotometryTransfoSpatiallyInvariant>(photoCalib->getCalibrationMean());
24 _myMap.emplace(
ccdImage->getHashKey(),
27 LOGLS_INFO(_log,
"SimplePhotometryModel got " << _myMap.size() <<
" ccdImage mappings.");
31 unsigned ipar = firstIndex;
32 for (
auto const &i : _myMap) {
33 auto mapping = i.second.get();
34 mapping->setIndex(ipar);
35 ipar += mapping->getNpar();
41 for (
auto &i : _myMap) {
42 auto mapping = i.second.get();
43 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
48 double instFlux)
const {
49 auto mapping = findMapping(ccdImage);
50 return mapping->transform(star, instFlux);
54 std::vector<unsigned> &indices)
const {
55 auto mapping = findMapping(ccdImage);
56 if (indices.size() < mapping->getNpar()) indices.resize(mapping->getNpar());
57 indices[0] = mapping->getIndex();
62 Eigen::VectorXd &derivatives)
const {
63 auto mapping = findMapping(ccdImage);
64 mapping->computeParameterDerivatives(measuredStar, measuredStar.
getInstFlux(), derivatives);
68 double calibration = (findMapping(ccdImage)->
getParameters()[0]);
70 return std::unique_ptr<afw::image::PhotoCalib>(
71 new afw::image::PhotoCalib(calibration, oldPhotoCalib->getCalibrationErr()));
75 for (
auto &i : _myMap) {
76 i.second->dump(stream);
82 if (i == _myMap.end())
83 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
84 "SimplePhotometryModel cannot find CcdImage " + ccdImage.
getName());
85 return i->second.get();
std::shared_ptr< afw::image::PhotoCalib > toPhotoCalib(CcdImage const &ccdImage) const override
Return the mapping of ccdImage represented as a PhotoCalib.
Relates transfo(s) to their position in the fitting matrix and allows interaction with the transfo(s)...
virtual Eigen::VectorXd getParameters()=0
std::string getName() const
Return the _name that identifies this ccdImage.
double transform(CcdImage const &ccdImage, MeasuredStar const &star, double instFlux) const override
Return the on-sky transformed flux for measuredStar on ccdImage.
SimplePhotometryModel(CcdImageList const &ccdImageList)
void computeParameterDerivatives(MeasuredStar const &measuredStar, CcdImage const &ccdImage, Eigen::VectorXd &derivatives) const override
Compute the parametric derivatives of this model.
void getMappingIndices(CcdImage const &ccdImage, std::vector< unsigned > &indices) const override
Get how this set of parameters (of length Npar()) map into the "grand" fit.
std::shared_ptr< afw::image::PhotoCalib > getPhotoCalib() const
Return the exposure's photometric calibration.
Class for a simple mapping implementing a generic Gtransfo.
double getInstFlux() const
objects measured on actual images.
unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex) override
Assign indices to parameters involved in mappings, starting at firstIndex.
void offsetParams(Eigen::VectorXd const &delta) override
Offset the parameters by the provided amounts.
std::list< std::shared_ptr< CcdImage > > CcdImageList
CcdImageKey getHashKey() const
void dump(std::ostream &stream=std::cout) const override
Dump the contents of the transfos, for debugging.
Handler of an actual image from a single CCD.
A mapping containing a single photometryTransfo.