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

Computes moments from a windowed profile. More...

#include <MomentWindow.h>

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

Public Types

using AccumType = typename casacore::NumericTraits< T >::PrecisionType
 
using DataIterator = typename casacore::Vector< T >::const_iterator
 
using MaskIterator = casacore::Vector< casacore::Bool >::const_iterator
 
- 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
 

Public Member Functions

 MomentWindow (shared_ptr< casacore::Lattice< T >> pAncilliaryLattice, MomentsBase< T > &iMom, casacore::LogIO &os, const casacore::uInt nLatticeOut)
 Constructor. More...
 
 ~MomentWindow ()
 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 Member Functions

casacore::Bool getAutoWindow (casacore::uInt &nFailed, casacore::Vector< casacore::Int > &window, const casacore::Vector< T > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, const T peakSNR, const T stdDeviation, const casacore::Bool doFit) const
 Automatically determine the spectral window. More...
 
casacore::Bool _getBosmaWindow (casacore::Vector< casacore::Int > &window, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, const T peakSNR, const T stdDeviation) const
 Automatically determine the spectral window via Bosma's algorithm. More...
 
casacore::Bool setNSigmaWindow (casacore::Vector< casacore::Int > &window, const T pos, const T width, const casacore::Int nPts, const casacore::Int N) const
 Take the fitted Gaussian parameters and set an N-sigma window. More...
 

Private Attributes

shared_ptr< casacore::Lattice
< T > > 
_ancilliaryLattice
 
MomentsBase< T > & iMom_p
 
casacore::LogIO os_p
 
const casacore::Vector< T > * pProfileSelect_p
 
casacore::Vector< T > ancilliarySliceRef_p
 
casacore::Vector< T > selectedData_p
 
stdDeviation_p
 
peakSNR_p
 
casacore::Bool doFit_p
 
casacore::IPosition sliceShape_p
 

Additional Inherited Members

- 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::MomentWindow< T >

Computes moments from a windowed 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 MomentWindow object and passes it to the LatticeApply function lineMultiApply. This function iterates through a given lattice, and invokes the multiProcess member function of MomentWindow on each profile 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.

MomentWindow computes moments from a subset of the pixels selected from the input profile. This subset is a simple index range, or window. The window is selected, for each profile, that is thought to surround the spectral feature of interest. This window can be found from the primary lattice, or from an ancilliary lattice (ImageMoments or MSMoments offers a smoothed version of the primary lattice as the ancilliary lattice). The moments are always computed from primary lattice data.

For each profile, the window can be found either interactively or automatically. There are two interactive methods. Either you just mark the window with the cursor, or you interactively fit a Gaussian to the profile and the +/- 3-sigma window is returned. There are two automatic methods. Either Bosma's converging mean algorithm is used, or an automatically fit Gaussian +/- 3-sigma window is returned.

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

Note that the ancilliary lattice is only accessed if the pointer to it is non zero.

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. The ancilliary masking lattice is just a smoothed version of the input lattice. 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 140 of file MomentWindow.h.

Member Typedef Documentation

template<class T >
using casa::MomentWindow< T >::AccumType = typename casacore::NumericTraits<T>::PrecisionType

Definition at line 143 of file MomentWindow.h.

template<class T >
using casa::MomentWindow< T >::DataIterator = typename casacore::Vector<T>::const_iterator

Definition at line 144 of file MomentWindow.h.

Definition at line 145 of file MomentWindow.h.

Constructor & Destructor Documentation

template<class T >
casa::MomentWindow< T >::MomentWindow ( shared_ptr< casacore::Lattice< T >>  pAncilliaryLattice,
MomentsBase< T > &  iMom,
casacore::LogIO os,
const casacore::uInt  nLatticeOut 
)

Constructor.

The pointer is to a lattice containing the masking lattice (created by ImageMoments or MSMoments). We also need the ImageMoments or MSMoments object which is calling us, its logger, and the number of output lattices it has created.

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

Destructor (does nothing).

Member Function Documentation

template<class T >
casacore::Bool casa::MomentWindow< T >::_getBosmaWindow ( casacore::Vector< casacore::Int > &  window,
const casacore::Vector< T > &  y,
const casacore::Vector< casacore::Bool > &  mask,
const T  peakSNR,
const T  stdDeviation 
) const
private

Automatically determine the spectral window via Bosma's algorithm.

template<class T >
casacore::Bool casa::MomentWindow< T >::getAutoWindow ( casacore::uInt nFailed,
casacore::Vector< casacore::Int > &  window,
const casacore::Vector< T > &  x,
const casacore::Vector< T > &  y,
const casacore::Vector< casacore::Bool > &  mask,
const T  peakSNR,
const T  stdDeviation,
const casacore::Bool  doFit 
) const
private

Automatically determine the spectral window.

template<class T >
virtual void casa::MomentWindow< 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::MomentWindow< 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 >.

template<class T >
casacore::Bool casa::MomentWindow< T >::setNSigmaWindow ( casacore::Vector< casacore::Int > &  window,
const T  pos,
const T  width,
const casacore::Int  nPts,
const casacore::Int  N 
) const
private

Take the fitted Gaussian parameters and set an N-sigma window.

If the window is too small return a Fail condition.

Member Data Documentation

template<class T >
shared_ptr<casacore::Lattice<T> > casa::MomentWindow< T >::_ancilliaryLattice
private

Definition at line 178 of file MomentWindow.h.

template<class T >
casacore::Vector<T> casa::MomentWindow< T >::ancilliarySliceRef_p
private

Definition at line 183 of file MomentWindow.h.

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

Definition at line 186 of file MomentWindow.h.

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

Definition at line 179 of file MomentWindow.h.

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

Definition at line 180 of file MomentWindow.h.

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

Definition at line 185 of file MomentWindow.h.

template<class T >
const casacore::Vector<T>* casa::MomentWindow< T >::pProfileSelect_p
private

Definition at line 182 of file MomentWindow.h.

template<class T >
casacore::Vector<T> casa::MomentWindow< T >::selectedData_p
private

Definition at line 184 of file MomentWindow.h.

template<class T >
casacore::IPosition casa::MomentWindow< T >::sliceShape_p
private

Definition at line 187 of file MomentWindow.h.

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

Definition at line 185 of file MomentWindow.h.


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