[Kst] branches/work/kst/1.5/kst/src/libkstmath
Andrew Walker
arwalker at sumusltd.com
Sat Jul 28 02:07:12 CEST 2007
SVN commit 693445 by arwalker:
add ability to set interpolation of holes option for spectrograms
M +40 -16 kstcsd.cpp
M +16 -15 kstcsd.h
--- branches/work/kst/1.5/kst/src/libkstmath/kstcsd.cpp #693444:693445
@@ -47,14 +47,14 @@
: KstDataObject() {
commonConstructor(in_tag, in_V, in_freq, in_average, in_removeMean,
in_apodize, in_apodizeFxn, in_windowSize, in_averageLength, in_gaussianSigma,
- in_vectorUnits, in_rateUnits, in_outputType, in_V->tagName());
+ in_vectorUnits, in_rateUnits, in_outputType, false, in_V->tagName());
setDirty();
}
KstCSD::KstCSD(const QDomElement &e)
: KstDataObject(e) {
-
+
QString in_tag;
QString vecName;
QString in_vectorUnits, in_rateUnits;
@@ -68,7 +68,8 @@
int in_windowSize = 5000;
double in_gaussianSigma = 3.0;
PSDType in_outputType = PSDAmplitudeSpectralDensity;
-
+ bool interpolateHoles = false;
+
QDomNode n = e.firstChild();
while (!n.isNull()) {
QDomElement e = n.toElement(); // try to convert the node to an element.
@@ -99,24 +100,26 @@
in_rateUnits = e.text();
} else if (e.tagName() == "output") {
in_outputType = (PSDType)e.text().toInt();
+ } else if (e.tagName() == "interpolateHoles") {
+ interpolateHoles = e.text().toInt() != 0;
}
}
n = n.nextSibling();
}
-
+
_inputVectorLoadQueue.append(qMakePair(INVECTOR, vecName));
-
+
commonConstructor(in_tag, in_V, in_freq, in_average, in_removeMean,
in_apodize, in_apodizeFxn, in_windowSize, in_averageLength, in_gaussianSigma,
- in_vectorUnits, in_rateUnits, in_outputType, vecName);
+ in_vectorUnits, in_rateUnits, in_outputType, interpolateHoles, vecName);
}
-void KstCSD::commonConstructor(const QString& in_tag, KstVectorPtr in_V,
- double in_freq, bool in_average, bool in_removeMean, bool in_apodize,
- ApodizeFunction in_apodizeFxn, int in_windowSize, int in_averageLength,
- double in_gaussianSigma, const QString& in_vectorUnits,
- const QString& in_rateUnits, PSDType in_outputType, const QString& vecName) {
+void KstCSD::commonConstructor(const QString& in_tag, KstVectorPtr in_V, double in_freq, bool in_average,
+ bool in_removeMean, bool in_apodize, ApodizeFunction in_apodizeFxn, int in_windowSize,
+ int in_averageLength, double in_gaussianSigma, const QString& in_vectorUnits,
+ const QString& in_rateUnits, PSDType in_outputType, bool in_interpolateHoles,
+ const QString& vecName) {
_typeString = i18n("Spectrogram");
_type = "Spectrogram";
_inputVectors[INVECTOR] = in_V;
@@ -132,6 +135,7 @@
_vectorUnits = in_vectorUnits;
_rateUnits = in_rateUnits;
_outputType = in_outputType;
+ _interpolateHoles = in_interpolateHoles;
if (_frequency <= 0.0) {
_frequency = 1.0;
@@ -203,8 +207,8 @@
break; //If there isn't enough left for a complete window.
}
- _psdCalculator.calculatePowerSpectrum(input + i, _windowSize, tempOutput, tempOutputLen, _removeMean, false, _average, _averageLength, _apodize, _apodizeFxn, _gaussianSigma, _outputType, _frequency);
-
+ _psdCalculator.calculatePowerSpectrum(input + i, _windowSize, tempOutput, tempOutputLen, _removeMean, _interpolateHoles, _average, _averageLength, _apodize, _apodizeFxn, _gaussianSigma, _outputType, _frequency);
+
// resize output matrix
(*_outMatrix)->resize(xSize+1, tempOutputLen);
@@ -242,6 +246,7 @@
ts << l2 << "<average>" << _average << "</average>" << endl;
ts << l2 << "<fftLen>" << int(ceil(log(double(_PSDLen*2)) / log(2.0))) << "</fftLen>" << endl;
ts << l2 << "<removeMean>" << _removeMean << "</removeMean>" << endl;
+ ts << l2 << "<interpolateHoles>" << _interpolateHoles << "</interpolateHoles>" << endl;
ts << l2 << "<apodize>" << _apodize << "</apodize>" << endl;
ts << l2 << "<apodizefxn>" << _apodizeFxn << "</apodizefxn>" << endl;
ts << l2 << "<windowsize>" << _windowSize << "</windowsize>" << endl;
@@ -354,19 +359,36 @@
}
}
+
ApodizeFunction KstCSD::apodizeFxn() const {
return _apodizeFxn;
-}
+}
+
void KstCSD::setApodizeFxn(ApodizeFunction in_fxn) {
setDirty();
_apodizeFxn = in_fxn;
}
+
+bool KstCSD::interpolateHoles() const {
+ return _interpolateHoles;
+}
+
+
+void KstCSD::setInterpolateHoles(bool interpolate) {
+ if (interpolate != _interpolateHoles) {
+ _interpolateHoles = interpolate;
+ setDirty();
+ }
+}
+
+
int KstCSD::length() const {
return _averageLength;
}
+
void KstCSD::setLength(int in_length) {
_averageLength = in_length;
}
@@ -382,10 +404,12 @@
_windowSize = in_size;
}
+
double KstCSD::gaussianSigma() const {
return _gaussianSigma;
}
+
void KstCSD::setGaussianSigma(double in_sigma) {
setDirty();
_gaussianSigma = in_sigma;
@@ -393,12 +417,12 @@
KstMatrixPtr KstCSD::outputMatrix() const {
- return *_outMatrix;
+ return *_outMatrix;
}
const QString& KstCSD::vectorUnits() const {
- return _vectorUnits;
+ return _vectorUnits;
}
--- branches/work/kst/1.5/kst/src/libkstmath/kstcsd.h #693444:693445
@@ -15,9 +15,6 @@
* *
***************************************************************************/
-/** A class for handling Spectrograms for kst
- */
-
#ifndef KSTCSD_H
#define KSTCSD_H
@@ -39,7 +36,7 @@
virtual void save(QTextStream& ts, const QString& indent = QString::null);
virtual QString propertyString() const;
-
+
QString vTag() const;
void setVector(KstVectorPtr);
@@ -59,30 +56,33 @@
double freq() const;
void setFreq(double in_freq);
-
+
ApodizeFunction apodizeFxn() const;
void setApodizeFxn(ApodizeFunction in_fxn);
-
+
double gaussianSigma() const;
void setGaussianSigma(double in_sigma);
-
+
int windowSize() const;
void setWindowSize(int in_size);
-
+
int length() const;
void setLength(int in_length);
-
+
const QString& vectorUnits() const;
void setVectorUnits(const QString& units);
-
+
const QString& rateUnits() const;
void setRateUnits(const QString& units);
-
+
PSDType output() const;
void setOutput(PSDType in_outputType);
-
+
+ bool interpolateHoles() const;
+ void setInterpolateHoles(bool interpolate);
+
KstMatrixPtr outputMatrix() const;
-
+
virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap& duplicatedMap);
private:
@@ -90,12 +90,13 @@
bool in_removeMean, bool in_apodize, ApodizeFunction in_apodizeFxn,
int in_windowSize, int in_length, double in_gaussianSigma,
const QString& in_vectorUnits, const QString& in_rateUnits,
- PSDType in_outputType, const QString& vecName);
+ PSDType in_outputType, bool interpolateHoles, const QString& vecName);
void updateMatrixLabels();
-
+
double _frequency;
bool _average;
+ bool _interpolateHoles;
bool _removeMean;
bool _apodize;
ApodizeFunction _apodizeFxn;
More information about the Kst
mailing list