File indexing completed on 2024-12-22 04:18:07

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *   copyright : (C) 2005  University of British Columbia                  *
0006  *                   dscott@phas.ubc.ca                                    *
0007  *                                                                         *
0008  *   This program is free software; you can redistribute it and/or modify  *
0009  *   it under the terms of the GNU General Public License as published by  *
0010  *   the Free Software Foundation; either version 2 of the License, or     *
0011  *   (at your option) any later version.                                   *
0012  *                                                                         *
0013  ***************************************************************************/
0014 
0015 #ifndef PERIODOGRAMPLUGIN_H
0016 #define PERIODOGRAMPLUGIN_H
0017 
0018 #include <QFile>
0019 
0020 #include <basicplugin.h>
0021 #include <dataobjectplugin.h>
0022 
0023 class PeriodogramSource : public Kst::BasicPlugin {
0024   Q_OBJECT
0025 
0026   public:
0027     virtual QString _automaticDescriptiveName() const;
0028 
0029     Kst::VectorPtr vectorTime() const;
0030     Kst::VectorPtr vectorData() const;
0031     Kst::ScalarPtr scalarOversampling() const;
0032     Kst::ScalarPtr scalarANFF() const;
0033 
0034     virtual void change(Kst::DataObjectConfigWidget *configWidget);
0035 
0036     void setupOutputs();
0037     virtual bool algorithm();
0038 
0039     virtual QStringList inputVectorList() const;
0040     virtual QStringList inputScalarList() const;
0041     virtual QStringList inputStringList() const;
0042     virtual QStringList outputVectorList() const;
0043     virtual QStringList outputScalarList() const;
0044     virtual QStringList outputStringList() const;
0045 
0046     virtual void saveProperties(QXmlStreamWriter &s);
0047 
0048   protected:
0049     PeriodogramSource(Kst::ObjectStore *store);
0050     ~PeriodogramSource();
0051 
0052   private:
0053     int max(int a, int b);
0054     int min(int a, int b);
0055     void spread(double y, double yy[], unsigned long n, double x, int m);
0056     void four1(double data[], unsigned long nn, int isign);
0057     void realft(double data[], unsigned long n, int isign);
0058     void avevar(double const  data[], unsigned long n, double* ave, double* var);
0059     void FastLombPeriodogram(
0060       double const x[],
0061       double const y[],
0062       unsigned long   n,
0063       double          ofac,
0064       double          hifac,
0065       double          wk1[],
0066       double          wk2[],
0067       unsigned long   ndim,
0068       unsigned long*  nout,
0069       unsigned long*  jmax,
0070       double*         prob,
0071       double*         pvar,
0072       int            iIsWindowFunction);
0073     void SlowLombPeriodogram(
0074       double const    x[],
0075       double const    y[],
0076       unsigned long   n,
0077       double          ofac,
0078       double          hifac,
0079       double          px[],
0080       double          py[],
0081       unsigned long   ndim,
0082       unsigned long*  nout,
0083       unsigned long*  jmax,
0084       double*         prob,
0085       double*         pvar,
0086       int            iIsWindowFunction);
0087 
0088   friend class Kst::ObjectStore;
0089 
0090 
0091 };
0092 
0093 
0094 class PeriodogramPlugin : public QObject, public Kst::DataObjectPluginInterface {
0095     Q_OBJECT
0096     Q_INTERFACES(Kst::DataObjectPluginInterface)
0097     Q_PLUGIN_METADATA(IID "com.kst.DataObjectPluginInterface/2.0")
0098   public:
0099     virtual ~PeriodogramPlugin() {}
0100 
0101     virtual QString pluginName() const;
0102     virtual QString pluginDescription() const;
0103 
0104     virtual DataObjectPluginInterface::PluginTypeID pluginType() const { return Generic; }
0105 
0106     virtual bool hasConfigWidget() const { return true; }
0107 
0108     virtual Kst::DataObject *create(Kst::ObjectStore *store, Kst::DataObjectConfigWidget *configWidget, bool setupInputsOutputs = true) const;
0109 
0110     virtual Kst::DataObjectConfigWidget *configWidget(QSettings *settingsObject) const;
0111 };
0112 
0113 #endif
0114 // vim: ts=2 sw=2 et