QtiPlot
0.9.8.2
|
#include <SmoothFilter.h>
Public Types | |
enum | SmoothMethod { SavitzkyGolay = 1, FFT = 2, Average = 3, Lowess = 4 } |
Public Member Functions | |
int | method () |
void | setLowessParameter (double f, int iterations) |
void | setMethod (int m) |
void | setPolynomOrder (int order) |
Sets the polynomial order in the Savitky-Golay algorithm. | |
void | setSmoothPoints (int points, int left_points=0) |
SmoothFilter (ApplicationWindow *parent, QwtPlotCurve *c, int m=3) | |
SmoothFilter (ApplicationWindow *parent, QwtPlotCurve *c, double start, double end, int m=3) | |
SmoothFilter (ApplicationWindow *parent, Graph *g, const QString &curveTitle, int m=3) | |
SmoothFilter (ApplicationWindow *parent, Graph *g, const QString &curveTitle, double start, double end, int m=3) | |
SmoothFilter (ApplicationWindow *parent, Table *t, const QString &xCol, const QString &yCol, int start=0, int end=-1, int m=3) | |
Private Member Functions | |
void | calculateOutputData (double *x, double *y) |
Calculates the data for the output curve and store it in the X an Y vectors. | |
void | init (int m) |
void | smoothAverage (double *x, double *y) |
void | smoothFFT (double *x, double *y) |
void | smoothLowess (double *x, double *y) |
void | smoothSavGol (double *x, double *y) |
Savitzky-Golay smoothing of (uniformly distributed) data. | |
Static Private Member Functions | |
static int | savitzkyGolayCoefficients (int points, int polynom_order, gsl_matrix *h) |
Compute Savitzky-Golay coefficients and store them into #h. | |
Private Attributes | |
double | d_f |
Parameter f for the Lowess algorithm. | |
int | d_iterations |
Number of iterations for the Lowess algorithm. | |
SmoothMethod | d_method |
The smooth method. | |
int | d_polynom_order |
Polynomial order in the Savitky-Golay algorithm (see Numerical Receipes in C for details). | |
int | d_sav_gol_points |
The number of left adjacents points used by the Savitky-Golay algorithm. | |
int | d_smooth_points |
The number of adjacents points used to smooth the data set. |
SmoothFilter::SmoothFilter | ( | ApplicationWindow * | parent, |
QwtPlotCurve * | c, | ||
int | m = 3 |
||
) |
References Filter::init(), and Filter::setDataFromCurve().
SmoothFilter::SmoothFilter | ( | ApplicationWindow * | parent, |
QwtPlotCurve * | c, | ||
double | start, | ||
double | end, | ||
int | m = 3 |
||
) |
References Filter::init(), and Filter::setDataFromCurve().
SmoothFilter::SmoothFilter | ( | ApplicationWindow * | parent, |
Graph * | g, | ||
const QString & | curveTitle, | ||
int | m = 3 |
||
) |
References Filter::init(), and Filter::setDataFromCurve().
SmoothFilter::SmoothFilter | ( | ApplicationWindow * | parent, |
Graph * | g, | ||
const QString & | curveTitle, | ||
double | start, | ||
double | end, | ||
int | m = 3 |
||
) |
References Filter::init(), and Filter::setDataFromCurve().
SmoothFilter::SmoothFilter | ( | ApplicationWindow * | parent, |
Table * | t, | ||
const QString & | xCol, | ||
const QString & | yCol, | ||
int | start = 0 , |
||
int | end = -1 , |
||
int | m = 3 |
||
) |
References Filter::init(), and Filter::setDataFromTable().
void SmoothFilter::calculateOutputData | ( | double * | X, |
double * | Y | ||
) | [private, virtual] |
Calculates the data for the output curve and store it in the X an Y vectors.
Reimplemented from Filter.
References Filter::d_explanation, d_f, d_iterations, d_method, Filter::d_points, d_smooth_points, Filter::d_x, Filter::d_y, smoothAverage(), smoothFFT(), smoothLowess(), and smoothSavGol().
void SmoothFilter::init | ( | int | m | ) | [private] |
References Filter::d_n, Filter::d_points, d_polynom_order, d_sav_gol_points, d_smooth_points, and setMethod().
int SmoothFilter::method | ( | ) | [inline] |
References d_method.
int SmoothFilter::savitzkyGolayCoefficients | ( | int | points, |
int | polynom_order, | ||
gsl_matrix * | h | ||
) | [static, private] |
Compute Savitzky-Golay coefficients and store them into #h.
This function follows GSL conventions in that it writes its result into a matrix allocated by the caller and returns a non-zero result on error.
The coefficient matrix is defined as the matrix H mapping a set of input values to the values of the polynomial of order #polynom_order which minimizes squared deviations from the input values. It is computed using the formula $H=V(V^TV)^(-1)V^T$, where $V$ is the Vandermonde matrix of the point indices.
For a short description of the mathematical background, see http://www.statistics4u.info/fundstat_eng/cc_filter_savgol_math.html
References Filter::error().
Referenced by smoothSavGol().
void SmoothFilter::setLowessParameter | ( | double | f, |
int | iterations | ||
) |
References d_f, Filter::d_init_err, d_iterations, d_method, and Lowess.
Referenced by SmoothCurveDialog::smooth().
void SmoothFilter::setMethod | ( | int | m | ) |
References Filter::d_init_err, and d_method.
Referenced by init().
void SmoothFilter::setPolynomOrder | ( | int | order | ) |
Sets the polynomial order in the Savitky-Golay algorithm.
References Filter::d_init_err, d_method, d_polynom_order, d_sav_gol_points, d_smooth_points, and SavitzkyGolay.
Referenced by SmoothCurveDialog::smooth().
void SmoothFilter::setSmoothPoints | ( | int | points, |
int | left_points = 0 |
||
) |
References Filter::d_init_err, d_polynom_order, d_sav_gol_points, and d_smooth_points.
Referenced by SmoothCurveDialog::smooth().
void SmoothFilter::smoothAverage | ( | double * | x, |
double * | y | ||
) | [private] |
References Filter::d_n, and d_smooth_points.
Referenced by calculateOutputData().
void SmoothFilter::smoothFFT | ( | double * | x, |
double * | y | ||
) | [private] |
References Filter::d_n, d_smooth_points, and Filter::d_x.
Referenced by calculateOutputData().
void SmoothFilter::smoothLowess | ( | double * | x, |
double * | y | ||
) | [private] |
References clowess(), d_f, d_iterations, and Filter::d_n.
Referenced by calculateOutputData().
void SmoothFilter::smoothSavGol | ( | double * | x, |
double * | y_inout | ||
) | [private] |
Savitzky-Golay smoothing of (uniformly distributed) data.
When the data is not uniformly distributed, Savitzky-Golay looses its interesting conservation properties. On the other hand, a central point of the algorithm is that for uniform data, the operation can be implemented as a convolution.
There are at least three possible approaches to handling edges of the data vector (cutting them off, zero padding and using the left-/rightmost smoothing polynomial for computing smoothed values near the edges). Zero-padding is a particularly bad choice for signals with a distinctly non-zero baseline and cutting off edges makes further computations on the original and smoothed signals more difficult; therefore, deviating from the user-specified number of left/right adjacent points (by smoothing over a fixed window at the edges) would be the least annoying alternative;
References Filter::d_n, d_polynom_order, d_sav_gol_points, d_smooth_points, Filter::error(), Filter::memoryErrorMessage(), and savitzkyGolayCoefficients().
Referenced by calculateOutputData().
double SmoothFilter::d_f [private] |
Parameter f for the Lowess algorithm.
Referenced by calculateOutputData(), setLowessParameter(), and smoothLowess().
int SmoothFilter::d_iterations [private] |
Number of iterations for the Lowess algorithm.
Referenced by calculateOutputData(), setLowessParameter(), and smoothLowess().
SmoothMethod SmoothFilter::d_method [private] |
The smooth method.
Referenced by calculateOutputData(), method(), setLowessParameter(), setMethod(), and setPolynomOrder().
int SmoothFilter::d_polynom_order [private] |
Polynomial order in the Savitky-Golay algorithm (see Numerical Receipes in C for details).
Referenced by init(), setPolynomOrder(), setSmoothPoints(), and smoothSavGol().
int SmoothFilter::d_sav_gol_points [private] |
The number of left adjacents points used by the Savitky-Golay algorithm.
Referenced by init(), setPolynomOrder(), setSmoothPoints(), and smoothSavGol().
int SmoothFilter::d_smooth_points [private] |
The number of adjacents points used to smooth the data set.
Referenced by calculateOutputData(), init(), setPolynomOrder(), setSmoothPoints(), smoothAverage(), smoothFFT(), and smoothSavGol().