File ConstrainedPhotometryModel.h

namespace lsst

Class for a simple mapping implementing a generic AstrometryTransform.

Remove all non-astronomical counts from the Chunk Exposure’s pixels.

Forward declarations for lsst::utils::Cache

For details on the Cache class, see the Cache.h file.

It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.

A base class for image defects

Numeric constants used by the Integrate.h integrator routines.

Compute Image Statistics

Note

Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.

Note

The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.

namespace jointcal
class ConstrainedFluxModel : public lsst::jointcal::ConstrainedPhotometryModel

Public Functions

ConstrainedFluxModel(CcdImageList const &ccdImageList, geom::Box2D const &focalPlaneBBox, int visitOrder = 7, double errorPedestal_ = 0)
void offsetFittedStar(FittedStar &fittedStar, double delta) const

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

Parameters
  • fittedStar: The star to update.

  • delta: The amount to update by.

double computeResidual(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const

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

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

Return

The residual.

Parameters
  • ccdImage: The ccdImage where measuredStar resides.

  • measuredStar: The measured star position to compute the residual of.

double computeRefResidual(FittedStar const &fittedStar, RefStar const &refStar) const

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

double getRefError(RefStar const &refStar) const

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

double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const

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

Return

The on-sky flux transformed from instFlux at measuredStar’s position.

Parameters
  • [in] ccdImage: The ccdImage where measuredStar resides.

  • measuredStar: The measured star position to transform.

double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const

Return the on-sky transformed flux uncertainty for measuredStar on ccdImage. Identical to transform() until freezeErrorTransform() is called.

Return

The on-sky flux transformed from instFlux at measuredStar’s position.

Parameters
  • [in] ccdImage: The ccdImage where measuredStar resides.

  • measuredStar: The measured star position to transform.

std::shared_ptr<afw::image::PhotoCalib> toPhotoCalib(CcdImage const &ccdImage) const

Return the mapping of ccdImage represented as a PhotoCalib.

Protected Functions

double initialChipCalibration(std::shared_ptr<afw::image::PhotoCalib const> photoCalib)

Return the initial calibration to use from this photoCalib.

class ConstrainedMagnitudeModel : public lsst::jointcal::ConstrainedPhotometryModel

Public Functions

ConstrainedMagnitudeModel(CcdImageList const &ccdImageList, geom::Box2D const &focalPlaneBBox, int visitOrder = 7, double errorPedestal_ = 0)
void offsetFittedStar(FittedStar &fittedStar, double delta) const

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

Parameters
  • fittedStar: The star to update.

  • delta: The amount to update by.

double computeResidual(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const

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

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

Return

The residual.

Parameters
  • ccdImage: The ccdImage where measuredStar resides.

  • measuredStar: The measured star position to compute the residual of.

double computeRefResidual(FittedStar const &fittedStar, RefStar const &refStar) const

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

double getRefError(RefStar const &refStar) const

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

double transform(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const

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

Return

The on-sky flux transformed from instFlux at measuredStar’s position.

Parameters
  • [in] ccdImage: The ccdImage where measuredStar resides.

  • measuredStar: The measured star position to transform.

double transformError(CcdImage const &ccdImage, MeasuredStar const &measuredStar) const

Return the on-sky transformed flux uncertainty for measuredStar on ccdImage. Identical to transform() until freezeErrorTransform() is called.

Return

The on-sky flux transformed from instFlux at measuredStar’s position.

Parameters
  • [in] ccdImage: The ccdImage where measuredStar resides.

  • measuredStar: The measured star position to transform.

std::shared_ptr<afw::image::PhotoCalib> toPhotoCalib(CcdImage const &ccdImage) const

Return the mapping of ccdImage represented as a PhotoCalib.

Protected Functions

double initialChipCalibration(std::shared_ptr<afw::image::PhotoCalib const> photoCalib)

Return the initial calibration to use from this photoCalib.

class ConstrainedPhotometryModel : public lsst::jointcal::PhotometryModel
#include <ConstrainedPhotometryModel.h>

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

This model consists of the following components:

  • A spatially invariant zero point per CCD, constrained across all visits, \(M_CCD\).

  • A Chebyshev polynomial ( \(a_ij*T_i(x)*T_j(y)\) ) per visit, constrained across all CCDs, \(M_visit\).

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.

Subclassed by lsst::jointcal::ConstrainedFluxModel, lsst::jointcal::ConstrainedMagnitudeModel

Public Functions

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

Construct a constrained photometry model.

Parameters
  • ccdImageList: The list of CCDImages to construct the model for.

  • focalPlaneBBox: The bounding box of the camera’s focal plane, defining the domain of the visit polynomial.

  • [in] log: An lsst::log::Log instance to log messages to.

  • [in] visitOrder: The order of the visit polynomial.

  • [in] errorPedestal_: A pedestal in flux or magnitude to apply to all MeasuredStar flux errors.

ConstrainedPhotometryModel(ConstrainedPhotometryModel const&)

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

ConstrainedPhotometryModel(ConstrainedPhotometryModel&&)
ConstrainedPhotometryModel &operator=(ConstrainedPhotometryModel const&)
ConstrainedPhotometryModel &operator=(ConstrainedPhotometryModel&&)
Eigen::Index assignIndices(std::string const &whatToFit, Eigen::Index firstIndex)

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

Return

The highest assigned index.

Parameters
  • [in] whatToFit: String containing parameters to fit.

  • [in] firstIndex: Index to start assigning at.

void offsetParams(Eigen::VectorXd const &delta)

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

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

Parameters
  • [in] delta: vector of offsets to apply

void freezeErrorTransform()

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.

void getMappingIndices(CcdImage const &ccdImage, IndexVector &indices) const

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

Parameters
  • [in] ccdImage: The ccdImage to look up.

  • [out] indices: The indices of the mapping associated with ccdImage.

std::size_t getTotalParameters() const

Return the total number of parameters in this model.

void computeParameterDerivatives(MeasuredStar const &measuredStar, CcdImage const &ccdImage, Eigen::VectorXd &derivatives) const

Compute the parametric derivatives of this model.

Parameters
  • [in] measuredStar: The measured star with the position and flux to compute at.

  • [in] ccdImage: The ccdImage containing the measured star, to find the correct mapping.

  • [out] derivatives: The computed derivatives. Must be pre-allocated to the correct size.

void dump(std::ostream &stream = std::cout) const

Dump the contents of the transforms, for debugging.

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 Functions

PhotometryMappingBase *findMapping(CcdImage const &ccdImage) const

Return a pointer to the mapping associated with this ccdImage.

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.

virtual double initialChipCalibration(std::shared_ptr<afw::image::PhotoCalib const> photoCalib) = 0

Return the initial calibration to use from this photoCalib.

PrepPhotoCalib prepPhotoCalib(CcdImage const &ccdImage) const

Helper for preparing toPhotoCalib()

Protected Attributes

MapType _chipVisitMap
VisitMapType _visitMap
ChipMapType _chipMap

Private Members

bool _fittingChips
bool _fittingVisits
struct PrepPhotoCalib
#include <ConstrainedPhotometryModel.h>

To hold the return of prepPhotoCalib.

Public Members

double chipConstant
afw::geom::TransformPoint2ToGeneric visitTransform
std::shared_ptr<afw::geom::TransformPoint2ToPoint2> pixToFocal
double visitMean