ProfileFit1D.h

Classes

ProfileFit1D -- Fit spectral components to a Vector of data (full description)

template <class T> class ProfileFit1D

Interface

Public Members
ProfileFit1D()
~ProfileFit1D()
ProfileFit1D(const ProfileFit1D& other)
ProfileFit1D& operator=(const ProfileFit1D& other)
Bool setData (const Vector<Double>& x, const Vector<T>& y, const Vector<Bool>& mask, const Vector<Double>& weight)
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)
Bool setGaussianElements (uInt nGauss)
void addElement (const SpectralElement& el)
void addElements (const SpectralList& list)
void clearList ()
Bool setRangeMask (const Vector<uInt>& startIndex, const Vector<uInt>& endIndex, Bool insideIsGood=True)
Bool setRangeMask (const Vector<T>& startIndex, const Vector<T>& endIndex, Bool insideIsGood=True)
Vector<Bool> getDataMask() const
Vector<Bool> getRangeMask() const
Vector<Bool> getTotalMask() const
Bool fit ()
Double getChiSquared () const
Double getNumberIterations () const
const SpectralList& getList (Bool fit=True) const
Vector<T> getEstimate (Int which=-1) const
Vector<T> getFit (Int which=-1) const
Vector<T> getResidual (Int which=-1, Bool fit=True) const
String errorMessage () const
Private Members
Vector<Bool> makeTotalMask() const
SpectralList getSubsetList (const SpectralList& list, Int which) const
void checkType() const
void copy(const ProfileFit1D<T>& other)

Description

Review Status

Programs:
Tests:

Prerequisite

Synopsis

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.

Example

    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);
    

To Do

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.

Member Description

ProfileFit1D()

Constructor

~ProfileFit1D()

Destructor

ProfileFit1D(const ProfileFit1D& other)

Copy constructor. Uses copy semantics.

ProfileFit1D& operator=(const ProfileFit1D& other)

Assignment operator. Uses copy semantics.

Bool setData (const Vector<Double>& x, const Vector<T>& y, const Vector<Bool>& mask, const Vector<Double>& weight)
Bool setData (const Vector<Double>& x, const Vector<T>& y, const Vector<Bool>& mask)
Bool setData (const Vector<Double>& x, const Vector<T>& y)

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

void 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.

Bool 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

void addElement (const SpectralElement& el)
void addElements (const SpectralList& list)

Add new SpectralElement(s) to the SpectralList (can be empty) of SpectralElements to be fit for.

void clearList ()

Clear the SpectralList of elements to be fit for

Bool setRangeMask (const Vector<uInt>& startIndex, const Vector<uInt>& endIndex, Bool insideIsGood=True)
Bool setRangeMask (const Vector<T>& startIndex, const Vector<T>& 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

Vector<Bool> getDataMask() const
Vector<Bool> getRangeMask() const
Vector<Bool> getTotalMask() const

Recover masks. These are the data mask (setData) the range mask (setRangeMask may be length zero) and the total mask combining the two.

Bool fit ()

Do the fit and return status. Returns convergence status. Error conditions in the solution process will generate an AipsError exception and you should catch these yourself.

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. 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.

Vector<T> getEstimate (Int which=-1) const
Vector<T> getFit (Int which=-1) const
Vector<T> getResidual (Int which=-1, Bool fit=True) 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.

String errorMessage () const

Recover the error message

Vector<Bool> makeTotalMask() const

Error message

Functions

SpectralList getSubsetList (const SpectralList& list, Int which) const

void checkType() const

void copy(const ProfileFit1D<T>& other)