GCpp general purpose C++ library  version 1.0
GExtremaFinder Class Reference

#include <GExtremaFinder.hh>

Public Member Functions

Constructors, destructors, affectation
 GExtremaFinder (u_int n=0, double *data=NULL, double bin=1.)
 
 GExtremaFinder (GRealSampleFFT *sptr)
 
 GExtremaFinder (GRealSampleFFT &s)
 
 GExtremaFinder (const GExtremaFinder &original)
 
GExtremaFinderoperator= (const GExtremaFinder &original)
 
virtual ~GExtremaFinder ()
 
Access to data
bool IsSampleLocal () const
 
const GRealSampleFFTGetSample () const
 
GRealSampleFFTGetSample ()
 
const GRealSampleFFTGetDerivativeSample () const
 
GRealSampleFFTGetDerivativeSample ()
 
u_int GetExtremaNum () const
 
const double * GetExtremaValues () const
 
double * GetExtremaValues ()
 
const double * GetExtremaPositions () const
 
double * GetExtremaPositions ()
 
const u_intGetExtremaBins () const
 
u_intGetExtremaBins ()
 
const bool * GetExtremaMax () const
 
bool * GetExtremaMax ()
 
u_int GetMaximaNum () const
 
const double * GetMaximaValues () const
 
double * GetMaximaValues ()
 
const double * GetMaximaPositions () const
 
double * GetMaximaPositions ()
 
const u_intGetMaximaBins () const
 
u_intGetMaximaBins ()
 
const double * GetMaximaCenters () const
 
double * GetMaximaCenters ()
 
const double * GetMaximaAmplitudes () const
 
double * GetMaximaAmplitudes ()
 
const double * GetMaximaAverages () const
 
double * GetMaximaAverages ()
 
double GetMaxValue (u_int i) const
 
double GetMaxPosition (u_int i) const
 
u_int GetMaxBin (u_int i) const
 
double GetMaxCenter (u_int i) const
 
double GetMaxAmplitude (u_int i) const
 
double GetMaxAverage (u_int i) const
 
u_int GetMaxPrevMinBin (u_int i) const
 
u_int GetMaxNextMinBin (u_int i) const
 
double GetMaxPrevMinPos (u_int i) const
 
double GetMaxNextMinPos (u_int i) const
 
double GetMaxPrevMinVal (u_int i) const
 
double GetMaxNextMinVal (u_int i) const
 
Extrema analysis
virtual int Analyse ()
 
virtual int Analyse (GRealSampleFFT *sptr)
 
virtual int Analyse (GRealSampleFFT &s)
 
virtual int DifferentialThreshold (double thr)
 
virtual void SetMaximaLowThreshold (double thr)
 
virtual void UnsetMaximaLowThreshold ()
 
virtual int AnalyseMaxima ()
 
virtual int AnalyseMaxima (GRealSampleFFT &s)
 
virtual int AnalyseMaxima (GRealSampleFFT &s, double low_thr)
 
virtual int AnalyseMaxima (GRealSampleFFT &s, double low_thr, double dif_thr)
 

Protected Attributes

GRealSampleFFTsample_ptr
 Pointer to the data sample to analyse.
 
bool sample_local
 Whether the sample is allocated by the class.
 
GRealSampleFFTderiv_ptr
 Derivative of the data sample.
 
bool analyzed
 Whether the extrema have been analyzed.
 
u_int alloc_size
 Allocated size for arrays.
 
u_int extr_num
 Number of extrema.
 
double * extr_val
 Array of extrema values.
 
double * extr_pos
 Array of extrema positions.
 
u_intextr_bin
 Array of bins with extrema.
 
bool * extr_max
 Array indicating if extrema are maxima (or minima)
 
bool max_thr_use
 Use of a low signal threshold for maxima analysis.
 
double max_thr_low
 Low signal threshold for maxima analysis.
 
u_int max_num
 Number of maxima.
 
double * max_val
 Array of maxima values.
 
double * max_pos
 Array of maxima positions.
 
u_intmax_bin
 Array of bins with maxima.
 
double * max_ctr
 Array of maxima zone average positions.
 
double * max_amp
 Array of maxima zone sum amplitude.
 
double * max_avg
 Array of maxima zone average amplitude.
 
double * max_prev_min_val
 Array of values of the minimum before maxima.
 
double * max_next_min_val
 Array of values of the minimum after maxima.
 
double * max_prev_min_pos
 Array of positions of the minimum before maxima.
 
double * max_next_min_pos
 Array of positions of the minimum after maxima.
 
u_intmax_prev_min_bin
 Array of positions of the minimum before maxima.
 
u_intmax_next_min_bin
 Array of positions of the minimum after maxima.
 

Private Member Functions

 GObjectV (GExtremaFinder)
 

Initialisation and setting functions

virtual int InitData (u_int n, double *data, double bin=1.)
 
virtual int InitData (GRealSampleFFT *sptr)
 
virtual int InitData (GRealSampleFFT &s)
 
virtual void ResetData ()
 
virtual void ClearData ()
 
virtual void CopyData (const GExtremaFinder &original)
 

Detailed Description

This class performs a maxima / minima search on a sample of real data.

Extrema analysis
Maxima analysis

The maxima analysis is performed from the results of the extrema analysis (maxima and minima).

The analysis selects the maxima and sets the corresponding information in dedicated arrays. The information is the following:

  • the number of maxima;
  • the raw data from maxima analysis:
    • Values: the signal amplitude at maxima positions;
    • Positions: the position of the maxima along signal axis;
    • Bins: the sample bins that contain a maximum;
  • a more detailed analysis of the maxima, analysing the signal over the full range from the preceeding to the following minimum:
    • Centers: total signal mean position for the maxima;
    • Amplitudes: integrated signal for the maxima;
    • Averages: average signal for the maxima;
    • the information about the maxima analysis zone: position and signal of the lower and upper limits of the zone asociated to the maxima.

For the maxima analysis, it is also possible to set a low signal threshold below which the data are not considered:

  • a maximum below this threshold is ignored;
  • the local maxima zone for integration / average is limited to a region where the signal does not drop below this threshold.

Constructor & Destructor Documentation

GExtremaFinder::GExtremaFinder ( u_int  n = 0,
double *  data = NULL,
double  bin = 1. 
)

Base constructor. The data array is copied into an internal sample for the analysis.

Parameters
narray dimension (should be a power of 2)
datadata array
binbin size

References alloc_size, analyzed, deriv_ptr, extr_bin, extr_max, extr_num, extr_pos, extr_val, InitData(), max_amp, max_avg, max_bin, max_ctr, max_next_min_bin, max_next_min_pos, max_next_min_val, max_num, max_pos, max_prev_min_bin, max_prev_min_pos, max_prev_min_val, max_thr_low, max_thr_use, max_val, sample_local, and sample_ptr.

GExtremaFinder::GExtremaFinder ( GRealSampleFFT sptr)
GExtremaFinder::~GExtremaFinder ( )
virtual

Destructor: cleans-up the data.

References ResetData().

Member Function Documentation

int GExtremaFinder::Analyse ( )
virtual

Function that performs the extrema analysis for the sample currently defined. The function returns the number of extrema points, or a negative value in case of error.

References analyzed, ClearData(), deriv_ptr, GRealSampleFFT::Derivate(), extr_bin, extr_max, extr_num, extr_pos, extr_val, GBaseSampleFFT::GetFunctionData(), GBaseSampleFFT::GetSamplesNumber(), GBaseSampleFFT::GetTimeStep(), GLogWarning(), and sample_ptr.

Referenced by Analyse(), and AnalyseMaxima().

int GExtremaFinder::Analyse ( GRealSampleFFT sptr)
virtual

Function that sets a new sample (locally) and performs the extrema analysis.

Parameters
sptrpointer to the sample

References Analyse(), and InitData().

int GExtremaFinder::Analyse ( GRealSampleFFT s)
virtual

Function that sets a new sample (externally) and performs the extrema analysis.

Parameters
ssample object

References Analyse(), and InitData().

int GExtremaFinder::AnalyseMaxima ( )
virtual

Function that computes the integral and average signal for each maximum. The extrema must have been analysed previously. For each maximum, the analysis is performed between previous and next minimum. The function returns the number of maxima, or a negative value in case of error.

References analyzed, extr_bin, extr_max, extr_num, extr_pos, extr_val, GBaseSampleFFT::GetFunctionData(), GBaseSampleFFT::GetSamplesNumber(), GBaseSampleFFT::GetTimeStep(), GLogWarning(), max_amp, max_avg, max_bin, max_ctr, max_next_min_bin, max_next_min_pos, max_next_min_val, max_num, max_pos, max_prev_min_bin, max_prev_min_pos, max_prev_min_val, max_thr_low, max_thr_use, max_val, and sample_ptr.

Referenced by AnalyseMaxima().

int GExtremaFinder::AnalyseMaxima ( GRealSampleFFT s)
virtual

Function that analyses the argument sample and computes the data for maxima (see GExtremaFinder::Analyse and GExtremaFinder::AnalyseMaxima functions).

Parameters
ssample object

References Analyse(), and AnalyseMaxima().

int GExtremaFinder::AnalyseMaxima ( GRealSampleFFT s,
double  low_thr 
)
virtual

Function that analyses the argument sample and computes the data for maxima (see GExtremaFinder::Analyse and GExtremaFinder::AnalyseMaxima functions). The maxima analysis is performed with a low signal threshold value. If a low threshold is defined the GExtremaFinder::DifferentialThreshold is called.

Parameters
ssample object
low_thrmaxima analysis low threshold

References Analyse(), AnalyseMaxima(), and SetMaximaLowThreshold().

int GExtremaFinder::AnalyseMaxima ( GRealSampleFFT s,
double  low_thr,
double  dif_thr 
)
virtual

Function that analyses the argument sample and computes the data for maxima (see GExtremaFinder::Analyse and GExtremaFinder::AnalyseMaxima functions). The maxima analysis is performed with a low signal threshold value. If an extrema difference validation threshold is defined the GExtremaFinder::DifferentialThreshold is called.

Parameters
ssample object
low_thrmaxima analysis low threshold
dif_thrextrema validation threshold

References Analyse(), AnalyseMaxima(), DifferentialThreshold(), and SetMaximaLowThreshold().

void GExtremaFinder::ClearData ( )
virtual

Fonctions that clears the analysis.

References analyzed, extr_num, and max_num.

Referenced by Analyse(), and InitData().

int GExtremaFinder::DifferentialThreshold ( double  thr)
virtual

Function that selects the extrema if the amplitude difference is larger than the argument threshold. The extrema must have been analysed previously. If the threshold is smaller than a previously set threshold for the same sample, nothing is done. The function returns the new number of extrema, or a negative value in case of error.

Parameters
thrselected threshold

cerr << "First local extremum " << extr_bin[ix] << " (#" << ix << "): " << extr_val[ix] << endl;

References analyzed, extr_bin, extr_max, extr_num, extr_pos, extr_val, GBaseSampleFFT::GetTimeStep(), GLogWarning(), and sample_ptr.

Referenced by AnalyseMaxima().

const GRealSampleFFT * GExtremaFinder::GetDerivativeSample ( ) const
inline

Return the derivative sample.

References deriv_ptr.

GRealSampleFFT * GExtremaFinder::GetDerivativeSample ( )
inline

Return the derivative sample.

References deriv_ptr.

const u_int * GExtremaFinder::GetExtremaBins ( ) const
inline

Returns the array of extrema sample bin indexes.

References extr_bin.

Referenced by CopyData().

u_int * GExtremaFinder::GetExtremaBins ( )
inline

Returns the array of extrema sample bin indexes.

References extr_bin.

const bool * GExtremaFinder::GetExtremaMax ( ) const
inline

Returns the array of maxima flags.

References extr_max.

Referenced by CopyData().

bool * GExtremaFinder::GetExtremaMax ( )
inline

Returns the array of maxima flags.

References extr_max.

u_int GExtremaFinder::GetExtremaNum ( ) const
inline

Returns the number of extrema.

References extr_num.

Referenced by CopyData().

const double * GExtremaFinder::GetExtremaPositions ( ) const
inline

Returns the array of extrema positions.

References extr_pos.

Referenced by CopyData().

double * GExtremaFinder::GetExtremaPositions ( )
inline

Returns the array of extrema positions.

References extr_pos.

const double * GExtremaFinder::GetExtremaValues ( ) const
inline

Returns the array of extrema values.

References extr_val.

Referenced by CopyData().

double * GExtremaFinder::GetExtremaValues ( )
inline

Returns the array of extrema values.

References extr_val.

double GExtremaFinder::GetMaxAmplitude ( u_int  i) const
inline

Return the integral signal for a maximum.

Parameters
imaximum index

References max_amp.

double GExtremaFinder::GetMaxAverage ( u_int  i) const
inline

Return the average signal for a maximum.

Parameters
imaximum index

References max_avg.

u_int GExtremaFinder::GetMaxBin ( u_int  i) const
inline

Return the sample bin index for a maximum.

Parameters
imaximum index

References max_bin.

double GExtremaFinder::GetMaxCenter ( u_int  i) const
inline

Return the center (average signal) for a maximum.

Parameters
imaximum index

References max_ctr.

const double * GExtremaFinder::GetMaximaAmplitudes ( ) const
inline

Returns the array of maxima integral amplitudes.

References max_amp.

Referenced by CopyData().

double * GExtremaFinder::GetMaximaAmplitudes ( )
inline

Returns the array of maxima integral amplitudes.

References max_amp.

const double * GExtremaFinder::GetMaximaAverages ( ) const
inline

Returns the array of maxima amplitudes.

References max_avg.

Referenced by CopyData().

double * GExtremaFinder::GetMaximaAverages ( )
inline

Returns the array of maxima average amplitudes.

References max_avg.

const u_int * GExtremaFinder::GetMaximaBins ( ) const
inline

Returns the array of maxima sample bin indexes.

References max_bin.

Referenced by CopyData().

u_int * GExtremaFinder::GetMaximaBins ( )
inline

Returns the array of maxima sample bin indexes.

References max_bin.

const double * GExtremaFinder::GetMaximaCenters ( ) const
inline

Returns the array of maxima centers (average signal position).

References max_ctr.

Referenced by CopyData().

double * GExtremaFinder::GetMaximaCenters ( )
inline

Returns the array of maxima centers (average signal position).

References max_ctr.

u_int GExtremaFinder::GetMaximaNum ( ) const
inline

Returns the number of maxima.

References max_num.

Referenced by CopyData().

const double * GExtremaFinder::GetMaximaPositions ( ) const
inline

Returns the array of maxima positions.

References max_pos.

Referenced by CopyData().

double * GExtremaFinder::GetMaximaPositions ( )
inline

Returns the array of maxima positions.

References max_pos.

const double * GExtremaFinder::GetMaximaValues ( ) const
inline

Returns the array of maxima values.

References max_val.

Referenced by CopyData().

double * GExtremaFinder::GetMaximaValues ( )
inline

Returns the array of maxima values.

References max_val.

u_int GExtremaFinder::GetMaxNextMinBin ( u_int  i) const
inline

Return the sample bin index of the minimum after a maximum.

Parameters
imaximum index

References max_next_min_bin.

double GExtremaFinder::GetMaxNextMinPos ( u_int  i) const
inline

Return the minimum position after a maximum.

Parameters
imaximum index

References max_next_min_pos.

double GExtremaFinder::GetMaxNextMinVal ( u_int  i) const
inline

Return the value of the minimum after a maximum.

Parameters
imaximum index

References max_next_min_val.

double GExtremaFinder::GetMaxPosition ( u_int  i) const
inline

Return the position a maximum.

Parameters
imaximum index

References max_pos.

u_int GExtremaFinder::GetMaxPrevMinBin ( u_int  i) const
inline

Return the sample bin index of the minimum before a maximum.

Parameters
imaximum index

References max_prev_min_bin.

double GExtremaFinder::GetMaxPrevMinPos ( u_int  i) const
inline

Return the minimum position before a maximum.

Parameters
imaximum index

References max_prev_min_pos.

double GExtremaFinder::GetMaxPrevMinVal ( u_int  i) const
inline

Return the value of the minimum before a maximum.

Parameters
imaximum index

References max_prev_min_val.

double GExtremaFinder::GetMaxValue ( u_int  i) const
inline

Return the signal value for a maximum.

Parameters
imaximum index

References max_val.

const GRealSampleFFT * GExtremaFinder::GetSample ( ) const
inline

Return the sample.

References sample_ptr.

GRealSampleFFT * GExtremaFinder::GetSample ( )
inline

Return the sample.

References sample_ptr.

GExtremaFinder::GObjectV ( GExtremaFinder  )
private

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
int GExtremaFinder::InitData ( u_int  n,
double *  data,
double  dt = 1. 
)
virtual

Initialization of the extrema finder from an array of values. A sample is created locally from the data.

Parameters
nrequested size of arrays
datadata array
dtsampling time step

References GLogWarning().

Referenced by Analyse(), CopyData(), GExtremaFinder(), and InitData().

int GExtremaFinder::InitData ( GRealSampleFFT sptr)
virtual

Initialization of the extrema finder from a sample pointer. The data sample is adopted by the class and delete with it.

Parameters
sptrpointer to the data sample

References GLogWarning(), InitData(), sample_local, and sample_ptr.

int GExtremaFinder::InitData ( GRealSampleFFT s)
virtual

Initialization of the extrema finder from an external sample. The data sample pointer is set and considered external.

Parameters
sdata sample

References alloc_size, ClearData(), deriv_ptr, extr_bin, extr_max, extr_pos, extr_val, GBaseSampleFFT::GetSamplesNumber(), max_amp, max_avg, max_bin, max_ctr, max_next_min_bin, max_next_min_pos, max_next_min_val, max_pos, max_prev_min_bin, max_prev_min_pos, max_prev_min_val, max_val, ResetData(), sample_local, and sample_ptr.

bool GExtremaFinder::IsSampleLocal ( ) const
inline

Return true if the data sample is defined locally.

References sample_local.

Referenced by CopyData().

GExtremaFinder & GExtremaFinder::operator= ( const GExtremaFinder original)

Affectation operator.

Parameters
originalobject to be copied

References CopyData().

void GExtremaFinder::ResetData ( )
virtual
void GExtremaFinder::SetMaximaLowThreshold ( double  thr)
inlinevirtual

Set the use of a low threshold for maxima analysis (the threshold value can be 0 or less).

Parameters
thrlow signal threshold for maxima analysis

References max_thr_low, and max_thr_use.

Referenced by AnalyseMaxima().

void GExtremaFinder::UnsetMaximaLowThreshold ( )
inlinevirtual

Unset the use of a low threshold for maxima analysis.

References max_thr_use.


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