LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
lsst::jointcal::ConstrainedPhotometryModel Class Referenceabstract

Photometry model with constraints, \(M(x,y) = M_CCD(x,y)*M_visit(u,v)\). More...

#include <ConstrainedPhotometryModel.h>

Inheritance diagram for lsst::jointcal::ConstrainedPhotometryModel:
lsst::jointcal::PhotometryModel lsst::jointcal::ConstrainedFluxModel lsst::jointcal::ConstrainedMagnitudeModel

Classes

struct  PrepPhotoCalib
 To hold the return of prepPhotoCalib. More...
 

Public Member Functions

 ConstrainedPhotometryModel (CcdImageList const &ccdImageList, geom::Box2D const &focalPlaneBBox, LOG_LOGGER log, int visitOrder=7, double errorPedestal_=0)
 Construct a constrained photometry model. More...
 
 ConstrainedPhotometryModel (ConstrainedPhotometryModel const &)=delete
 No copy or move: there is only ever one instance of a given model (i.e. per ccd+visit) More...
 
 ConstrainedPhotometryModel (ConstrainedPhotometryModel &&)=delete
 
ConstrainedPhotometryModeloperator= (ConstrainedPhotometryModel const &)=delete
 
ConstrainedPhotometryModeloperator= (ConstrainedPhotometryModel &&)=delete
 
Eigen::Index assignIndices (std::string const &whatToFit, Eigen::Index firstIndex) override
 Assign indices in the full matrix to the parameters being fit in the mappings, starting at firstIndex. More...
 
void offsetParams (Eigen::VectorXd const &delta) override
 Offset the parameters by the provided amounts (by -delta). More...
 
void freezeErrorTransform () override
 Once this routine has been called, the error transform is not modified by offsetParams(). More...
 
void getMappingIndices (CcdImage const &ccdImage, IndexVector &indices) const override
 Get how this set of parameters (of length Npar()) map into the "grand" fit. More...
 
std::size_t getTotalParameters () const override
 Return the total number of parameters in this model. More...
 
void computeParameterDerivatives (MeasuredStar const &measuredStar, CcdImage const &ccdImage, Eigen::VectorXd &derivatives) const override
 Compute the parametric derivatives of this model. More...
 
void dump (std::ostream &stream=std::cout) const override
 Dump the contents of the transforms, for debugging. More...
 
virtual void offsetFittedStar (FittedStar &fittedStar, double delta) const =0
 Offset the appropriate flux or magnitude (by -delta). More...
 
virtual double computeResidual (CcdImage const &ccdImage, MeasuredStar const &measuredStar) const =0
 Compute the residual between the model applied to a star and its associated fittedStar. More...
 
virtual double transform (CcdImage const &ccdImage, MeasuredStar const &measuredStar) const =0
 Return the on-sky transformed flux for measuredStar on ccdImage. More...
 
virtual double transformError (CcdImage const &ccdImage, MeasuredStar const &measuredStar) const =0
 Return the on-sky transformed flux uncertainty for measuredStar on ccdImage. More...
 
virtual double getRefError (RefStar const &refStar) const =0
 Return the refStar error appropriate for this model (e.g. fluxErr or magErr). More...
 
virtual double computeRefResidual (FittedStar const &fittedStar, RefStar const &refStar) const =0
 Return the fittedStar - refStar residual appropriate for this model (e.g. flux - flux or mag - mag). More...
 
virtual std::shared_ptr< afw::image::PhotoCalibtoPhotoCalib (CcdImage const &ccdImage) const =0
 Return the mapping of ccdImage represented as a PhotoCalib. More...
 
std::size_t getNpar (CcdImage const &ccdImage) const
 Return the number of parameters in the mapping of CcdImage. More...
 
PhotometryMappingBase const & getMapping (CcdImage const &ccdImage) const
 Get the mapping associated with ccdImage. More...
 
bool validate (CcdImageList const &ccdImageList, int ndof) const
 Return true if this is a "reasonable" model. More...
 
bool checkPositiveOnBBox (CcdImage const &ccdImage) const
 Check that the model is positive on the ccdImage bbox. More...
 
double getErrorPedestal ()
 
double tweakFluxError (jointcal::MeasuredStar const &measuredStar) const
 Add a fraction of the instrumental flux to the instrumental flux error, in quadrature. More...
 
double tweakMagnitudeError (jointcal::MeasuredStar const &measuredStar) const
 Add a small magnitude offset to the "instrumental magnitude" error, in quadrature. More...
 

Protected Types

typedef std::unordered_map< CcdImageKey, std::unique_ptr< ChipVisitPhotometryMapping > > MapType
 
typedef std::map< VisitIdType, std::shared_ptr< PhotometryMapping > > VisitMapType
 
typedef std::map< CcdIdType, std::shared_ptr< PhotometryMapping > > ChipMapType
 

Protected Member Functions

PhotometryMappingBasefindMapping (CcdImage const &ccdImage) const override
 Return a pointer to the mapping associated with this ccdImage. More...
 
template<class ChipTransform , class VisitTransform , class ChipVisitMapping >
void initialize (CcdImageList const &ccdImageList, geom::Box2D const &focalPlaneBBox, int visitOrder)
 Initialize the chip, visit, and chipVisit mappings by creating appropriate transforms and mappings. More...
 
virtual double initialChipCalibration (std::shared_ptr< afw::image::PhotoCalib const > photoCalib)=0
 Return the initial calibration to use from this photoCalib. More...
 
PrepPhotoCalib prepPhotoCalib (CcdImage const &ccdImage) const
 Helper for preparing toPhotoCalib() More...
 

Protected Attributes

MapType _chipVisitMap
 
VisitMapType _visitMap
 
ChipMapType _chipMap
 
LOG_LOGGER _log
 lsst.logging instance, to be created by a subclass so that messages have consistent name. More...
 
double errorPedestal
 

Detailed Description

Photometry model with constraints, \(M(x,y) = M_CCD(x,y)*M_visit(u,v)\).

This model consists of the following components:

Because this model's parameters are degenerate under multiplication by a constant, \(M=(a*M_CCD)*(1/a*M_visit)\), we hold one CCD's zero point fixed to remove that degeneracy.

Definition at line 48 of file ConstrainedPhotometryModel.h.

Member Typedef Documentation

◆ ChipMapType

Definition at line 109 of file ConstrainedPhotometryModel.h.

◆ MapType

Definition at line 102 of file ConstrainedPhotometryModel.h.

◆ VisitMapType

Definition at line 106 of file ConstrainedPhotometryModel.h.

Constructor & Destructor Documentation

◆ ConstrainedPhotometryModel() [1/3]

lsst::jointcal::ConstrainedPhotometryModel::ConstrainedPhotometryModel ( CcdImageList const &  ccdImageList,
geom::Box2D const &  focalPlaneBBox,
LOG_LOGGER  log,
int  visitOrder = 7,
double  errorPedestal_ = 0 
)
inlineexplicit

Construct a constrained photometry model.

Parameters
ccdImageListThe list of CCDImages to construct the model for.
focalPlaneBBoxThe bounding box of the camera's focal plane, defining the domain of the visit polynomial.
[in]logAn lsst::log::Log instance to log messages to.
[in]visitOrderThe order of the visit polynomial.
[in]errorPedestal_A pedestal in flux or magnitude to apply to all MeasuredStar flux errors.

Definition at line 60 of file ConstrainedPhotometryModel.h.

63  : PhotometryModel(log, errorPedestal_), _fittingChips(false), _fittingVisits(false) {
64  _chipVisitMap.reserve(ccdImageList.size());
65  }
PhotometryModel(LOG_LOGGER log, double errorPedestal_=0)
T reserve(T... args)

◆ ConstrainedPhotometryModel() [2/3]

lsst::jointcal::ConstrainedPhotometryModel::ConstrainedPhotometryModel ( ConstrainedPhotometryModel const &  )
delete

No copy or move: there is only ever one instance of a given model (i.e. per ccd+visit)

◆ ConstrainedPhotometryModel() [3/3]

lsst::jointcal::ConstrainedPhotometryModel::ConstrainedPhotometryModel ( ConstrainedPhotometryModel &&  )
delete

Member Function Documentation

◆ assignIndices()

Eigen::Index lsst::jointcal::ConstrainedPhotometryModel::assignIndices ( std::string const &  whatToFit,
Eigen::Index  firstIndex 
)
overridevirtual

Assign indices in the full matrix to the parameters being fit in the mappings, starting at firstIndex.

Parameters
[in]whatToFitString containing parameters to fit.
[in]firstIndexIndex to start assigning at.
Returns
The highest assigned index.

Implements lsst::jointcal::PhotometryModel.

Definition at line 45 of file ConstrainedPhotometryModel.cc.

48  {
49  Eigen::Index index = firstIndex;
50  if (whatToFit.find("Model") == std::string::npos) {
51  LOGLS_WARN(_log, "assignIndices was called and Model is *not* in whatToFit");
52  return index;
53  }
54 
55  // If we got here, "Model" is definitely in whatToFit.
56  _fittingChips = (whatToFit.find("ModelChip") != std::string::npos);
57  _fittingVisits = (whatToFit.find("ModelVisit") != std::string::npos);
58  // If nothing more than "Model" is specified, it means fit everything.
59  if ((!_fittingChips) && (!_fittingVisits)) {
60  _fittingChips = _fittingVisits = true;
61  }
62 
63  if (_fittingChips) {
64  for (auto &idMapping : _chipMap) {
65  auto mapping = idMapping.second.get();
66  // Don't assign indices for fixed parameters.
67  if (mapping->isFixed()) continue;
68  mapping->setIndex(index);
69  index += mapping->getNpar();
70  }
71  }
72  if (_fittingVisits) {
73  for (auto &idMapping : _visitMap) {
74  auto mapping = idMapping.second.get();
75  mapping->setIndex(index);
76  index += mapping->getNpar();
77  }
78  }
79  for (auto &idMapping : _chipVisitMap) {
80  idMapping.second->setWhatToFit(_fittingChips, _fittingVisits);
81  }
82  return index;
83 }
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:648
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...

◆ checkPositiveOnBBox()

bool lsst::jointcal::PhotometryModel::checkPositiveOnBBox ( CcdImage const &  ccdImage) const
inherited

Check that the model is positive on the ccdImage bbox.

Parameters
ccdImageThe ccdImage to test.
Returns
True if the image is positive on a sampling of points of the ccdImage bbox.

Definition at line 49 of file PhotometryModel.cc.

49  {
50  bool check = true;
51  auto bbox = ccdImage.getImageFrame();
52  for (auto const &x : {bbox.xMin, bbox.getCenter().x, bbox.xMax})
53  for (auto const &y : {bbox.yMin, bbox.getCenter().y, bbox.yMax}) {
54  // flux, fluxErr, instFlux, instFluxErr all 1
56  star.setInstFluxAndErr(1, 1);
57  double result = transform(ccdImage, star);
58  // Don't short circuit so that we log every place the model is negative.
59  if (result < 0) {
60  LOGLS_WARN(_log, "CcdImage " << ccdImage.getName() << " is negative at (" << x << "," << y
61  << "): " << result);
62  check = false;
63  }
64  }
65  return check;
66 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:648
int y
Definition: SpanSet.cc:49
The base class for handling stars. Used by all matching routines.
Definition: BaseStar.h:50
objects measured on actual images.
Definition: MeasuredStar.h:46
double x
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...
py::object result
Definition: _schema.cc:429
virtual double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const =0
Return the on-sky transformed flux for measuredStar on ccdImage.

◆ computeParameterDerivatives()

void lsst::jointcal::ConstrainedPhotometryModel::computeParameterDerivatives ( MeasuredStar const &  measuredStar,
CcdImage const &  ccdImage,
Eigen::VectorXd &  derivatives 
) const
overridevirtual

Compute the parametric derivatives of this model.

Parameters
[in]measuredStarThe measured star with the position and flux to compute at.
[in]ccdImageThe ccdImage containing the measured star, to find the correct mapping.
[out]derivativesThe computed derivatives. Must be pre-allocated to the correct size.

Implements lsst::jointcal::PhotometryModel.

Definition at line 128 of file ConstrainedPhotometryModel.cc.

130  {
131  auto mapping = findMapping(ccdImage);
132  mapping->computeParameterDerivatives(measuredStar, measuredStar.getInstFlux(), derivatives);
133 }
PhotometryMappingBase * findMapping(CcdImage const &ccdImage) const override
Return a pointer to the mapping associated with this ccdImage.

◆ computeRefResidual()

virtual double lsst::jointcal::PhotometryModel::computeRefResidual ( FittedStar const &  fittedStar,
RefStar const &  refStar 
) const
pure virtualinherited

Return the fittedStar - refStar residual appropriate for this model (e.g. flux - flux or mag - mag).

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::SimpleMagnitudeModel, and lsst::jointcal::SimpleFluxModel.

◆ computeResidual()

virtual double lsst::jointcal::PhotometryModel::computeResidual ( CcdImage const &  ccdImage,
MeasuredStar const &  measuredStar 
) const
pure virtualinherited

Compute the residual between the model applied to a star and its associated fittedStar.

\[ residual = Model(measuredStar) - fittedStar \]

Parameters
ccdImageThe ccdImage where measuredStar resides.
measuredStarThe measured star position to compute the residual of.
Returns
The residual.

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::SimpleMagnitudeModel, and lsst::jointcal::SimpleFluxModel.

◆ dump()

void lsst::jointcal::ConstrainedPhotometryModel::dump ( std::ostream stream = std::cout) const
overridevirtual

Dump the contents of the transforms, for debugging.

Implements lsst::jointcal::PhotometryModel.

Definition at line 157 of file ConstrainedPhotometryModel.cc.

157  {
158  for (auto &idMapping : _chipMap) {
159  idMapping.second->dump(stream);
160  stream << std::endl;
161  }
162  stream << std::endl;
163  for (auto &idMapping : _visitMap) {
164  idMapping.second->dump(stream);
165  stream << std::endl;
166  }
167 }
T endl(T... args)

◆ findMapping()

PhotometryMappingBase * lsst::jointcal::ConstrainedPhotometryModel::findMapping ( CcdImage const &  ccdImage) const
overrideprotectedvirtual

Return a pointer to the mapping associated with this ccdImage.

Implements lsst::jointcal::PhotometryModel.

Definition at line 169 of file ConstrainedPhotometryModel.cc.

169  {
170  auto idMapping = _chipVisitMap.find(ccdImage.getHashKey());
171  if (idMapping == _chipVisitMap.end())
172  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
173  "ConstrainedPhotometryModel cannot find CcdImage " + ccdImage.getName());
174  return idMapping->second.get();
175 }
T end(T... args)
T find(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ freezeErrorTransform()

void lsst::jointcal::ConstrainedPhotometryModel::freezeErrorTransform ( )
overridevirtual

Once this routine has been called, the error transform is not modified by offsetParams().

The routine can be called when the mappings are roughly in place. After the call, the transformations used to propagate errors are no longer affected when updating the mappings. This allows an exactly linear fit, which can be necessary for some model+data combinations.

Implements lsst::jointcal::PhotometryModel.

Definition at line 102 of file ConstrainedPhotometryModel.cc.

102  {
103  for (auto &idMapping : _chipMap) {
104  idMapping.second.get()->freezeErrorTransform();
105  }
106  for (auto &idMapping : _visitMap) {
107  idMapping.second.get()->freezeErrorTransform();
108  }
109 }

◆ getErrorPedestal()

double lsst::jointcal::PhotometryModel::getErrorPedestal ( )
inlineinherited

Definition at line 191 of file PhotometryModel.h.

◆ getMapping()

PhotometryMappingBase const& lsst::jointcal::PhotometryModel::getMapping ( CcdImage const &  ccdImage) const
inlineinherited

Get the mapping associated with ccdImage.

Definition at line 156 of file PhotometryModel.h.

156  {
157  return *(findMapping(ccdImage));
158  }
virtual PhotometryMappingBase * findMapping(CcdImage const &ccdImage) const =0
Return a pointer to the mapping associated with this ccdImage.

◆ getMappingIndices()

void lsst::jointcal::ConstrainedPhotometryModel::getMappingIndices ( CcdImage const &  ccdImage,
IndexVector indices 
) const
overridevirtual

Get how this set of parameters (of length Npar()) map into the "grand" fit.

Parameters
[in]ccdImageThe ccdImage to look up.
[out]indicesThe indices of the mapping associated with ccdImage.

Implements lsst::jointcal::PhotometryModel.

Definition at line 111 of file ConstrainedPhotometryModel.cc.

112  {
113  auto mapping = findMapping(ccdImage);
114  mapping->getMappingIndices(indices);
115 }
PhotometryMappingBase * findMapping(CcdImage const &ccdImage) const override
Return a pointer to the mapping associated with this ccdImage.

◆ getNpar()

std::size_t lsst::jointcal::PhotometryModel::getNpar ( CcdImage const &  ccdImage) const
inlineinherited

Return the number of parameters in the mapping of CcdImage.

Definition at line 153 of file PhotometryModel.h.

153 { return findMapping(ccdImage)->getNpar(); }
virtual std::size_t getNpar() const =0
Number of total parameters in this mapping.
virtual PhotometryMappingBase * findMapping(CcdImage const &ccdImage) const =0
Return a pointer to the mapping associated with this ccdImage.

◆ getRefError()

virtual double lsst::jointcal::PhotometryModel::getRefError ( RefStar const &  refStar) const
pure virtualinherited

Return the refStar error appropriate for this model (e.g. fluxErr or magErr).

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::SimpleMagnitudeModel, and lsst::jointcal::SimpleFluxModel.

◆ getTotalParameters()

std::size_t lsst::jointcal::ConstrainedPhotometryModel::getTotalParameters ( ) const
overridevirtual

Return the total number of parameters in this model.

Implements lsst::jointcal::PhotometryModel.

Definition at line 117 of file ConstrainedPhotometryModel.cc.

117  {
118  std::size_t total = 0;
119  for (auto &idMapping : _chipMap) {
120  total += idMapping.second->getNpar();
121  }
122  for (auto &idMapping : _visitMap) {
123  total += idMapping.second->getNpar();
124  }
125  return total;
126 }

◆ initialChipCalibration()

virtual double lsst::jointcal::ConstrainedPhotometryModel::initialChipCalibration ( std::shared_ptr< afw::image::PhotoCalib const >  photoCalib)
protectedpure virtual

Return the initial calibration to use from this photoCalib.

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, and lsst::jointcal::ConstrainedFluxModel.

◆ initialize()

template<class ChipTransform , class VisitTransform , class ChipVisitMapping >
template void lsst::jointcal::ConstrainedPhotometryModel::initialize< MagnitudeTransformSpatiallyInvariant, MagnitudeTransformChebyshev, ChipVisitMagnitudeMapping > ( CcdImageList const &  ccdImageList,
geom::Box2D const &  focalPlaneBBox,
int  visitOrder 
)
protected

Initialize the chip, visit, and chipVisit mappings by creating appropriate transforms and mappings.

Definition at line 178 of file ConstrainedPhotometryModel.cc.

179  {
180  // keep track of which chip we want to constrain (the one closest to the middle of the focal plane)
181  double minRadius2 = std::numeric_limits<double>::infinity();
182  CcdIdType constrainedChip = -1;
183 
184  // First initialize all visit and ccd transforms, before we make the ccdImage mappings.
185  for (auto const &ccdImage : ccdImageList) {
186  auto visit = ccdImage->getVisit();
187  auto chip = ccdImage->getCcdId();
188  auto visitPair = _visitMap.find(visit);
189  auto chipPair = _chipMap.find(chip);
190 
191  // If the chip is not in the map, add it, otherwise continue.
192  if (chipPair == _chipMap.end()) {
193  auto center = ccdImage->getDetector()->getCenter(afw::cameraGeom::FOCAL_PLANE);
194  double radius2 = std::pow(center.getX(), 2) + std::pow(center.getY(), 2);
195  if (radius2 < minRadius2) {
196  minRadius2 = radius2;
197  constrainedChip = chip;
198  }
199  auto photoCalib = ccdImage->getPhotoCalib();
200  // Use the single-frame processing calibration from the PhotoCalib as the default.
201  auto chipTransform = std::make_unique<ChipTransform>(initialChipCalibration(photoCalib));
202  _chipMap[chip] = std::make_shared<PhotometryMapping>(std::move(chipTransform));
203  }
204  // If the visit is not in the map, add it, otherwise continue.
205  if (visitPair == _visitMap.end()) {
206  auto visitTransform = std::make_unique<VisitTransform>(visitOrder, focalPlaneBBox);
207  _visitMap[visit] = std::make_shared<PhotometryMapping>(std::move(visitTransform));
208  }
209  }
210 
211  // Fix one chip mapping, to remove the degeneracy from the system.
212  _chipMap.at(constrainedChip)->setFixed(true);
213 
214  // Now create the ccdImage mappings, which are combinations of the chip/visit mappings above.
215  for (auto const &ccdImage : ccdImageList) {
216  auto visit = ccdImage->getVisit();
217  auto chip = ccdImage->getCcdId();
218  _chipVisitMap.emplace(ccdImage->getHashKey(),
219  std::make_unique<ChipVisitMapping>(_chipMap[chip], _visitMap[visit]));
220  }
221  LOGLS_INFO(_log, "Got " << _chipMap.size() << " chip mappings and " << _visitMap.size()
222  << " visit mappings; holding chip " << constrainedChip << " fixed ("
223  << getTotalParameters() << " total parameters).");
224  LOGLS_DEBUG(_log, "CcdImage map has " << _chipVisitMap.size() << " mappings, with "
225  << _chipVisitMap.bucket_count() << " buckets and a load factor of "
227 }
T bucket_count(T... args)
T end(T... args)
T load_factor(T... args)
std::size_t getTotalParameters() const override
Return the total number of parameters in this model.
T at(T... args)
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:608
T infinity(T... args)
T move(T... args)
#define LOGLS_INFO(logger, message)
Log a info-level message using an iostream-based interface.
Definition: Log.h:628
T find(T... args)
T size(T... args)
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...
T pow(T... args)
T emplace(T... args)
virtual double initialChipCalibration(std::shared_ptr< afw::image::PhotoCalib const > photoCalib)=0
Return the initial calibration to use from this photoCalib.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Position on a 2-d planar approximation to the focal plane (x...
Definition: CameraSys.cc:30

◆ offsetFittedStar()

virtual void lsst::jointcal::PhotometryModel::offsetFittedStar ( FittedStar fittedStar,
double  delta 
) const
pure virtualinherited

Offset the appropriate flux or magnitude (by -delta).

Parameters
fittedStarThe star to update.
deltaThe amount to update by.

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::SimpleMagnitudeModel, and lsst::jointcal::SimpleFluxModel.

◆ offsetParams()

void lsst::jointcal::ConstrainedPhotometryModel::offsetParams ( Eigen::VectorXd const &  delta)
overridevirtual

Offset the parameters by the provided amounts (by -delta).

The shifts are applied according to the indices given in assignIndices.

Parameters
[in]deltavector of offsets to apply

Implements lsst::jointcal::PhotometryModel.

Definition at line 85 of file ConstrainedPhotometryModel.cc.

85  {
86  if (_fittingChips) {
87  for (auto &idMapping : _chipMap) {
88  auto mapping = idMapping.second.get();
89  // Don't offset indices for fixed parameters.
90  if (mapping->isFixed()) continue;
91  mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
92  }
93  }
94  if (_fittingVisits) {
95  for (auto &idMapping : _visitMap) {
96  auto mapping = idMapping.second.get();
97  mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
98  }
99  }
100 }

◆ operator=() [1/2]

ConstrainedPhotometryModel& lsst::jointcal::ConstrainedPhotometryModel::operator= ( ConstrainedPhotometryModel const &  )
delete

◆ operator=() [2/2]

ConstrainedPhotometryModel& lsst::jointcal::ConstrainedPhotometryModel::operator= ( ConstrainedPhotometryModel &&  )
delete

◆ prepPhotoCalib()

ConstrainedPhotometryModel::PrepPhotoCalib lsst::jointcal::ConstrainedPhotometryModel::prepPhotoCalib ( CcdImage const &  ccdImage) const
protected

Helper for preparing toPhotoCalib()

Definition at line 229 of file ConstrainedPhotometryModel.cc.

230  {
231  auto detector = ccdImage.getDetector();
232  auto ccdBBox = detector->getBBox();
233  ChipVisitPhotometryMapping *mapping = dynamic_cast<ChipVisitPhotometryMapping *>(findMapping(ccdImage));
234 
235  // There should be no way in which we can get to this point and not have a ChipVisitMapping,
236  // so blow up if we don't.
237  assert(mapping != nullptr);
238  // We know it's a Chebyshev transform because we created it as such, so blow up if it's not.
239  auto visitPhotometryTransform = std::dynamic_pointer_cast<PhotometryTransformChebyshev>(
240  mapping->getVisitMapping()->getTransform());
241  assert(visitPhotometryTransform != nullptr);
242  auto focalBBox = visitPhotometryTransform->getBBox();
243 
244  // Unravel our chebyshev coefficients to build an astshim::ChebyMap.
245  auto coeff_f = toChebyMapCoeffs(std::dynamic_pointer_cast<PhotometryTransformChebyshev>(
246  mapping->getVisitMapping()->getTransform()));
247  // Bounds are the bbox
248  std::vector<double> lowerBound = {focalBBox.getMinX(), focalBBox.getMinY()};
249  std::vector<double> upperBound = {focalBBox.getMaxX(), focalBBox.getMaxY()};
250  afw::geom::TransformPoint2ToGeneric visitTransform(ast::ChebyMap(coeff_f, 1, lowerBound, upperBound));
251 
252  double chipConstant = mapping->getChipMapping()->getParameters()[0];
253 
254  // Compute a box that covers the area of the ccd in focal plane coordinates.
255  // This is the box over which we want to compute the mean of the visit transform.
256  auto pixToFocal = detector->getTransform(afw::cameraGeom::PIXELS, afw::cameraGeom::FOCAL_PLANE);
257  geom::Box2D ccdBBoxInFocal;
258  for (auto const &point : pixToFocal->applyForward(geom::Box2D(ccdBBox).getCorners())) {
259  ccdBBoxInFocal.include(point);
260  }
261  double visitMean = visitPhotometryTransform->mean(ccdBBoxInFocal);
262 
263  return {chipConstant, visitTransform, pixToFocal, visitMean};
264 }
std::vector< Point2D > getCorners() const
Get the corner points.
Definition: Box.cc:496
Transform< Point2Endpoint, GenericEndpoint > TransformPoint2ToGeneric
Definition: Transform.h:301
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
void include(Point2D const &point) noexcept
Expand this to ensure that this->contains(point).
Definition: Box.cc:380
CameraSysPrefix const PIXELS
Pixel coordinates: Nominal position on the entry surface of a given detector (x, y unbinned pixels)...
Definition: CameraSys.cc:34
PhotometryMappingBase * findMapping(CcdImage const &ccdImage) const override
Return a pointer to the mapping associated with this ccdImage.
table::Key< int > detector
T dynamic_pointer_cast(T... args)
A ChebyMap is a form of Mapping which performs a Chebyshev polynomial transformation.
Definition: ChebyMap.h:97
CameraSys const FOCAL_PLANE
Focal plane coordinates: Position on a 2-d planar approximation to the focal plane (x...
Definition: CameraSys.cc:30

◆ toPhotoCalib()

virtual std::shared_ptr<afw::image::PhotoCalib> lsst::jointcal::PhotometryModel::toPhotoCalib ( CcdImage const &  ccdImage) const
pure virtualinherited

◆ transform()

virtual double lsst::jointcal::PhotometryModel::transform ( CcdImage const &  ccdImage,
MeasuredStar const &  measuredStar 
) const
pure virtualinherited

Return the on-sky transformed flux for measuredStar on ccdImage.

Parameters
[in]ccdImageThe ccdImage where measuredStar resides.
measuredStarThe measured star position to transform.
Returns
The on-sky flux transformed from instFlux at measuredStar's position.

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::SimpleMagnitudeModel, and lsst::jointcal::SimpleFluxModel.

◆ transformError()

virtual double lsst::jointcal::PhotometryModel::transformError ( CcdImage const &  ccdImage,
MeasuredStar const &  measuredStar 
) const
pure virtualinherited

Return the on-sky transformed flux uncertainty for measuredStar on ccdImage.

Identical to transform() until freezeErrorTransform() is called.

Parameters
[in]ccdImageThe ccdImage where measuredStar resides.
measuredStarThe measured star position to transform.
Returns
The on-sky flux transformed from instFlux at measuredStar's position.

Implemented in lsst::jointcal::ConstrainedMagnitudeModel, lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::SimpleMagnitudeModel, and lsst::jointcal::SimpleFluxModel.

◆ tweakFluxError()

double lsst::jointcal::PhotometryModel::tweakFluxError ( jointcal::MeasuredStar const &  measuredStar) const
inlineinherited

Add a fraction of the instrumental flux to the instrumental flux error, in quadrature.

Definition at line 194 of file PhotometryModel.h.

194  {
195  if (errorPedestal == 0) {
196  return measuredStar.getInstFluxErr();
197  } else {
198  return std::hypot(measuredStar.getInstFluxErr(), measuredStar.getInstFlux() * errorPedestal);
199  }
200  }
T hypot(T... args)

◆ tweakMagnitudeError()

double lsst::jointcal::PhotometryModel::tweakMagnitudeError ( jointcal::MeasuredStar const &  measuredStar) const
inlineinherited

Add a small magnitude offset to the "instrumental magnitude" error, in quadrature.

Definition at line 203 of file PhotometryModel.h.

203  {
204  if (errorPedestal == 0) {
205  return measuredStar.getInstMagErr();
206  } else {
207  return std::hypot(measuredStar.getInstMagErr(), errorPedestal);
208  }
209  }
T hypot(T... args)

◆ validate()

bool lsst::jointcal::PhotometryModel::validate ( CcdImageList const &  ccdImageList,
int  ndof 
) const
inherited

Return true if this is a "reasonable" model.

A valid photometry model is positive within each sensor's bounding box.

Parameters
ccdImageListThe ccdImages to test the model validity on.
ndofThe number of degrees of freedom in the fit, e.g. from Fitterbase.computeChi2().
Returns
True if the model is valid on all ccdImages.

Definition at line 33 of file PhotometryModel.cc.

33  {
34  bool check = true;
35  for (auto const &ccdImage : ccdImageList) {
36  // Don't short circuit so that we log every place the model is negative.
37  check &= checkPositiveOnBBox(*ccdImage);
38  }
39  if (ndof < 0) {
40  check &= false;
41  LOGLS_ERROR(_log, "This model only has "
42  << ndof << " degrees of freedom, with " << getTotalParameters()
43  << " total parameters. Reduce the model complexity (e.g. polynomial order)"
44  " to better match the number of measured sources.");
45  }
46  return check;
47 }
bool checkPositiveOnBBox(CcdImage const &ccdImage) const
Check that the model is positive on the ccdImage bbox.
virtual std::size_t getTotalParameters() const =0
Return the total number of parameters in this model.
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...
#define LOGLS_ERROR(logger, message)
Log a error-level message using an iostream-based interface.
Definition: Log.h:668

Member Data Documentation

◆ _chipMap

ChipMapType lsst::jointcal::ConstrainedPhotometryModel::_chipMap
protected

Definition at line 110 of file ConstrainedPhotometryModel.h.

◆ _chipVisitMap

MapType lsst::jointcal::ConstrainedPhotometryModel::_chipVisitMap
protected

Definition at line 103 of file ConstrainedPhotometryModel.h.

◆ _log

LOG_LOGGER lsst::jointcal::PhotometryModel::_log
protectedinherited

lsst.logging instance, to be created by a subclass so that messages have consistent name.

Definition at line 216 of file PhotometryModel.h.

◆ _visitMap

VisitMapType lsst::jointcal::ConstrainedPhotometryModel::_visitMap
protected

Definition at line 107 of file ConstrainedPhotometryModel.h.

◆ errorPedestal

double lsst::jointcal::PhotometryModel::errorPedestal
protectedinherited

Definition at line 219 of file PhotometryModel.h.


The documentation for this class was generated from the following files: