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

Compute moments from a Gaussian fitted to a profile. More...

#include <MomentFit.h>

Inheritance diagram for casa::MomentFit< T >:
casa::MomentCalcBase< T > casacore::LineCollapser< T, T >

Public Member Functions

 MomentFit (MomentsBase< T > &iMom, casacore::LogIO &os, const casacore::uInt nLatticeOut)
 Constructor. More...
 
virtual ~MomentFit ()
 Destructor (does nothing). More...
 
virtual void process (T &out, casacore::Bool &outMask, const casacore::Vector< T > &in, const casacore::Vector< casacore::Bool > &inMask, const casacore::IPosition &pos)
 This function is not implemented and throws an exception. More...
 
virtual void multiProcess (casacore::Vector< T > &out, casacore::Vector< casacore::Bool > &outMask, const casacore::Vector< T > &in, const casacore::Vector< casacore::Bool > &inMask, const casacore::IPosition &pos)
 This function returns a vector of numbers from each input vector. More...
 
- Public Member Functions inherited from casa::MomentCalcBase< T >
virtual ~MomentCalcBase ()
 
virtual casacore::uInt nFailedFits () const
 Returns the number of failed fits if doing fitting. More...
 
- Public Member Functions inherited from casacore::LineCollapser< T, T >
virtual ~LineCollapser ()
 Destructor. More...
 
virtual Bool canHandleNullMask () const
 Can the process function in the derived class handle a null mask? If not, LatticeApply ensures that it'll always pass a filled mask vector, even if the lattice does not have a mask (in that case that mask contains all True values). More...
 

Private Attributes

MomentsBase< T > & iMom_p
 
casacore::LogIO os_p
 
stdDeviation_p
 
peakSNR_p
 
casacore::Bool doFit_p
 
casacore::Gaussian1D< T > gauss_p
 

Additional Inherited Members

- Public Types inherited from casa::MomentCalcBase< T >
using AccumType = typename casacore::NumericTraits< T >::PrecisionType
 
using DataIterator = typename casacore::Vector< T >::const_iterator
 
using MaskIterator = casacore::Vector< casacore::Bool >::const_iterator
 
- Protected Member Functions inherited from casa::MomentCalcBase< T >
void accumSums (typename casacore::NumericTraits< T >::PrecisionType &s0, typename casacore::NumericTraits< T >::PrecisionType &s0Sq, typename casacore::NumericTraits< T >::PrecisionType &s1, typename casacore::NumericTraits< T >::PrecisionType &s2, casacore::Int &iMin, casacore::Int &iMax, T &dMin, T &dMax, casacore::Int i, T datum, casacore::Double coord) const
 Accumulate statistical sums from a vector. More...
 
casacore::uInt allNoise (T &dMean, const casacore::Vector< T > &data, const casacore::Vector< casacore::Bool > &mask, T peakSNR, T stdDeviation) const
 Determine if the spectrum is pure noise. More...
 
void constructorCheck (casacore::Vector< T > &calcMoments, casacore::Vector< casacore::Bool > &calcMomentsMask, const casacore::Vector< casacore::Int > &selectMoments, casacore::uInt nLatticeOut) const
 Check validity of constructor inputs. More...
 
void costlyMoments (MomentsBase< T > &iMom, casacore::Bool &doMedianI, casacore::Bool &doMedianV, casacore::Bool &doAbsDev) const
 Find out from the selectMoments array whether we want to compute the more expensive moments. More...
 
void doCoordCalc (casacore::Bool &doCoordProfile, casacore::Bool &doCoordRandom, const MomentsBase< T > &iMom) const
 Return the casacore::Bool saying whether we need to compute coordinates or not for the requested moments. More...
 
casacore::Bool doFit (const MomentsBase< T > &iMom) const
 Return the casacore::Bool from the ImageMoments or MSMoments object saying whether we are going to fit Gaussians to the profiles or not. More...
 
casacore::Bool findNextDatum (casacore::uInt &iFound, const casacore::uInt &n, const casacore::Vector< casacore::Bool > &mask, const casacore::uInt &iStart, const casacore::Bool &findGood) const
 Find the next masked or unmasked point in a vector. More...
 
casacore::Bool fitGaussian (casacore::uInt &nFailed, T &peak, T &pos, T &width, T &level, const casacore::Vector< T > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, T peakGuess, T posGuess, T widthGuess, T levelGuess) const
 Fit a Gaussian to x and y arrays given guesses for the gaussian parameters. More...
 
casacore::Bool getAutoGaussianFit (casacore::uInt &nFailed, casacore::Vector< T > &gaussPars, const casacore::Vector< T > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, T peakSNR, T stdDeviation) const
 Automatically fit a Gaussian to a spectrum, including finding the starting guesses. More...
 
casacore::Bool getAutoGaussianGuess (T &peakGuess, T &posGuess, T &widthGuess, T &levelGuess, const casacore::Vector< T > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask) const
 Automatically work out a guess for the Gaussian parameters Returns false if all pixels masked. More...
 
casacore::Double getMomentCoord (const MomentsBase< T > &iMom, casacore::Vector< casacore::Double > &pixelIn, casacore::Vector< casacore::Double > &worldOut, casacore::Double momentPixel, casacore::Bool asVelocity=false) const
 Compute the world coordinate for the given moment axis pixel. More...
 
void lineSegments (casacore::uInt &nSeg, casacore::Vector< casacore::uInt > &start, casacore::Vector< casacore::uInt > &nPts, const casacore::Vector< casacore::Bool > &mask) const
 Examine a mask and determine how many segments of unmasked points it consists of. More...
 
casacore::IntmomentAxis (MomentsBase< T > &iMom) const
 Return the moment axis from the ImageMoments object. More...
 
casacore::String momentAxisName (const casacore::CoordinateSystem &, const MomentsBase< T > &iMom) const
 Return the name of the moment/profile axis. More...
 
T & peakSNR (MomentsBase< T > &iMom) const
 Return the peak SNR for determination of all noise spectra from the ImageMoments or MSMoments object. More...
 
void selectRange (casacore::Vector< T > &pixelRange, casacore::Bool &doInclude, casacore::Bool &doExlude, MomentsBase< T > &iMom) const
 Return the selected pixel intensity range from the ImageMoments or MSMoments object and the Bools describing whether it is inclusion or exclusion. More...
 
casacore::Vector< casacore::IntselectMoments (MomentsBase< T > &iMom) const
 The MomentCalculators compute a vector of all possible moments. More...
 
void setCalcMoments (const MomentsBase< T > &iMom, casacore::Vector< T > &calcMoments, casacore::Vector< casacore::Bool > &calcMomentsMask, casacore::Vector< casacore::Double > &pixelIn, casacore::Vector< casacore::Double > &worldOut, casacore::Bool doCoord, casacore::Double integratedScaleFactor, T dMedian, T vMedian, casacore::Int nPts, typename casacore::NumericTraits< T >::PrecisionType s0, typename casacore::NumericTraits< T >::PrecisionType s1, typename casacore::NumericTraits< T >::PrecisionType s2, typename casacore::NumericTraits< T >::PrecisionType s0Sq, typename casacore::NumericTraits< T >::PrecisionType sumAbsDev, T dMin, T dMax, casacore::Int iMin, casacore::Int iMax) const
 Fill the ouput moments array. More...
 
void setPosLabel (casacore::String &title, const casacore::IPosition &pos) const
 Fill a string with the position of the cursor. More...
 
void setCoordinateSystem (casacore::CoordinateSystem &cSys, MomentsBase< T > &iMom)
 Install casacore::CoordinateSystem and SpectralCoordinate in protected data members. More...
 
void setUpCoords (const MomentsBase< T > &iMom, casacore::Vector< casacore::Double > &pixelIn, casacore::Vector< casacore::Double > &worldOut, casacore::Vector< casacore::Double > &sepWorldCoord, casacore::LogIO &os, casacore::Double &integratedScaleFactor, const casacore::CoordinateSystem &cSys, casacore::Bool doCoordProfile, casacore::Bool doCoordRandom) const
 Set up separable moment axis coordinate vector and conversion vectors if not separable. More...
 
T & stdDeviation (MomentsBase< T > &iMom) const
 Return standard deviation of image from ImageMoments or MSMoments object. More...
 
virtual void init (casacore::uInt nOutPixelsPerCollapse)
 Check if #pixels is indeed 1. More...
 
- Protected Attributes inherited from casa::MomentCalcBase< T >
casacore::CoordinateSystem cSys_p
 A number of private data members are kept here in the base class as they are common to the derived classes. More...
 
casacore::Vector< T > calcMoments_p
 This vector is a container for all the possible moments that can be calculated. More...
 
casacore::Vector< casacore::BoolcalcMomentsMask_p
 
casacore::Vector< casacore::IntselectMoments_p
 This vector tells us which elements of the calcMoments_p vector we wish to select. More...
 
casacore::Bool doMedianI_p
 Although the general philosophy of these classes is to compute all the posisble moments and then select the ones we want, some of them are too expensive to calculate unless they are really wanted. More...
 
casacore::Bool doMedianV_p
 
casacore::Bool doAbsDev_p
 
casacore::Vector
< casacore::Double
pixelIn_p
 These vectors are used to transform coordinates between pixel and world. More...
 
casacore::Vector
< casacore::Double
worldOut_p
 
casacore::Bool doCoordProfile_p
 All computations involving casacore::Coordinate conversions are relatively expensive These Bools signifies whether we need coordinate calculations or not for the full profile, and for some occaisional calculations. More...
 
casacore::Bool doCoordRandom_p
 
casacore::Vector
< casacore::Double
sepWorldCoord_p
 This vector houses the world coordinate values for the profile if it was from a separable axis. More...
 
casacore::Vector< T > abcissa_p
 This vector is used to hold the abscissa values. More...
 
casacore::String momAxisType_p
 This string tells us the name of the moment axis (VELO or FREQ etc) More...
 
casacore::uInt nFailed_p
 This is the number of Gaussian fits that failed. More...
 
casacore::Double integratedScaleFactor_p
 This scale factor is the increment along the moment axis applied so that units for the Integrated moment are like Jy/beam.km/s (or whatever is needed for the moment axis units) For non-linear velocities (e.g. More...
 

Detailed Description

template<class T>
class casa::MomentFit< T >

Compute moments from a Gaussian fitted to a profile.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

This concrete class is derived from the abstract base class MomentCalcBase which provides an interface layer to the ImageMoments or MSMoments driver class. ImageMoments or MSMoments creates a MomentFit object and passes it to the LatticeApply function, lineMultiApply. This function iterates through a given lattice, and invokes the multiProcess member function of MomentFit on each vector of pixels that it extracts from the input lattice. The multiProcess function returns a vector of moments which are inserted into the output lattices also supplied to the casacore::LatticeApply function.

MomentFit computes moments by fitting a Gaussian to each profile. The moments are then computed from that fit. The fitting can be done either interactively or automatically.

The constructor takes MomentsBase object that is actually an ImageMoments or an MSMoments object; the one that is constructing the MomentFit object of course. There is much control information embodied in the state of the ImageMoments object. This information is extracted by the MomentCalcBase class and passed on to MomentFit for consumption.

See the MomentsBase, ImageMoments, and MSMoments for discussion about the moments that are available for computation.

Example

This example comes from ImageMoments. outPt is a pointer block holding pointers to the output lattices. os_P is a casacore::LogIO object.

// Construct desired moment calculator object. Use it polymorphically via
// a pointer to the base class.
MomentCalcBase<T>* pMomentCalculator = 0;
if (clipMethod || smoothClipMethod) {
pMomentCalculator = new MomentClip<T>(pSmoothedImage, *this, os_p, outPt.nelements());
} else if (windowMethod) {
pMomentCalculator = new MomentWindow<T>(pSmoothedImage, *this, os_p, outPt.nelements());
} else if (fitMethod) {
pMomentCalculator = new MomentFit<T>(*this, os_p, outPt.nelements());
}
// Iterate optimally through the image, compute the moments, fill the output lattices
casacore::LatticeApply<T>::lineMultiApply(outPt, *pInImage_p, *pMomentCalculator,
momentAxis_p, pProgressMeter);
delete pMomentCalculator;

Motivation


Tip: Note that there are is assignment operator or copy constructor; Do not use the ones the system would generate either;

Definition at line 123 of file MomentFit.h.

Constructor & Destructor Documentation

template<class T >
casa::MomentFit< T >::MomentFit ( MomentsBase< T > &  iMom,
casacore::LogIO os,
const casacore::uInt  nLatticeOut 
)

Constructor.

We need the ImageMoments or MSMoments object which is calling us, its logger, and the number of output lattices it has created.

template<class T >
virtual casa::MomentFit< T >::~MomentFit ( )
virtual

Destructor (does nothing).

Member Function Documentation

template<class T >
virtual void casa::MomentFit< T >::multiProcess ( casacore::Vector< T > &  out,
casacore::Vector< casacore::Bool > &  outMask,
const casacore::Vector< T > &  in,
const casacore::Vector< casacore::Bool > &  inMask,
const casacore::IPosition pos 
)
virtual

This function returns a vector of numbers from each input vector.

the output vector contains the moments known to the ImageMoments or MSMoments object passed into the constructor.

Implements casacore::LineCollapser< T, T >.

template<class T >
virtual void casa::MomentFit< T >::process ( T &  out,
casacore::Bool outMask,
const casacore::Vector< T > &  in,
const casacore::Vector< casacore::Bool > &  inMask,
const casacore::IPosition pos 
)
virtual

This function is not implemented and throws an exception.

Implements casacore::LineCollapser< T, T >.

Member Data Documentation

template<class T >
casacore::Bool casa::MomentFit< T >::doFit_p
private

Definition at line 156 of file MomentFit.h.

template<class T >
casacore::Gaussian1D<T> casa::MomentFit< T >::gauss_p
private

Definition at line 157 of file MomentFit.h.

template<class T >
MomentsBase<T>& casa::MomentFit< T >::iMom_p
private

Definition at line 153 of file MomentFit.h.

template<class T >
casacore::LogIO casa::MomentFit< T >::os_p
private

Definition at line 154 of file MomentFit.h.

template<class T >
T casa::MomentFit< T >::peakSNR_p
private

Definition at line 155 of file MomentFit.h.

template<class T >
T casa::MomentFit< T >::stdDeviation_p
private

Definition at line 155 of file MomentFit.h.


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