Class that handles the photometric least squares problem.
More...
#include <PhotometryFit.h>
Class that handles the photometric least squares problem.
Definition at line 46 of file PhotometryFit.h.
◆ PhotometryFit() [1/3]
Construct a photometry fitter.
- Parameters
-
associations | The associations catalog to use in the fitter. |
photometryModel | The model to build the fitter for. |
Definition at line 54 of file PhotometryFit.h.
◆ PhotometryFit() [2/3]
lsst::jointcal::PhotometryFit::PhotometryFit |
( |
PhotometryFit const & |
| ) |
|
|
delete |
No copy or move: there is only ever one fitter of a given type.
◆ PhotometryFit() [3/3]
lsst::jointcal::PhotometryFit::PhotometryFit |
( |
PhotometryFit && |
| ) |
|
|
delete |
◆ assignIndices()
void lsst::jointcal::PhotometryFit::assignIndices |
( |
std::string const & |
whatToFit | ) |
|
|
overridevirtual |
Set parameters to fit and assign indices in the big matrix.
- Parameters
-
[in] | whatToFit | Valid strings : "Model", "Fluxes", which define which parameter sets are going to be fitted. whatToFit="Model Fluxes" will set both parameter sets variable when computing derivatives. Provided it contains "Model", whatToFit is passed over to the PhotometryModel, and can hence be used to control more finely which subsets of the photometric model are being fitted, if the the actual PhotometryModel implements such a possibility. |
Implements lsst::jointcal::FitterBase.
Definition at line 185 of file PhotometryFit.cc.
◆ computeChi2()
Returns the chi2 for the current state.
Definition at line 42 of file FitterBase.cc.
◆ findOutliers()
Find Measurements and references contributing more than a cut, computed as.
\[
<chi2> + nSigmaCut + rms(chi2).
\]
The outliers are NOT removed, and no refit is done.
After returning from here, there are still measurements that contribute above the cut, but their contribution should be evaluated after a refit before discarding them.
- Parameters
-
[in] | nSigmaCut | Number of sigma to select on. |
[out] | msOutliers | list of MeasuredStar outliers to populate |
[out] | fsOutliers | list of FittedStar outliers to populate |
[out] | cut | value of chi2 that defines which objects are outliers |
- Returns
- Total number of outliers that were removed.
Definition at line 52 of file FitterBase.cc.
◆ getModel()
◆ leastSquareDerivatives()
void lsst::jointcal::FitterBase::leastSquareDerivatives |
( |
TripletList & |
tripletList, |
|
|
Eigen::VectorXd & |
grad |
|
) |
| const |
|
inherited |
Evaluates the chI^2 derivatives (Jacobian and gradient) for the current whatToFit setting.
The Jacobian is given as triplets in a sparse matrix, the gradient as a dense vector. The parameters which vary, and their indices, are to be set using assignIndices.
- Parameters
-
tripletList | tripletList of (row,col,value) representing the Jacobian of the chi2. |
grad | The gradient of the chi2. |
Definition at line 346 of file FitterBase.cc.
◆ minimize()
MinimizeResult lsst::jointcal::FitterBase::minimize |
( |
std::string const & |
whatToFit, |
|
|
double |
nSigmaCut = 0 , |
|
|
double |
sigmaRelativeTolerance = 0 , |
|
|
bool |
doRankUpdate = true , |
|
|
bool |
doLineSearch = false , |
|
|
std::string const & |
dumpMatrixFile = "" |
|
) |
| |
|
inherited |
Does a 1 step minimization, assuming a linear model.
This is a complete Newton Raphson step. Compute first and second derivatives, solve for the step and apply it, with an optional line search.
It calls assignIndices, leastSquareDerivatives, solves the linear system and calls offsetParams, then removes outliers in a loop if requested. Relies on sparse linear algebra via Eigen's CholmodSupport package.
- Parameters
-
[in] | whatToFit | See child method assignIndices for valid string values. |
[in] | nSigmaCut | How many sigma to reject outliers at. Outlier rejection ignored for nSigmaCut=0. |
[in] | sigmaRelativeTolerance | Percentage change in the chi2 cut for outliers tolerated for termination. If value is zero, minimization iterations will continue until there are no outliers. |
[in] | doRankUpdate | Use CholmodSimplicialLDLT2.update() to do a fast rank update after outlier removal; otherwise do a slower full recomputation of the matrix. Only matters if nSigmaCut != 0. |
[in] | doLineSearch | Use boost's brent_find_minima to perform a line search after the gradient solution is found, and apply the scale factor to the computed offsets. The line search is done in the domain [-1, 2], but if the scale factor is far from 1.0, then the problem is likely in a significantly non-linear regime. |
[in] | dumpMatrixFile | Write the pre-fit Hessian matrix and gradient to the files with "-mat.txt" and "-grad.txt". Be aware, this requires a large increase in memory usage to create a dense matrix before writing it; the output file may be large. Writing the matrix can be helpful for debugging bad fits. Read it and compute the real eigenvalues (recall that the Hessian is symmetric by construction) with numpy: hessian = np.matrix(np.loadtxt("dumpMatrixFile-mat.txt"))
values, vectors = np.linalg.eigh(hessian)
|
- Returns
- Return code describing success/failure of fit.
- Note
- When fitting one parameter set by itself (e.g. "Model"), the system is purely linear (assuming there are no cross-terms in the derivatives, e.g. the SimpleAstrometryModel), which should result in the optimal chi2 after a single step. This can be used to debug the fitter by fitting that parameter set twice in a row: the second run with the same "whatToFit" will produce no change in the fitted parameters, if the calculations and indices are defined correctly.
Definition at line 178 of file FitterBase.cc.
◆ offsetParams()
void lsst::jointcal::PhotometryFit::offsetParams |
( |
Eigen::VectorXd const & |
delta | ) |
|
|
overridevirtual |
Offset the parameters by the requested quantities.
The used parameter layout is the one from the last call to assignIndices or minimize(). There is no easy way to check that the current setting of whatToFit and the provided Delta vector are compatible: we can only test the size.
- Parameters
-
[in] | delta | vector of offsets to apply |
Implements lsst::jointcal::FitterBase.
Definition at line 211 of file PhotometryFit.cc.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ outliersContributions()
Contributions to derivatives from (presumably) outlier terms.
No discarding done.
Definition at line 321 of file FitterBase.cc.
◆ removeMeasOutliers()
void lsst::jointcal::FitterBase::removeMeasOutliers |
( |
MeasuredStarList & |
outliers | ) |
|
|
protectedinherited |
Remove measuredStar outliers from the fit. No Refit done.
Definition at line 332 of file FitterBase.cc.
◆ removeRefOutliers()
void lsst::jointcal::FitterBase::removeRefOutliers |
( |
FittedStarList & |
outliers | ) |
|
|
protectedinherited |
Remove refStar outliers from the fit. No Refit done.
Definition at line 340 of file FitterBase.cc.
◆ saveChi2Contributions()
void lsst::jointcal::FitterBase::saveChi2Contributions |
( |
std::string const & |
baseName | ) |
const |
|
virtualinherited |
Save the full chi2 term per star that was used in the minimization, for debugging.
Saves results to text files "baseName-meas.csv" and "baseName-ref.csv" for the MeasuredStar and RefStar contributions, respectively. This method is mostly useful for debugging: we will probably want to create a better persistence system for jointcal's internal representations in the future (see DM-12446).
Definition at line 354 of file FitterBase.cc.
◆ saveChi2MeasContributions()
void lsst::jointcal::PhotometryFit::saveChi2MeasContributions |
( |
std::string const & |
filename | ) |
const |
|
overrideprotectedvirtual |
◆ saveChi2RefContributions()
void lsst::jointcal::PhotometryFit::saveChi2RefContributions |
( |
std::string const & |
filename | ) |
const |
|
overrideprotectedvirtual |
◆ _associations
◆ _lastNTrip
Eigen::Index lsst::jointcal::FitterBase::_lastNTrip |
|
protectedinherited |
◆ _log
LOG_LOGGER lsst::jointcal::FitterBase::_log |
|
protectedinherited |
◆ _nModelParams
Eigen::Index lsst::jointcal::FitterBase::_nModelParams |
|
protectedinherited |
◆ _nStarParams
Eigen::Index lsst::jointcal::FitterBase::_nStarParams |
|
protectedinherited |
◆ _nTotal
Eigen::Index lsst::jointcal::FitterBase::_nTotal |
|
protectedinherited |
◆ _whatToFit
The documentation for this class was generated from the following files: