GPLIB++
Files | Classes | Functions
Time series analysis methods

Files

file  FilterFunc.h
 
file  WFunc.h
 

Classes

class  gplib::SimpleLp
 A simple low pass. More...
 
class  gplib::TimeSeriesComponent
 TimeSeriesComponent is the base storage class for all types of time series data. More...
 
class  gplib::TsSpectrum
 The class CTsSpectrum is used to calculate spectra from (real) time series data. More...
 
struct  gplib::Hamming
 This functor returns the weighting factor for the Hamming window, given the relative position relpos [0..1] in the time series. More...
 
struct  gplib::Hanning
 This functor returns the weighting factor for the Hanning window, given the relative position (0..1) in the time series. More...
 
struct  gplib::Boxcar
 A functor for the simple Boxcar function. More...
 
struct  gplib::Steep
 This functor rises steeply at the edges and then has a wide range where it is unity. More...
 
struct  gplib::CosSq
 The cosine squared windows of fixed width. More...
 
class  gplib::TruncCosSq
 A variable width cosine squared window that is zero outside. More...
 

Functions

double gplib::FreqToW (const double f)
 Transform from frequency domain to w-domain. More...
 
 gplib::SimpleLp::SimpleLp (const double cornerfreq)
 The constructor takes the dimensionless corner frequency, i.e. the corner frequency in Hz times the sampling rate. More...
 
double gplib::SimpleLp::operator() (const double currvalue)
 This version of the operator is suitable for use with std::transform, it returns a filtered value for each call with the current value. More...
 
template<typename _InputIterator , typename _OutputIterator >
void gplib::ShortCorr (_InputIterator masterbegin, _InputIterator masterend, _InputIterator shortbegin, _InputIterator shortend, _OutputIterator outbegin)
 Calculate the correlation between a short time series and a master time series. More...
 
template<typename InputIterator , typename OutputIterator , typename WindowFunctype >
void gplib::StackedSpectrum (InputIterator tsbegin, InputIterator tsend, OutputIterator freqbegin, const size_t seglength, WindowFunctype WFunc)
 This template is used to calculate stacked spectra for example for power spectrum estimation. More...
 
template<typename InputIterator , typename WindowFunctype >
gplib::cmat gplib::TimeFrequency (InputIterator tsbegin, InputIterator tsend, const size_t seglength, WindowFunctype WFunc)
 Calculate a sliding windowed fourier transform for a time series and store the results for each segment in a matrix. More...
 
template<typename InputIterator , typename OutputIterator , typename WindowFunctype >
void gplib::ApplyWindow (InputIterator inbegin, InputIterator inend, OutputIterator outbegin, WindowFunctype WFunc, double relshift=0.0)
 Apply one of the above window functions to a range. More...
 
gplib::rvec gplib::TimeSeriesComponent::GetUblasData ()
 For some methods we prefer to get the data as a ublas vector, we return a copy. More...
 
template<typename _InputIterator , typename _OutputIterator >
void gplib::TsSpectrum::CalcSpectrum (_InputIterator tsbegin, _InputIterator tsend, _OutputIterator freqbegin, _OutputIterator freqend)
 The member function to calculate a spectrum from a time series. More...
 
template<typename _InputIterator , typename _OutputIterator >
void gplib::TsSpectrum::CalcTimeSeries (_InputIterator freqbegin, _InputIterator freqend, _OutputIterator tsbegin, _OutputIterator tsend)
 The member function to calculate a time series from (complex) spectra. More...
 

Detailed Description

Function Documentation

template<typename InputIterator , typename OutputIterator , typename WindowFunctype >
void gplib::ApplyWindow ( InputIterator  inbegin,
InputIterator  inend,
OutputIterator  outbegin,
WindowFunctype  WFunc,
double  relshift = 0.0 
)
inline

Apply one of the above window functions to a range.

Apply one of the above window functions to a range given by the iterators inbegin and outbegin and write the result into a structure through the iterator outbegin, make sure the datastructure can hold enough elements. Input and output structures can be the same.

Definition at line 104 of file WFunc.h.

Referenced by gplib::TimeFrequency().

template<typename _InputIterator , typename _OutputIterator >
void gplib::TsSpectrum::CalcSpectrum ( _InputIterator  tsbegin,
_InputIterator  tsend,
_OutputIterator  freqbegin,
_OutputIterator  freqend 
)

The member function to calculate a spectrum from a time series.

Calculate a spectrum from the input range given by tsbegin and tsend and write to output range given by freqbegin,freqend.

Takes three iterators for input: beginning of input, end of input and beginning of output Make sure the structure pointed to by freqbegin can hold at least (tsend -tsbegin)/2 +1 elements

Calculate the fourier transform of a real valued time series. We specify the start and the end of both structures to be able to check that the output structure can hold enough elements.

Parameters
tsbeginThe iterator to the start of the time series segment
tsendThe iterator to the end of the time series segment
freqbeginThe iterator to the start of the output structure, this has to be able to hold (tsend - tsbegin)/2 + 1 values
freqendThe iterator to the end of the output structure, this has to be able to hold (tsend - tsbegin)/2 + 1 values

Definition at line 80 of file TsSpectrum.h.

References size.

Referenced by gplib::StackedSpectrum(), and gplib::TimeFrequency().

template<typename _InputIterator , typename _OutputIterator >
void gplib::TsSpectrum::CalcTimeSeries ( _InputIterator  freqbegin,
_InputIterator  freqend,
_OutputIterator  tsbegin,
_OutputIterator  tsend 
)

The member function to calculate a time series from (complex) spectra.

Calculate a times series from the input range given by freqbegin and freqend and write to output range given by tsbegin,tsend.

Takes three iterators for input: beginning of input, end of input and beginning of output Make sure the structure pointed to by tsbegin can hold at least (freqend -freqbegin)*2 - 2 elements

Calculate the inverse fourier transfrom from a given complex array/vector. We specify the start and the end of both structures to be able to check that the output structure can hold enough elements.

Parameters
freqbeginThe iterator to the start of the structure holding the spectral elements
freqendThe iterator to the end of the structure holding the spectral elements
tsbeginThe iterator to the start of the output time series structure
tsendThe iterator to the end of the output time series structure

Definition at line 106 of file TsSpectrum.h.

References size.

Referenced by gplib::MultiRecCalc::CalcRecData().

double gplib::FreqToW ( const double  f)

Transform from frequency domain to w-domain.

Definition at line 22 of file FilterFunc.h.

Referenced by gplib::SimpleLp::SimpleLp().

gplib::rvec gplib::TimeSeriesComponent::GetUblasData ( )
inline

For some methods we prefer to get the data as a ublas vector, we return a copy.

We want to make this inline, so it appears in the header.

This function is quite expensive, as the ublas object is generated on the fly and we return a copy.

Definition at line 112 of file TimeSeriesComponent.h.

double gplib::SimpleLp::operator() ( const double  currvalue)
inline

This version of the operator is suitable for use with std::transform, it returns a filtered value for each call with the current value.

Definition at line 54 of file FilterFunc.h.

template<typename _InputIterator , typename _OutputIterator >
void gplib::ShortCorr ( _InputIterator  masterbegin,
_InputIterator  masterend,
_InputIterator  shortbegin,
_InputIterator  shortend,
_OutputIterator  outbegin 
)

Calculate the correlation between a short time series and a master time series.

The short time series will be shifted along the master and the corresponding correlation will be stored in the structure referenced by outpebegin, make sure that structure can hold enough data

Definition at line 18 of file ShortCorr.h.

References gplib::SubMean().

Referenced by CalcCorrAndWrite().

gplib::SimpleLp::SimpleLp ( const double  cornerfreq)
inline

The constructor takes the dimensionless corner frequency, i.e. the corner frequency in Hz times the sampling rate.

Definition at line 42 of file FilterFunc.h.

References gplib::FreqToW().

template<typename InputIterator , typename OutputIterator , typename WindowFunctype >
void gplib::StackedSpectrum ( InputIterator  tsbegin,
InputIterator  tsend,
OutputIterator  freqbegin,
const size_t  seglength,
WindowFunctype  WFunc 
)

This template is used to calculate stacked spectra for example for power spectrum estimation.

The template StackedSpectrum calculates stacked spectra from an input time series. Two input iterators define the input range, one output iterator the start of the output range, we have to provide the length of individual segments and a windowing function. Make sure the container the output is stored in can hold at least seglength/2+1. The Windowing function gets the relative position within the segment and should therefore be defined on the interval 0..1

Definition at line 24 of file StackedSpectrum.h.

References gplib::TsSpectrum::CalcSpectrum(), and gplib::SubMean().

Referenced by CalcPSpecAndWrite(), and main().

template<typename InputIterator , typename WindowFunctype >
gplib::cmat gplib::TimeFrequency ( InputIterator  tsbegin,
InputIterator  tsend,
const size_t  seglength,
WindowFunctype  WFunc 
)

Calculate a sliding windowed fourier transform for a time series and store the results for each segment in a matrix.

This function returns the time-frequency matrix for a real time series

Parameters
tsbeginiterator to the start of the input time series
tsenditerator to the end of the input time series
lengthof segments used for fourier transform in points, if the last segment is longer than the time-series it is discarded
Functionobject for windowing the segments before fourier transform
See Also
WFunc.h for a selection of provided function objects

Definition at line 23 of file TimeFrequency.h.

References gplib::ApplyWindow(), gplib::TsSpectrum::CalcSpectrum(), and gplib::SubMean().

Referenced by gplib::MultiRecCalc::CalcRecData(), and CalcTfAndWrite().