QtiPlot  0.9.8.2
SmoothFilter.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : SmoothFilter.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2007 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Numerical smoothing of data sets
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef SMOOTHFILTER_H
00030 #define SMOOTHFILTER_H
00031 
00032 #include "Filter.h"
00033 #include <gsl/gsl_matrix_double.h>
00034 
00035 class SmoothFilter : public Filter
00036 {
00037 Q_OBJECT
00038 
00039 public:
00040     SmoothFilter(ApplicationWindow *parent, QwtPlotCurve *c, int m = 3);
00041     SmoothFilter(ApplicationWindow *parent, QwtPlotCurve *c, double start, double end, int m = 3);
00042     SmoothFilter(ApplicationWindow *parent, Graph *g, const QString& curveTitle, int m = 3);
00043     SmoothFilter(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end, int m = 3);
00044     SmoothFilter(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int start = 0, int end = -1, int m = 3);
00045 
00046     enum SmoothMethod{SavitzkyGolay = 1, FFT = 2, Average = 3, Lowess = 4};
00047 
00048     int method(){return (int)d_method;};
00049     void setMethod(int m);
00050 
00051     void setSmoothPoints(int points, int left_points = 0);
00053     void setPolynomOrder(int order);
00054     void setLowessParameter(double f, int iterations);
00055 
00056 private:
00057     void init(int m);
00058     void calculateOutputData(double *x, double *y);
00059     void smoothFFT(double *x, double *y);
00060     void smoothAverage(double *x, double *y);
00061     void smoothSavGol(double *x, double *y);
00062     void smoothLowess(double *x, double *y);
00063     static int savitzkyGolayCoefficients(int points, int polynom_order, gsl_matrix *h);
00064 
00066     SmoothMethod d_method;
00067 
00069     int d_smooth_points;
00070 
00072     int d_sav_gol_points;
00073 
00075     int d_polynom_order;
00076 
00078     double d_f;
00079 
00081     int d_iterations;
00082 };
00083 
00084 #endif