GCpp general purpose C++ library
version 1.0
|
#include <GExtremaFinder.hh>
Protected Attributes | |
GRealSampleFFT * | sample_ptr |
Pointer to the data sample to analyse. | |
bool | sample_local |
Whether the sample is allocated by the class. | |
GRealSampleFFT * | deriv_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_int * | extr_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_int * | max_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_int * | max_prev_min_bin |
Array of positions of the minimum before maxima. | |
u_int * | max_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) |
This class performs a maxima / minima search on a sample of real data.
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:
For the maxima analysis, it is also possible to set a low signal threshold below which the data are not considered:
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.
n | array dimension (should be a power of 2) |
data | data array |
bin | bin 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 | ) |
Constructor from a GRealSampleFFT pointer. The GRealSampleFFT object is adopted (deleted with the GExtremaFinder object).
sptr | pointer to the sample |
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 & | s | ) |
Constructor from a GRealSampleFFT object. The GRealSampleFFT object is external.
s | sample object |
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 | ( | const GExtremaFinder & | original | ) |
Copy constructor.
original | object to be copied |
References alloc_size, analyzed, CopyData(), deriv_ptr, extr_bin, extr_max, extr_num, extr_pos, extr_val, 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.
|
virtual |
Destructor: cleans-up the data.
References ResetData().
|
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().
|
virtual |
Function that sets a new sample (locally) and performs the extrema analysis.
sptr | pointer to the sample |
References Analyse(), and InitData().
|
virtual |
Function that sets a new sample (externally) and performs the extrema analysis.
s | sample object |
References Analyse(), and InitData().
|
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().
|
virtual |
Function that analyses the argument sample and computes the data for maxima (see GExtremaFinder::Analyse and GExtremaFinder::AnalyseMaxima functions).
s | sample object |
References Analyse(), and AnalyseMaxima().
|
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.
s | sample object |
low_thr | maxima analysis low threshold |
References Analyse(), AnalyseMaxima(), and SetMaximaLowThreshold().
|
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.
s | sample object |
low_thr | maxima analysis low threshold |
dif_thr | extrema validation threshold |
References Analyse(), AnalyseMaxima(), DifferentialThreshold(), and SetMaximaLowThreshold().
|
virtual |
Fonctions that clears the analysis.
References analyzed, extr_num, and max_num.
Referenced by Analyse(), and InitData().
|
protectedvirtual |
This function copies the data from original to the current object.
original | object to be copied |
References analyzed, deriv_ptr, extr_bin, extr_max, extr_pos, extr_val, GetExtremaBins(), GetExtremaMax(), GetExtremaNum(), GetExtremaPositions(), GetExtremaValues(), GetMaximaAmplitudes(), GetMaximaAverages(), GetMaximaBins(), GetMaximaCenters(), GetMaximaNum(), GetMaximaPositions(), GetMaximaValues(), InitData(), IsSampleLocal(), 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_thr_low, max_thr_use, max_val, and sample_ptr.
Referenced by GExtremaFinder(), and operator=().
|
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.
thr | selected 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().
|
inline |
Return the derivative sample.
References deriv_ptr.
|
inline |
Return the derivative sample.
References deriv_ptr.
|
inline |
|
inline |
Returns the array of extrema sample bin indexes.
References extr_bin.
|
inline |
|
inline |
Returns the array of maxima flags.
References extr_max.
|
inline |
|
inline |
|
inline |
Returns the array of extrema positions.
References extr_pos.
|
inline |
|
inline |
Returns the array of extrema values.
References extr_val.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the array of maxima integral amplitudes.
References max_amp.
|
inline |
|
inline |
Returns the array of maxima average amplitudes.
References max_avg.
|
inline |
|
inline |
Returns the array of maxima sample bin indexes.
References max_bin.
|
inline |
Returns the array of maxima centers (average signal position).
References max_ctr.
Referenced by CopyData().
|
inline |
Returns the array of maxima centers (average signal position).
References max_ctr.
|
inline |
|
inline |
|
inline |
Returns the array of maxima positions.
References max_pos.
|
inline |
|
inline |
Returns the array of maxima values.
References max_val.
Return the sample bin index of the minimum after a maximum.
i | maximum index |
References max_next_min_bin.
|
inline |
|
inline |
Return the value of the minimum after a maximum.
i | maximum index |
References max_next_min_val.
|
inline |
Return the sample bin index of the minimum before a maximum.
i | maximum index |
References max_prev_min_bin.
|
inline |
Return the minimum position before a maximum.
i | maximum index |
References max_prev_min_pos.
|
inline |
Return the value of the minimum before a maximum.
i | maximum index |
References max_prev_min_val.
|
inline |
|
inline |
Return the sample.
References sample_ptr.
|
inline |
Return the sample.
References sample_ptr.
|
private |
Macro from GCpp library that defines the following functions:
|
virtual |
Initialization of the extrema finder from an array of values. A sample is created locally from the data.
n | requested size of arrays |
data | data array |
dt | sampling time step |
References GLogWarning().
Referenced by Analyse(), CopyData(), GExtremaFinder(), and InitData().
|
virtual |
Initialization of the extrema finder from a sample pointer. The data sample is adopted by the class and delete with it.
sptr | pointer to the data sample |
References GLogWarning(), InitData(), sample_local, and sample_ptr.
|
virtual |
Initialization of the extrema finder from an external sample. The data sample pointer is set and considered external.
s | data 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.
|
inline |
Return true if the data sample is defined locally.
References sample_local.
Referenced by CopyData().
GExtremaFinder & GExtremaFinder::operator= | ( | const GExtremaFinder & | original | ) |
|
virtual |
Fonctions that deletes the data arrays and resets the analysis.
References alloc_size, analyzed, deriv_ptr, extr_bin, extr_max, extr_num, extr_pos, extr_val, 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_val, sample_local, and sample_ptr.
Referenced by InitData(), and ~GExtremaFinder().
|
inlinevirtual |
Set the use of a low threshold for maxima analysis (the threshold value can be 0 or less).
thr | low signal threshold for maxima analysis |
References max_thr_low, and max_thr_use.
Referenced by AnalyseMaxima().
|
inlinevirtual |
Unset the use of a low threshold for maxima analysis.
References max_thr_use.