casa
5.7.0-16
|
Abstract base class for moment calculator classes. More...
#include <MomentCalcBase.h>
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 Member Functions | |
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... | |
virtual void | process (T &result, Bool &resultMask, const Vector< T > &line, const Vector< Bool > &mask, const IPosition &pos)=0 |
Collapse the given line and return one value from that operation. More... | |
virtual void | multiProcess (Vector< T > &result, Vector< Bool > &resultMask, const Vector< T > &line, const Vector< Bool > &mask, const IPosition &pos)=0 |
Collapse the given line and return a line of values from that operation. More... | |
Protected Member Functions | |
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::Int & | momentAxis (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::Int > | selectMoments (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 | |
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::Bool > | calcMomentsMask_p |
casacore::Vector< casacore::Int > | selectMoments_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... | |
Abstract base class for moment calculator classes.
Public interface
This class, its concrete derived classes, and the classes casacore::LineCollapser, ImageMoments, MSMoments, and casacore::LatticeApply are connected as follows. casacore::LatticeApply offers functions so that the application programmer does not need to worry about how to optimally iterate through a casacore::Lattice; it deals with tiling and to a lesser extent memory. casacore::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 casacore::LatticeApply uses and the offered class inherits from. Specifically, in this case, MomentCalcBase inherits from casacore::LineCollapser and casacore::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 casacore::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 casacore::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.
Since MomentCalcBase is an abstract class, we defer code examples to the derived classes.
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 casacore::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;
Definition at line 132 of file MomentCalcBase.h.
using casa::MomentCalcBase< T >::AccumType = typename casacore::NumericTraits<T>::PrecisionType |
Definition at line 135 of file MomentCalcBase.h.
using casa::MomentCalcBase< T >::DataIterator = typename casacore::Vector<T>::const_iterator |
Definition at line 136 of file MomentCalcBase.h.
using casa::MomentCalcBase< T >::MaskIterator = casacore::Vector<casacore::Bool>::const_iterator |
Definition at line 137 of file MomentCalcBase.h.
|
virtual |
|
inlineprotected |
Accumulate statistical sums from a vector.
Accumulate statistical sums from this datum
casacore::Input: i Index datum Pixel value coord casacore::Coordinate value on moment axis casacore::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.
|
protected |
Determine if the spectrum is pure noise.
|
protected |
Check validity of constructor inputs.
|
protected |
Find out from the selectMoments array whether we want to compute the more expensive moments.
|
protected |
Return the casacore::Bool saying whether we need to compute coordinates or not for the requested moments.
|
protected |
Return the casacore::Bool from the ImageMoments or MSMoments object saying whether we are going to fit Gaussians to the profiles or not.
|
protected |
Find the next masked or unmasked point in a vector.
|
protected |
Fit a Gaussian to x and y arrays given guesses for the gaussian parameters.
|
protected |
Automatically fit a Gaussian to a spectrum, including finding the starting guesses.
|
protected |
Automatically work out a guess for the Gaussian parameters Returns false if all pixels masked.
|
inlineprotected |
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 casacore::Input/output pixelIn Pixels to convert. Must all be filled in except for pixelIn(momentPixel). worldOut casacore::Vector to hold result
Should really return a casacore::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, casacore::SpectralCoordinate::frequencyToVelocity(), casa::MomentsBase< T >::momentAxis_p, casacore::CoordinateSystem::spectralCoordinate(), casacore::CoordinateSystem::toWorld(), and casa::MomentsBase< T >::worldMomentAxis_p.
|
protectedvirtual |
Check if #pixels is indeed 1.
Implements casacore::LineCollapser< T, T >.
|
protected |
Examine a mask and determine how many segments of unmasked points it consists of.
|
protected |
Return the moment axis from the ImageMoments object.
|
protected |
Return the name of the moment/profile axis.
|
inlinevirtual |
Returns the number of failed fits if doing fitting.
Definition at line 142 of file MomentCalcBase.h.
References casa::MomentCalcBase< T >::nFailed_p.
|
protected |
Return the peak SNR for determination of all noise spectra from the ImageMoments or MSMoments object.
|
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.
|
protected |
Return the selected pixel intensity range from the ImageMoments or MSMoments object and the Bools describing whether it is inclusion or exclusion.
|
protected |
Fill the ouput moments array.
|
protected |
Install casacore::CoordinateSystem and SpectralCoordinate in protected data members.
|
protected |
Fill a string with the position of the cursor.
|
protected |
Set up separable moment axis coordinate vector and conversion vectors if not separable.
|
protected |
Return standard deviation of image from ImageMoments or MSMoments object.
|
protected |
This vector is used to hold the abscissa values.
Definition at line 186 of file MomentCalcBase.h.
|
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.
|
protected |
Definition at line 157 of file MomentCalcBase.h.
|
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().
|
protected |
Definition at line 169 of file MomentCalcBase.h.
|
protected |
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.
Definition at line 177 of file MomentCalcBase.h.
|
protected |
Definition at line 177 of file MomentCalcBase.h.
|
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.
|
protected |
Definition at line 169 of file MomentCalcBase.h.
|
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.
|
protected |
This string tells us the name of the moment axis (VELO or FREQ etc)
Definition at line 189 of file MomentCalcBase.h.
|
protected |
This is the number of Gaussian fits that failed.
Definition at line 192 of file MomentCalcBase.h.
Referenced by casa::MomentCalcBase< T >::nFailedFits().
|
protected |
These vectors are used to transform coordinates between pixel and world.
Definition at line 172 of file MomentCalcBase.h.
|
protected |
This vector tells us which elements of the calcMoments_p vector we wish to select.
Definition at line 161 of file MomentCalcBase.h.
|
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.
|
protected |
Definition at line 172 of file MomentCalcBase.h.