casa
$Rev:20696$
|
Fit spectral components to a Vector of data. More...
#include <ProfileFit1D.h>
Public Member Functions | |
ProfileFit1D () | |
Constructor. | |
~ProfileFit1D () | |
Destructor. | |
ProfileFit1D (const ProfileFit1D &other) | |
Copy constructor. | |
ProfileFit1D & | operator= (const ProfileFit1D &other) |
Assignment operator. | |
Bool | setData (const Vector< Double > &x, const Vector< T > &y, const Vector< Bool > &mask, const Vector< Double > &weight) |
Set abcissa, ordinate, mask and weights. | |
Bool | setData (const Vector< Double > &x, const Vector< T > &y, const Vector< Bool > &mask) |
Bool | setData (const Vector< Double > &x, const Vector< T > &y) |
void | setElements (const SpectralList &list) |
Set a SpectralList of SpectralElements to fit for. | |
Bool | setGaussianElements (uInt nGauss) |
Set a SpectralList of Gaussian SpectralElements to fit for. | |
void | addElement (const SpectralElement &el) |
Add new SpectralElement(s) to the SpectralList (can be empty) of SpectralElements to be fit for. | |
void | addElements (const SpectralList &list) |
void | clearList () |
Clear the SpectralList of elements to be fit for. | |
Bool | setRangeMask (const Vector< uInt > &startIndex, const Vector< uInt > &endIndex, Bool insideIsGood=True) |
Set range mask. | |
Bool | setRangeMask (const Vector< T > &startIndex, const Vector< T > &endIndex, Bool insideIsGood=True) |
Vector< Bool > | getDataMask () const |
Recover masks. | |
Vector< Bool > | getRangeMask () const |
Vector< Bool > | getTotalMask () const |
Bool | fit () |
Do the fit and return status. | |
Double | getChiSquared () const |
Get Chi Squared of fit. | |
Double | getNumberIterations () const |
Get number of iterations for last fit. | |
const SpectralList & | getList (Bool fit=True) const |
Recover the list of elements. | |
Vector< T > | getEstimate (Int which=-1) const |
Recover vectors for the estimate, fit and residual. | |
Vector< T > | getFit (Int which=-1) const |
Vector< T > | getResidual (Int which=-1, Bool fit=True) const |
String | errorMessage () const |
Recover the error message. | |
Private Member Functions | |
Vector< Bool > | makeTotalMask () const |
Functions. | |
SpectralList | getSubsetList (const SpectralList &list, Int which) const |
void | checkType () const |
void | copy (const ProfileFit1D< T > &other) |
Private Attributes | |
Vector< Double > | itsX |
Vector< T > | itsY |
Vector< Double > | itsWeight |
Vector< Bool > | itsDataMask |
Vector< Bool > | itsRangeMask |
SpectralList | itsList |
SpectralFit | itsFitter |
String | itsError |
Fit spectral components to a Vector of data.
Public interface
Fit lists (held in class SpectralList) of SpectralElements to a Vector of data. Each SpectralElement can be one from a variety of types. The values of the parameters for each SpectralElement provide the initial starting guesses for the fitting process. Also, a SpectralElement object holds a mask indicating whether a parameter should be held fixed or solved for. After the fitting is done, a new SpectralList holding SpectralElements with the fitted parameters is created.
For all the functions that return a status Bool, True is good. If False is returned, an error message can be recovered with function errorMessage
, You should not proceed if False is returned.
const uInt n = 512; Vector<Double> x(n); Vector<Double> y(n); Vector<Bool> m(n); // Code to fill data vectors x,y,m ProfileFit1D<Float> fitter; Bool ok = fitter.setData (x, y, m); ok = fitter.setGaussianElements (2); ok = fitter.fit(); const SpectralList& fitList = fitter.getList(True);
Caution: At the moment, because of templating limitations of the underlying fitting classes, you must use template type Double; This restriction will be lifted in the future;
Definition at line 101 of file ProfileFit1D.h.
casa::ProfileFit1D< T >::ProfileFit1D | ( | ) |
Constructor.
casa::ProfileFit1D< T >::~ProfileFit1D | ( | ) |
Destructor.
casa::ProfileFit1D< T >::ProfileFit1D | ( | const ProfileFit1D< T > & | other | ) |
Copy constructor.
Uses copy semantics.
void casa::ProfileFit1D< T >::addElement | ( | const SpectralElement & | el | ) |
Add new SpectralElement(s) to the SpectralList (can be empty) of SpectralElements to be fit for.
Referenced by casa::ImageFit1D< Float >::addElement().
void casa::ProfileFit1D< T >::addElements | ( | const SpectralList & | list | ) |
Referenced by casa::ImageFit1D< Float >::addElements().
void casa::ProfileFit1D< T >::checkType | ( | ) | const [private] |
void casa::ProfileFit1D< T >::clearList | ( | ) |
Clear the SpectralList of elements to be fit for.
Referenced by casa::ImageFit1D< Float >::clearList().
void casa::ProfileFit1D< T >::copy | ( | const ProfileFit1D< T > & | other | ) | [private] |
String casa::ProfileFit1D< T >::errorMessage | ( | ) | const [inline] |
Recover the error message.
Definition at line 213 of file ProfileFit1D.h.
Bool casa::ProfileFit1D< T >::fit | ( | ) |
Double casa::ProfileFit1D< T >::getChiSquared | ( | ) | const [inline] |
Get Chi Squared of fit.
Definition at line 190 of file ProfileFit1D.h.
Referenced by casa::SpectralFitter::getChiSquared(), and casa::ImageFit1D< Float >::getChiSquared().
Vector<Bool> casa::ProfileFit1D< T >::getDataMask | ( | ) | const [inline] |
Recover masks.
These are the data mask (setData) the range mask (setRangeMask may be length zero) and the total mask combining the two.
Definition at line 179 of file ProfileFit1D.h.
Vector<T> casa::ProfileFit1D< T >::getEstimate | ( | Int | which = -1 | ) | const |
Recover vectors for the estimate, fit and residual.
If you don't specify which element, all elements are included If the Vectors are returned with zero length, it means an error condition exists (e.g. asking for fit before you do one). In this case an error message can be recovered with function errorMessage
.
Vector<T> casa::ProfileFit1D< T >::getFit | ( | Int | which = -1 | ) | const |
Referenced by casa::SpectralFitter::getFit().
const SpectralList& casa::ProfileFit1D< T >::getList | ( | Bool | fit = True | ) | const |
Recover the list of elements.
You can get the elements as initially estimated (fit=False), or after fitting (fit=True). In the latter case, the SpectralElements hold the parameters and errors of the fit.
Referenced by casa::SpectralFitter::getList(), and casa::ImageFit1D< Float >::getList().
Double casa::ProfileFit1D< T >::getNumberIterations | ( | ) | const [inline] |
Get number of iterations for last fit.
Definition at line 193 of file ProfileFit1D.h.
Referenced by casa::SpectralFitter::getNumberIterations(), and casa::ImageFit1D< Float >::getNumberIterations().
Vector<Bool> casa::ProfileFit1D< T >::getRangeMask | ( | ) | const [inline] |
Definition at line 180 of file ProfileFit1D.h.
Vector<T> casa::ProfileFit1D< T >::getResidual | ( | Int | which = -1 , |
Bool | fit = True |
||
) | const |
Referenced by casa::SpectralFitter::getResidual().
SpectralList casa::ProfileFit1D< T >::getSubsetList | ( | const SpectralList & | list, |
Int | which | ||
) | const [private] |
Vector<Bool> casa::ProfileFit1D< T >::getTotalMask | ( | ) | const [inline] |
Definition at line 181 of file ProfileFit1D.h.
Referenced by casa::ImageFit1D< Float >::getTotalMask().
Vector<Bool> casa::ProfileFit1D< T >::makeTotalMask | ( | ) | const [private] |
Functions.
Referenced by casa::ProfileFit1D< FitterType >::getTotalMask().
ProfileFit1D& casa::ProfileFit1D< T >::operator= | ( | const ProfileFit1D< T > & | other | ) |
Assignment operator.
Uses copy semantics.
Bool casa::ProfileFit1D< T >::setData | ( | const Vector< Double > & | x, |
const Vector< T > & | y, | ||
const Vector< Bool > & | mask, | ||
const Vector< Double > & | weight | ||
) |
Set abcissa, ordinate, mask and weights.
A True mask value means the data are good. If you don't specify the weights vector, all weights are assumed to be unity. If you don't specify a mask it will be created as all good. Status is returned, if False, error message can be recovered with errorMessage
Bool casa::ProfileFit1D< T >::setData | ( | const Vector< Double > & | x, |
const Vector< T > & | y, | ||
const Vector< Bool > & | mask | ||
) |
Bool casa::ProfileFit1D< T >::setData | ( | const Vector< Double > & | x, |
const Vector< T > & | y | ||
) |
void casa::ProfileFit1D< T >::setElements | ( | const SpectralList & | list | ) |
Set a SpectralList of SpectralElements to fit for.
The SpectralElements in the list hold the initial estimates and must reflect the abcissa and ordinate units. They also contain the information about whether specific parameters are to be held fixed or allowed to vary in the fitting process. You can recover the list of elements with function getList.
Referenced by casa::ImageFit1D< Float >::setElements().
Bool casa::ProfileFit1D< T >::setGaussianElements | ( | uInt | nGauss | ) |
Set a SpectralList of Gaussian SpectralElements to fit for.
The initial estimates for the Gaussians will be automatically determined. All of the parameters created by this function will be solved for by default. You can recover the list of elements with function getList. Status is returned, if False, error message can be recovered with errorMessage
Bool casa::ProfileFit1D< T >::setRangeMask | ( | const Vector< uInt > & | startIndex, |
const Vector< uInt > & | endIndex, | ||
Bool | insideIsGood = True |
||
) |
Set range mask.
You can specify a number of ranges via a vector of start indices (or X values) and a vector of end indices (or X values). When argument insideIsGood is True, a mask will be created which will be True (good) inside the ranges and bad (False) outside of those ranges. When argument insideIsGood is False, the mask will be False (bad) inside the ranges and True (good) outside of those ranges. When the data are fit, a total mask is formed combining (via a logical AND) the data mask (setData) and this range mask. Status is returned, if False, error message can be recovered with errorMessage
Bool casa::ProfileFit1D< T >::setRangeMask | ( | const Vector< T > & | startIndex, |
const Vector< T > & | endIndex, | ||
Bool | insideIsGood = True |
||
) |
Vector<Bool> casa::ProfileFit1D< T >::itsDataMask [private] |
Definition at line 219 of file ProfileFit1D.h.
Referenced by casa::ProfileFit1D< FitterType >::getDataMask().
String casa::ProfileFit1D< T >::itsError [mutable, private] |
Definition at line 225 of file ProfileFit1D.h.
SpectralFit casa::ProfileFit1D< T >::itsFitter [private] |
Definition at line 224 of file ProfileFit1D.h.
Referenced by casa::ProfileFit1D< FitterType >::getChiSquared(), and casa::ProfileFit1D< FitterType >::getNumberIterations().
SpectralList casa::ProfileFit1D< T >::itsList [private] |
Definition at line 222 of file ProfileFit1D.h.
Vector<Bool> casa::ProfileFit1D< T >::itsRangeMask [private] |
Definition at line 220 of file ProfileFit1D.h.
Referenced by casa::ProfileFit1D< FitterType >::getRangeMask().
Vector<Double> casa::ProfileFit1D< T >::itsWeight [private] |
Definition at line 218 of file ProfileFit1D.h.
Vector<Double> casa::ProfileFit1D< T >::itsX [private] |
Definition at line 213 of file ProfileFit1D.h.
Vector<T> casa::ProfileFit1D< T >::itsY [private] |
Definition at line 217 of file ProfileFit1D.h.