casa::MomentCalcBase< T > Class Template Reference

Abstract base class for moment calculator classes. More...

#include <MomentCalcBase.h>

Inheritance diagram for casa::MomentCalcBase< T >:
casa::MomentClip< T > casa::MomentFit< T > casa::MomentWindow< T >

List of all members.

Public Member Functions

virtual ~MomentCalcBase ()
virtual uInt nFailedFits () const
 Returns the number of failed fits if doing fitting.

Protected Member Functions

void accumSums (typename NumericTraits< T >::PrecisionType &s0, typename NumericTraits< T >::PrecisionType &s0Sq, typename NumericTraits< T >::PrecisionType &s1, typename NumericTraits< T >::PrecisionType &s2, Int &iMin, Int &iMax, T &dMin, T &dMax, Int i, T datum, Double coord) const
 Accumulate statistical sums from a vector.
uInt allNoise (T &dMean, const Vector< T > &data, const Vector< Bool > &mask, T peakSNR, T stdDeviation) const
 Determine if the spectrum is pure noise.
void constructorCheck (Vector< T > &calcMoments, Vector< Bool > &calcMomentsMask, const Vector< Int > &selectMoments, uInt nLatticeOut) const
 Check validity of constructor inputs.
void costlyMoments (MomentsBase< T > &iMom, Bool &doMedianI, Bool &doMedianV, Bool &doAbsDev) const
 Find out from the selectMoments array whether we want to compute the more expensive moments.
void doCoordCalc (Bool &doCoordProfile, Bool &doCoordRandom, const MomentsBase< T > &iMom) const
 Return the Bool saying whether we need to compute coordinates or not for the requested moments.
Bool doFit (const MomentsBase< T > &iMom) const
 Return the Bool from the ImageMoments or MSMoments object saying whether we are going to fit Gaussians to the profiles or not.
Bool findNextDatum (uInt &iFound, const uInt &n, const Vector< Bool > &mask, const uInt &iStart, const Bool &findGood) const
 Find the next masked or unmasked point in a vector.
Bool fitGaussian (uInt &nFailed, T &peak, T &pos, T &width, T &level, const Vector< T > &x, const Vector< T > &y, const Vector< 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.
Bool getAutoGaussianFit (uInt &nFailed, Vector< T > &gaussPars, const Vector< T > &x, const Vector< T > &y, const Vector< Bool > &mask, T peakSNR, T stdDeviation) const
 Automatically fit a Gaussian to a spectrum, including finding the starting guesses.
Bool getAutoGaussianGuess (T &peakGuess, T &posGuess, T &widthGuess, T &levelGuess, const Vector< T > &x, const Vector< T > &y, const Vector< Bool > &mask) const
 Automatically work out a guess for the Gaussian parameters Returns False if all pixels masked.
Double getMomentCoord (const MomentsBase< T > &iMom, Vector< Double > &pixelIn, Vector< Double > &worldOut, Double momentPixel, Bool asVelocity=False) const
 Compute the world coordinate for the given moment axis pixel.
void lineSegments (uInt &nSeg, Vector< uInt > &start, Vector< uInt > &nPts, const Vector< Bool > &mask) const
 Examine a mask and determine how many segments of unmasked points it consists of.
Int & momentAxis (MomentsBase< T > &iMom) const
 Return the moment axis from the ImageMoments object.
String momentAxisName (const CoordinateSystem &, const MomentsBase< T > &iMom) const
 Return the name of the moment/profile axis.
T & peakSNR (MomentsBase< T > &iMom) const
 Return the peak SNR for determination of all noise spectra from the ImageMoments or MSMoments object.
void selectRange (Vector< T > &pixelRange, Bool &doInclude, 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.
Vector< Int > selectMoments (MomentsBase< T > &iMom) const
 The MomentCalculators compute a vector of all possible moments.
void setCalcMoments (const MomentsBase< T > &iMom, Vector< T > &calcMoments, Vector< Bool > &calcMomentsMask, Vector< Double > &pixelIn, Vector< Double > &worldOut, Bool doCoord, Double integratedScaleFactor, T dMedian, T vMedian, Int nPts, typename NumericTraits< T >::PrecisionType s0, typename NumericTraits< T >::PrecisionType s1, typename NumericTraits< T >::PrecisionType s2, typename NumericTraits< T >::PrecisionType s0Sq, typename NumericTraits< T >::PrecisionType sumAbsDev, T dMin, T dMax, Int iMin, Int iMax) const
 Fill the ouput moments array.
void setPosLabel (String &title, const IPosition &pos) const
 Fill a string with the position of the cursor.
void setCoordinateSystem (CoordinateSystem &cSys, MomentsBase< T > &iMom)
 Install CoordinateSystem and SpectralCoordinate in protected data members.
void setUpCoords (const MomentsBase< T > &iMom, Vector< Double > &pixelIn, Vector< Double > &worldOut, Vector< Double > &sepWorldCoord, LogIO &os, Double &integratedScaleFactor, const CoordinateSystem &cSys, Bool doCoordProfile, Bool doCoordRandom) const
 Set up separable moment axis coordinate vector and conversion vectors if not separable.
T & stdDeviation (MomentsBase< T > &iMom) const
 Return standard deviation of image from ImageMoments or MSMoments object.
virtual void init (uInt nOutPixelsPerCollapse)
 Check if #pixels is indeed 1.

Protected Attributes

CoordinateSystem cSys_p
 A number of private data members are kept here in the base class as they are common to the derived classes.
Vector< T > calcMoments_p
 This vector is a container for all the possible moments that can be calculated.
Vector< Bool > calcMomentsMask_p
Vector< Int > selectMoments_p
 This vector tells us which elements of the calcMoments_p vector we wish to select.
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.
Bool doMedianV_p
Bool doAbsDev_p
Vector< Double > pixelIn_p
 These vectors are used to transform coordinates between pixel and world.
Vector< Double > worldOut_p
Bool doCoordProfile_p
 All computations involving Coordinate conversions are relatively expensive These Bools signifies whether we need coordinate calculations or not for the full profile, and for some occaisional calculations.
Bool doCoordRandom_p
Vector< Double > sepWorldCoord_p
 This vector houses the world coordinate values for the profile if it was from a separable axis.
Vector< T > abcissa_p
 This vector is used to hold the abscissa values.
String momAxisType_p
 This string tells us the name of the moment axis (VELO or FREQ etc).
uInt nFailed_p
 This is the number of Gaussian fits that failed.
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.

Detailed Description

template<class T>
class casa::MomentCalcBase< T >

Abstract base class for moment calculator classes.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

This class, its concrete derived classes, and the classes LineCollapser, ImageMoments, MSMoments, and LatticeApply are connected as follows. LatticeApply offers functions so that the application programmer does not need to worry about how to optimally iterate through a Lattice; it deals with tiling and to a lesser extent memory. LatticeApply functions are used by offering a class object to them that has a member function with a name and signature specified by an abstract base class that LatticeApply uses and the offered class inherits from. Specifically, in this case, MomentCalcBase inherits from LineCollapser and LatticeApply uses objects and methods of this class (but does not inherit from it). This defines the functions collapse and multiProcess which operate on a vector extracted from a Lattice. The former returns one number, the latter a vector of numbers from that profile. MomentCalcBase is a base class for for moment calculation and the multiProcess functions are used to compute moments (e.g., mean, sum, sum squared, intensity weighted velocity etc).

It is actually the concrete classes derived from MomentCalcBase (call them, as a group, the MomentCalculator classes) that implement the multiProcess functions. These derived classes allow different algorithms to be written with which moments of the vector can be computed.

Now, so far, we have a LatticeApply function which iterates through Lattices, extracts vectors, and offers them up to functions implemented in the derived MomentCalculator classes to compute the moments. As well as that, we need some class to actually construct the MomentCalculator classes and to feed them to LatticeApply. This is the role of the ImageMoments or MSMoments classes. They are a high level class which takes control information from users specifying which moments they would like to calculate and how. They also provide the ancilliary masking lattice to the MomentCalculator constructors. The actual computational work is done by the MomentCalculator classes. So MomentsBase, MomentCalcBase and their derived MomentCalculator classes are really one unit; none of them are useful without the others. The separation of functionality is caused by having the LatticeApply class that knows all about optimally iterating through Lattices.

The coupling between these classes is done partly by the "friendship". MomentsBase and its inheritances grant friendship to MomentCalcBase so that the latter has access to the private data and private functions of the formers. MomentCalcBase then operates as an interface between its derived MomentCalculator classes and ImageMoments or MSMoments. It retrieves private data from these classes, and also activates private functions in these classes, on behalf of the MomentCalculator classes. The rest of the coupling is done via the constructors of the derived MomentCalculator classes.

Finally, MomentCalcBase also has a number of protected functions that are common to its derived classes (e.g. fitting, accumulating sums etc). It also has protected data that is common to all the MomentCalculator classes. This protected data is accessed directly by name rather than with interface functions as there is too much of it. Of course, since MomentCalcBase is an abstract base class, it is up to the MomentCalculator classes to give the MomentCalcBase protected data objects values.

For discussion about different moments and algorithms to compute them see the discussion in MomentsBase , ImageMoments , MSMoments and also in the derived classes documentation.

Example

Since MomentCalcBase is an abstract class, we defer code examples to the derived classes.

Motivation

We were desirous of writing functions to optimally iterate through Lattices so that the application programmer did not have to know anything about tiling or memory if possible. These are the LatticeApply functions. To incorporate MomentsBase and its inheritances into this scheme required some of it to be shifted into MomentCalcBase and its derived classes.


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

To Do

Definition at line 132 of file MomentCalcBase.h.


Constructor & Destructor Documentation

template<class T >
virtual casa::MomentCalcBase< T >::~MomentCalcBase (  )  [virtual]

Member Function Documentation

template<class T >
void casa::MomentCalcBase< T >::accumSums ( typename NumericTraits< T >::PrecisionType &  s0,
typename NumericTraits< T >::PrecisionType &  s0Sq,
typename NumericTraits< T >::PrecisionType &  s1,
typename NumericTraits< T >::PrecisionType &  s2,
Int &  iMin,
Int &  iMax,
T &  dMin,
T &  dMax,
Int  i,
datum,
Double  coord 
) const [inline, protected]

Accumulate statistical sums from a vector.

Accumulate statistical sums from this datum

Input: i Index datum Pixel value coord Coordinate value on moment axis Input/output: iMin,max index of dMin and dMax dMin,dMax minimum and maximum value Output: s0 sum (I) s0Sq sum (I*I) s1 sum (I*v) s2 sum (I*v*v)

Definition at line 202 of file MomentCalcBase.h.

template<class T >
uInt casa::MomentCalcBase< T >::allNoise ( T &  dMean,
const Vector< T > &  data,
const Vector< Bool > &  mask,
peakSNR,
stdDeviation 
) const [protected]

Determine if the spectrum is pure noise.

template<class T >
void casa::MomentCalcBase< T >::constructorCheck ( Vector< T > &  calcMoments,
Vector< Bool > &  calcMomentsMask,
const Vector< Int > &  selectMoments,
uInt  nLatticeOut 
) const [protected]

Check validity of constructor inputs.

template<class T >
void casa::MomentCalcBase< T >::costlyMoments ( MomentsBase< T > &  iMom,
Bool &  doMedianI,
Bool &  doMedianV,
Bool &  doAbsDev 
) const [protected]

Find out from the selectMoments array whether we want to compute the more expensive moments.

template<class T >
void casa::MomentCalcBase< T >::doCoordCalc ( Bool &  doCoordProfile,
Bool &  doCoordRandom,
const MomentsBase< T > &  iMom 
) const [protected]

Return the Bool saying whether we need to compute coordinates or not for the requested moments.

template<class T >
Bool casa::MomentCalcBase< T >::doFit ( const MomentsBase< T > &  iMom  )  const [protected]

Return the Bool from the ImageMoments or MSMoments object saying whether we are going to fit Gaussians to the profiles or not.

template<class T >
Bool casa::MomentCalcBase< T >::findNextDatum ( uInt &  iFound,
const uInt &  n,
const Vector< Bool > &  mask,
const uInt &  iStart,
const Bool &  findGood 
) const [protected]

Find the next masked or unmasked point in a vector.

template<class T >
Bool casa::MomentCalcBase< T >::fitGaussian ( uInt &  nFailed,
T &  peak,
T &  pos,
T &  width,
T &  level,
const Vector< T > &  x,
const Vector< T > &  y,
const Vector< Bool > &  mask,
peakGuess,
posGuess,
widthGuess,
levelGuess 
) const [protected]

Fit a Gaussian to x and y arrays given guesses for the gaussian parameters.

template<class T >
Bool casa::MomentCalcBase< T >::getAutoGaussianFit ( uInt &  nFailed,
Vector< T > &  gaussPars,
const Vector< T > &  x,
const Vector< T > &  y,
const Vector< Bool > &  mask,
peakSNR,
stdDeviation 
) const [protected]

Automatically fit a Gaussian to a spectrum, including finding the starting guesses.

template<class T >
Bool casa::MomentCalcBase< T >::getAutoGaussianGuess ( T &  peakGuess,
T &  posGuess,
T &  widthGuess,
T &  levelGuess,
const Vector< T > &  x,
const Vector< T > &  y,
const Vector< Bool > &  mask 
) const [protected]

Automatically work out a guess for the Gaussian parameters Returns False if all pixels masked.

template<class T >
Double casa::MomentCalcBase< T >::getMomentCoord ( const MomentsBase< T > &  iMom,
Vector< Double > &  pixelIn,
Vector< Double > &  worldOut,
Double  momentPixel,
Bool  asVelocity = False 
) const [inline, protected]

Compute the world coordinate for the given moment axis pixel.

Find the value of the world coordinate on the moment axis for the given moment axis pixel value.

Input momentPixel is the index in the profile extracted from the data Input/output pixelIn Pixels to convert. Must all be filled in except for pixelIn(momentPixel). worldOut Vector to hold result

Should really return a Fallible as I don't check and see if the coordinate transformation fails or not

Should really check the result is True, but for speed ..\.

Definition at line 309 of file MomentCalcBase.h.

References casa::MomentCalcBase< T >::cSys_p, and casa::MomentsBase< T >::worldMomentAxis_p.

template<class T >
virtual void casa::MomentCalcBase< T >::init ( uInt  nOutPixelsPerCollapse  )  [protected, virtual]

Check if #pixels is indeed 1.

template<class T >
void casa::MomentCalcBase< T >::lineSegments ( uInt &  nSeg,
Vector< uInt > &  start,
Vector< uInt > &  nPts,
const Vector< Bool > &  mask 
) const [protected]

Examine a mask and determine how many segments of unmasked points it consists of.

template<class T >
Int& casa::MomentCalcBase< T >::momentAxis ( MomentsBase< T > &  iMom  )  const [protected]

Return the moment axis from the ImageMoments object.

template<class T >
String casa::MomentCalcBase< T >::momentAxisName ( const CoordinateSystem &  ,
const MomentsBase< T > &  iMom 
) const [protected]

Return the name of the moment/profile axis.

template<class T >
virtual uInt casa::MomentCalcBase< T >::nFailedFits (  )  const [inline, virtual]

Returns the number of failed fits if doing fitting.

Definition at line 142 of file MomentCalcBase.h.

References casa::MomentCalcBase< T >::nFailed_p.

template<class T >
T& casa::MomentCalcBase< T >::peakSNR ( MomentsBase< T > &  iMom  )  const [protected]

Return the peak SNR for determination of all noise spectra from the ImageMoments or MSMoments object.

template<class T >
Vector<Int> casa::MomentCalcBase< T >::selectMoments ( MomentsBase< T > &  iMom  )  const [protected]

The MomentCalculators compute a vector of all possible moments.

This function returns a vector which selects the desired moments from that "all moment" vector.

template<class T >
void casa::MomentCalcBase< T >::selectRange ( Vector< T > &  pixelRange,
Bool &  doInclude,
Bool &  doExlude,
MomentsBase< T > &  iMom 
) const [protected]

Return the selected pixel intensity range from the ImageMoments or MSMoments object and the Bools describing whether it is inclusion or exclusion.

template<class T >
void casa::MomentCalcBase< T >::setCalcMoments ( const MomentsBase< T > &  iMom,
Vector< T > &  calcMoments,
Vector< Bool > &  calcMomentsMask,
Vector< Double > &  pixelIn,
Vector< Double > &  worldOut,
Bool  doCoord,
Double  integratedScaleFactor,
dMedian,
vMedian,
Int  nPts,
typename NumericTraits< T >::PrecisionType  s0,
typename NumericTraits< T >::PrecisionType  s1,
typename NumericTraits< T >::PrecisionType  s2,
typename NumericTraits< T >::PrecisionType  s0Sq,
typename NumericTraits< T >::PrecisionType  sumAbsDev,
dMin,
dMax,
Int  iMin,
Int  iMax 
) const [protected]

Fill the ouput moments array.

template<class T >
void casa::MomentCalcBase< T >::setCoordinateSystem ( CoordinateSystem &  cSys,
MomentsBase< T > &  iMom 
) [protected]

Install CoordinateSystem and SpectralCoordinate in protected data members.

template<class T >
void casa::MomentCalcBase< T >::setPosLabel ( String &  title,
const IPosition &  pos 
) const [protected]

Fill a string with the position of the cursor.

template<class T >
void casa::MomentCalcBase< T >::setUpCoords ( const MomentsBase< T > &  iMom,
Vector< Double > &  pixelIn,
Vector< Double > &  worldOut,
Vector< Double > &  sepWorldCoord,
LogIO &  os,
Double &  integratedScaleFactor,
const CoordinateSystem &  cSys,
Bool  doCoordProfile,
Bool  doCoordRandom 
) const [protected]

Set up separable moment axis coordinate vector and conversion vectors if not separable.

template<class T >
T& casa::MomentCalcBase< T >::stdDeviation ( MomentsBase< T > &  iMom  )  const [protected]

Return standard deviation of image from ImageMoments or MSMoments object.


Member Data Documentation

template<class T >
Vector<T> casa::MomentCalcBase< T >::abcissa_p [protected]

This vector is used to hold the abscissa values.

Definition at line 186 of file MomentCalcBase.h.

template<class T >
Vector<T> casa::MomentCalcBase< T >::calcMoments_p [protected]

This vector is a container for all the possible moments that can be calculated.

They are in the order given by the MomentsBase enum MomentTypes

Definition at line 156 of file MomentCalcBase.h.

template<class T >
Vector<Bool> casa::MomentCalcBase< T >::calcMomentsMask_p [protected]

Definition at line 157 of file MomentCalcBase.h.

template<class T >
CoordinateSystem casa::MomentCalcBase< T >::cSys_p [protected]

A number of private data members are kept here in the base class as they are common to the derived classes.

Since this class is abstract, they have to be filled by the derived classes.

CoordinateSystem

Definition at line 151 of file MomentCalcBase.h.

Referenced by casa::MomentCalcBase< T >::getMomentCoord().

template<class T >
Bool casa::MomentCalcBase< T >::doAbsDev_p [protected]

Definition at line 169 of file MomentCalcBase.h.

template<class T >
Bool casa::MomentCalcBase< T >::doCoordProfile_p [protected]

All computations involving Coordinate conversions are relatively expensive These Bools signifies whether we need coordinate calculations or not for the full profile, and for some occaisional calculations.

Definition at line 177 of file MomentCalcBase.h.

template<class T >
Bool casa::MomentCalcBase< T >::doCoordRandom_p [protected]

Definition at line 177 of file MomentCalcBase.h.

template<class T >
Bool casa::MomentCalcBase< T >::doMedianI_p [protected]

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.

These are the median moments and those that require a second pass. These control Bools tell us whether we really want to compute the expensive ones.

Definition at line 169 of file MomentCalcBase.h.

template<class T >
Bool casa::MomentCalcBase< T >::doMedianV_p [protected]

Definition at line 169 of file MomentCalcBase.h.

template<class T >
Double casa::MomentCalcBase< T >::integratedScaleFactor_p [protected]

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.

optical) this is approximate only and is computed at the reference pixel

Definition at line 199 of file MomentCalcBase.h.

template<class T >
String casa::MomentCalcBase< T >::momAxisType_p [protected]

This string tells us the name of the moment axis (VELO or FREQ etc).

Definition at line 189 of file MomentCalcBase.h.

template<class T >
uInt casa::MomentCalcBase< T >::nFailed_p [protected]

This is the number of Gaussian fits that failed.

Definition at line 192 of file MomentCalcBase.h.

Referenced by casa::MomentCalcBase< T >::nFailedFits().

template<class T >
Vector<Double> casa::MomentCalcBase< T >::pixelIn_p [protected]

These vectors are used to transform coordinates between pixel and world.

Definition at line 172 of file MomentCalcBase.h.

template<class T >
Vector<Int> casa::MomentCalcBase< T >::selectMoments_p [protected]

This vector tells us which elements of the calcMoments_p vector we wish to select.

Definition at line 161 of file MomentCalcBase.h.

template<class T >
Vector<Double> casa::MomentCalcBase< T >::sepWorldCoord_p [protected]

This vector houses the world coordinate values for the profile if it was from a separable axis.

This means this vector can be pre computed just once, instead of working out the coordinates for each profile (expensive). It should only be filled if doCoordCalc_p is True

Definition at line 183 of file MomentCalcBase.h.

template<class T >
Vector<Double> casa::MomentCalcBase< T >::worldOut_p [protected]

Definition at line 172 of file MomentCalcBase.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1