1 /***************************************************************************
2                           psd.h: Power Spectra for KST
3                              -------------------
4     begin                : Fri Feb 10 2002
5     copyright            : (C) 2002 by C. Barth Netterfield
6     email                : netterfield@astro.utoronto.ca
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 /** A class for handling power spectra for kst
19  *@author C. Barth Netterfield
20  */
21 
22 #ifndef PSD_H
23 #define PSD_H
24 
25 #include "dataobject.h"
26 #include "psdcalculator.h"
27 #include "kstmath_export.h"
28 
29 namespace Kst {
30 
31 class ObjectStore;
32 
33 class KSTMATH_EXPORT PSD : public DataObject {
34   Q_OBJECT
35 
36   public:
37     static const QString staticTypeString;
38     static const QString staticTypeTag;
typeString()39     const QString& typeString() const { return staticTypeString; }
40 
41     virtual void save(QXmlStreamWriter &s);
42     virtual QString propertyString() const;
43 
44     bool apodize() const;
45     void setApodize(bool in_apodize);
46 
47     ApodizeFunction apodizeFxn() const;
48     void setApodizeFxn(ApodizeFunction in_apodizeFxn);
49 
50     double gaussianSigma() const;
51     void setGaussianSigma(double in_gaussianSigma);
52 
53     bool removeMean() const;
54     void setRemoveMean(bool in_removeMean);
55 
56     bool average() const;
57     void setAverage(bool in_average);
58 
59     double frequency() const;
60     void setFrequency(double in_frequency);
61 
62     int length() const;
63     void setLength(int in_length);
64 
65     void setVector(VectorPtr);
66     VectorPtr vector() const;
67 
68     const QString& vectorUnits() const;
69     void setVectorUnits(const QString& units);
70 
71     const QString& rateUnits() const;
72     void setRateUnits(const QString& units);
73 
74     PSDType output() const;
75     void setOutput(PSDType in_output);
76 
77     virtual bool slaveVectorsUsed() const;
78 
79     virtual void showNewDialog();
80     virtual void showEditDialog();
81 
vX()82     VectorPtr vX() const { return _fVector; }
vY()83     VectorPtr vY() const { return _sVector; }
84 
85     const CurveHintList *curveHints() const;
86 
87     virtual DataObjectPtr makeDuplicate() const;
88 
89     virtual QString descriptionTip() const;
90 
91     void change(VectorPtr in_V,
92         double freq, bool average, int average_len, bool apodize, bool removeMean,
93         const QString& VUnits, const QString& RUnits, ApodizeFunction in_apodizeFxn = WindowOriginal,
94         double in_gaussianSigma = 3.0, PSDType in_output = PSDAmplitudeSpectralDensity);
95     virtual void internalUpdate();
96 
setChanged()97     void setChanged() { _changed=true;}
98 
99     virtual ScriptInterface* createScriptInterface();
100 
101   protected:
102 
103     PSD(ObjectStore *store);
104     virtual ~PSD();
105 
106     friend class ObjectStore;
107 
108     virtual QString _automaticDescriptiveName() const;
109     virtual void _initializeShortName();
110 
111   private:
112     void updateVectorLabels();
113 
114     void _adjustLengths();
115     ApodizeFunction _apodizeFxn;
116     double _gaussianSigma;
117     bool _Apodize;
118     bool _RemoveMean;
119     bool _Average;
120     PSDType _Output;
121     PSDType _prevOutput;
122     int _last_n_subsets;
123     int _last_n_new;
124     int _last_n;
125     double _Frequency;
126 
127     int _PSDLength;
128     int _averageLength;
129 
130     PSDCalculator _psdCalculator;
131 
132     QString _vectorUnits;
133     QString _rateUnits;
134 
135     VectorPtr _sVector, _fVector;
136     bool _changed;
137 };
138 
139 typedef SharedPtr<PSD> PSDPtr;
140 typedef ObjectList<PSD> PSDList;
141 
142 
143 }
144 
145 #endif
146 // vim: ts=2 sw=2 et
147