casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
casa::ProfileFit1D< T > Class Template Reference

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

#include <ProfileFit1D.h>

Public Member Functions

 ProfileFit1D ()
 Constructor. More...
 
 ~ProfileFit1D ()
 Destructor. More...
 
 ProfileFit1D (const ProfileFit1D &other)
 Copy constructor. More...
 
ProfileFit1Doperator= (const ProfileFit1D &other)
 Assignment operator. More...
 
casacore::Bool setData (const casacore::Vector< casacore::Double > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, const casacore::Vector< casacore::Double > &weight)
 Set abcissa, ordinate, mask and weights. More...
 
casacore::Bool setData (const casacore::Vector< casacore::Double > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask)
 
casacore::Bool setData (const casacore::Vector< casacore::Double > &x, const casacore::Vector< T > &y)
 
void setElements (const SpectralList &list)
 Set a SpectralList of SpectralElements to fit for. More...
 
casacore::Bool setGaussianElements (casacore::uInt nGauss)
 Set a SpectralList of Gaussian SpectralElements to fit for. More...
 
void addElement (const SpectralElement &el)
 Add new SpectralElement(s) to the SpectralList (can be empty) of SpectralElements to be fit for. More...
 
void addElements (const SpectralList &list)
 
void clearList ()
 Clear the SpectralList of elements to be fit for. More...
 
casacore::Bool setXRangeMask (const casacore::Vector< casacore::uInt > &startIndex, const casacore::Vector< casacore::uInt > &endIndex, casacore::Bool insideIsGood=true)
 Set abscissa range mask. More...
 
casacore::Bool setXRangeMask (const casacore::Vector< T > &startIndex, const casacore::Vector< T > &endIndex, casacore::Bool insideIsGood=true)
 
casacore::Bool setXMask (const std::set< casacore::uInt > &indices, casacore::Bool specifiedPixelsAreGood)
 
casacore::Vector< casacore::BoolgetDataMask () const
 Recover masks. More...
 
casacore::Vector< casacore::BoolgetRangeMask () const
 
casacore::Vector< casacore::BoolgetTotalMask () const
 
casacore::Bool fit ()
 Do the fit and return status. More...
 
casacore::Double getChiSquared () const
 Get Chi Squared of fit. More...
 
casacore::Double getNumberIterations () const
 Get number of iterations for last fit. More...
 
const SpectralListgetList (casacore::Bool fit=true) const
 Recover the list of elements. More...
 
casacore::Vector< T > getEstimate (casacore::Int which=-1) const
 Recover vectors for the estimate, fit and residual. More...
 
casacore::Vector< T > getFit (casacore::Int which=-1) const
 
casacore::Vector< T > getResidual (casacore::Int which=-1, casacore::Bool fit=true) const
 
casacore::String errorMessage () const
 Recover the error message. More...
 

Private Member Functions

casacore::Vector< casacore::BoolmakeTotalMask () const
 Functions. More...
 
SpectralList getSubsetList (const SpectralList &list, casacore::Int which) const
 
void checkType () const
 
void copy (const ProfileFit1D< T > &other)
 

Private Attributes

casacore::Vector
< casacore::Double
itsX
 
casacore::Vector< T > itsY
 
casacore::Vector
< casacore::Double
itsWeight
 
casacore::Vector< casacore::BoolitsDataMask
 
casacore::Vector< casacore::BoolitsRangeMask
 
SpectralList itsList
 
SpectralFit itsFitter
 
casacore::String itsError
 

Detailed Description

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

Fit spectral components to a casacore::Vector of data.

Intended use:

Public interface

Review Status

Test programs:
tProfileFit1D

Prerequisite

Synopsis

Fit lists (held in class SpectralList) of SpectralElements to a casacore::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 casacore::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 casacore::uInt n = 512;
// Code to fill data vectors x,y,m
ProfileFit1D<casacore::Float> fitter;
casacore::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 103 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< T >::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< T >::clearList().

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

Recover the error message.

Definition at line 220 of file ProfileFit1D.h.

template<class T>
casacore::Bool casa::ProfileFit1D< T >::fit ( )

Do the fit and return status.

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

template<class T>
casacore::Double casa::ProfileFit1D< T >::getChiSquared ( ) const
inline

Get Chi Squared of fit.

Definition at line 197 of file ProfileFit1D.h.

Referenced by casa::SpectralFitter::getChiSquared(), and casa::ImageFit1D< T >::getChiSquared().

template<class T>
casacore::Vector<casacore::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 186 of file ProfileFit1D.h.

Referenced by casa::ImageFit1D< T >::getDataMask().

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

template<class T>
casacore::Double casa::ProfileFit1D< T >::getNumberIterations ( ) const
inline

Get number of iterations for last fit.

Definition at line 200 of file ProfileFit1D.h.

Referenced by casa::SpectralFitter::getNumberIterations(), and casa::ImageFit1D< T >::getNumberIterations().

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

Definition at line 187 of file ProfileFit1D.h.

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

Definition at line 188 of file ProfileFit1D.h.

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

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

template<class T>
casacore::Bool casa::ProfileFit1D< T >::setGaussianElements ( casacore::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>
casacore::Bool casa::ProfileFit1D< T >::setXMask ( const std::set< casacore::uInt > &  indices,
casacore::Bool  specifiedPixelsAreGood 
)
template<class T>
casacore::Bool casa::ProfileFit1D< T >::setXRangeMask ( const casacore::Vector< casacore::uInt > &  startIndex,
const casacore::Vector< casacore::uInt > &  endIndex,
casacore::Bool  insideIsGood = true 
)

Set abscissa 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 In the single set version, the values in the set indicate the pixels to set the mask for, ie no ranges, just specific pixels are to be provided. In this case, specified values which are greater than or equal to the number of pixels are tacitly ignored.

template<class T>
casacore::Bool casa::ProfileFit1D< T >::setXRangeMask ( const casacore::Vector< T > &  startIndex,
const casacore::Vector< T > &  endIndex,
casacore::Bool  insideIsGood = true 
)

Member Data Documentation

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

Definition at line 226 of file ProfileFit1D.h.

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

template<class T>
casacore::String casa::ProfileFit1D< T >::itsError
mutableprivate

Definition at line 232 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 229 of file ProfileFit1D.h.

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

Definition at line 227 of file ProfileFit1D.h.

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

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

Definition at line 225 of file ProfileFit1D.h.

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

Definition at line 220 of file ProfileFit1D.h.

template<class T>
casacore::Vector<T> casa::ProfileFit1D< T >::itsY
private

Definition at line 224 of file ProfileFit1D.h.


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