1 #ifndef TIMEFREQUENCY_H_
2 #define TIMEFREQUENCY_H_
22 template<
typename InputIterator,
typename WindowFunctype>
24 const size_t seglength, WindowFunctype WFunc)
26 const size_t insize = distance(tsbegin, tsend);
27 if (insize < seglength)
29 "Time Series shorter than requested segment length");
30 const unsigned int nsegments = insize / seglength;
31 const unsigned int speclength = seglength / 2 + 1;
33 gplib::cmat output(nsegments, speclength);
35 typename std::iterator_traits<InputIterator>::value_type> tinvector;
37 InputIterator currstart = tsbegin;
38 InputIterator currend = tsbegin;
39 advance(currend, seglength);
41 std::vector<std::complex<double> > segspec(speclength);
42 for (
unsigned int i = 0; i < nsegments; ++i)
44 tinvector currseg(currstart, currend);
45 SubMean(currseg.begin(), currseg.end());
46 ApplyWindow(currseg.begin(),currseg.end(),currseg.begin(),WFunc);
48 segspec.begin(), segspec.end());
49 copy(segspec.begin(), segspec.end(), row(output, i).begin());
50 advance(currstart, seglength);
51 advance(currend, seglength);
void SubMean(InputIterator begin, InputIterator end, typename std::iterator_traits< InputIterator >::value_type mean)
Substract the mean from each element in the container, mean is passed as a parameter.
The class CTsSpectrum is used to calculate spectra from (real) time series data.
The basic exception class for all errors that arise in gplib.