casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes
casa::ProfileFit1D< T > Class Template Reference

Fit spectral components to a Vector of data. More...

#include <ProfileFit1D.h>

List of all members.

Public Member Functions

 ProfileFit1D ()
 Constructor.
 ~ProfileFit1D ()
 Destructor.
 ProfileFit1D (const ProfileFit1D &other)
 Copy constructor.
ProfileFit1Doperator= (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< BoolgetDataMask () const
 Recover masks.
Vector< BoolgetRangeMask () const
Vector< BoolgetTotalMask () 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 SpectralListgetList (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< BoolmakeTotalMask () const
 Functions.
SpectralList getSubsetList (const SpectralList &list, Int which) const
void checkType () const
void copy (const ProfileFit1D< T > &other)

Private Attributes

Vector< DoubleitsX
Vector< T > itsY
Vector< DoubleitsWeight
Vector< BoolitsDataMask
Vector< BoolitsRangeMask
SpectralList itsList
SpectralFit itsFitter
String itsError

Detailed Description

template<class T>
class casa::ProfileFit1D< T >

Fit spectral components to a Vector of data.

Intended use:

Public interface

Review Status

Test programs:
tProfileFit1D

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;

Definition at line 101 of file ProfileFit1D.h.


Constructor & Destructor Documentation

template<class T>
casa::ProfileFit1D< T >::ProfileFit1D ( )

Constructor.

template<class T>
casa::ProfileFit1D< T >::~ProfileFit1D ( )

Destructor.

template<class T>
casa::ProfileFit1D< T >::ProfileFit1D ( const ProfileFit1D< T > &  other)

Copy constructor.

Uses copy semantics.


Member Function Documentation

template<class T>
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().

template<class T>
void casa::ProfileFit1D< T >::addElements ( const SpectralList list)
template<class T>
void casa::ProfileFit1D< T >::checkType ( ) const [private]
template<class T>
void casa::ProfileFit1D< T >::clearList ( )

Clear the SpectralList of elements to be fit for.

Referenced by casa::ImageFit1D< Float >::clearList().

template<class T>
void casa::ProfileFit1D< T >::copy ( const ProfileFit1D< T > &  other) [private]
template<class T>
String casa::ProfileFit1D< T >::errorMessage ( ) const [inline]

Recover the error message.

Definition at line 213 of file ProfileFit1D.h.

template<class T>
Bool casa::ProfileFit1D< T >::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.

template<class T>
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().

template<class T>
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.

template<class T>
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.

template<class T>
Vector<T> casa::ProfileFit1D< T >::getFit ( Int  which = -1) const
template<class T>
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().

template<class T>
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().

template<class T>
Vector<Bool> casa::ProfileFit1D< T >::getRangeMask ( ) const [inline]

Definition at line 180 of file ProfileFit1D.h.

template<class T>
Vector<T> casa::ProfileFit1D< T >::getResidual ( Int  which = -1,
Bool  fit = True 
) const
template<class T>
SpectralList casa::ProfileFit1D< T >::getSubsetList ( const SpectralList list,
Int  which 
) const [private]
template<class T>
Vector<Bool> casa::ProfileFit1D< T >::getTotalMask ( ) const [inline]

Definition at line 181 of file ProfileFit1D.h.

Referenced by casa::ImageFit1D< Float >::getTotalMask().

template<class T>
Vector<Bool> casa::ProfileFit1D< T >::makeTotalMask ( ) const [private]
template<class T>
ProfileFit1D& casa::ProfileFit1D< T >::operator= ( const ProfileFit1D< T > &  other)

Assignment operator.

Uses copy semantics.

template<class T>
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

template<class T>
Bool casa::ProfileFit1D< T >::setData ( const Vector< Double > &  x,
const Vector< T > &  y,
const Vector< Bool > &  mask 
)
template<class T>
Bool casa::ProfileFit1D< T >::setData ( const Vector< Double > &  x,
const Vector< T > &  y 
)
template<class T>
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().

template<class T>
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

template<class T>
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

template<class T>
Bool casa::ProfileFit1D< T >::setRangeMask ( const Vector< T > &  startIndex,
const Vector< T > &  endIndex,
Bool  insideIsGood = True 
)

Member Data Documentation

template<class T>
Vector<Bool> casa::ProfileFit1D< T >::itsDataMask [private]

Definition at line 219 of file ProfileFit1D.h.

Referenced by casa::ProfileFit1D< FitterType >::getDataMask().

template<class T>
String casa::ProfileFit1D< T >::itsError [mutable, private]

Definition at line 225 of file ProfileFit1D.h.

template<class T>
SpectralFit casa::ProfileFit1D< T >::itsFitter [private]
template<class T>
SpectralList casa::ProfileFit1D< T >::itsList [private]

Definition at line 222 of file ProfileFit1D.h.

template<class T>
Vector<Bool> casa::ProfileFit1D< T >::itsRangeMask [private]

Definition at line 220 of file ProfileFit1D.h.

Referenced by casa::ProfileFit1D< FitterType >::getRangeMask().

template<class T>
Vector<Double> casa::ProfileFit1D< T >::itsWeight [private]

Definition at line 218 of file ProfileFit1D.h.

template<class T>
Vector<Double> casa::ProfileFit1D< T >::itsX [private]

Definition at line 213 of file ProfileFit1D.h.

template<class T>
Vector<T> casa::ProfileFit1D< T >::itsY [private]

Definition at line 217 of file ProfileFit1D.h.


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