GWOLLUM  4.2.0
Tools for gravitational-wave analyses
Sample Class Reference

Transform discrete time series. More...

#include <Sample.h>

Inheritance diagram for Sample:
Collaboration diagram for Sample:

Public Member Functions

double GetHighPassFrequency (void)
 Returns the current highpass frequency. More...
 
unsigned int GetNativeFrequency (void)
 Returns the current native sampling frequency [Hz]. More...
 
unsigned int GetWindowSize (void)
 Returns the window size (=0 if no windowing). More...
 
unsigned int GetWorkingFrequency (void)
 Returns the current working sampling frequency [Hz]. More...
 
void SetDCRemoval (const bool aDCremove=true)
 Activates/Deactivates the DC removal. More...
 
bool SetFrequencies (const unsigned int aNativeFrequency, const unsigned int aWorkingFrequency, const double aHighPassFrequency=0.0)
 Defines frequencies for the transformation. More...
 
bool SetHighPassFrequency (const double aHighPassFrequency)
 Defines a highpass frequency. More...
 
bool SetNativeFrequency (const int aNativeFrequency)
 Sets a new native sampling frequency. More...
 
void SetWindow (const unsigned int aWindowSize, double *aWindow)
 Defines the window. More...
 
bool SetWorkingFrequency (const unsigned int aWorkingFrequency)
 Sets a new working sampling frequency. More...
 
bool Transform (const unsigned int aInSize, double *aInData, const unsigned int aOutSize, double *aOutData)
 Transforms data. More...
 
Constructors and destructors
 Sample (const unsigned int aVerbosity=0)
 Constructor of the Sample class. More...
 
virtual ~Sample (void)
 Destructor of the Sample class. More...
 

Protected Attributes

double fHighPassFrequency
 Cutoff frequency. More...
 
unsigned int fNativeFrequency
 Native sampling frequency. More...
 
bool fRemoveDC
 DC removal flag. More...
 
unsigned int fVerbosity
 Verbosity level. More...
 
double * fWindow
 Window. More...
 
unsigned int fWindowSize
 Window size. More...
 
unsigned int fWorkingFrequency
 Working sampling frequency. More...
 

Private Member Functions

void HighPass (const unsigned int aSize, double *aData)
 Highpasses the data. More...
 
void MakeHighPassFilters (void)
 Constructs the highpass filters. More...
 
void MakeSamplingFilters (void)
 Constructs the re-sampling filters. More...
 
void PreSample (unsigned int &aSize, double *aData)
 Pre-samples the data. More...
 
void RemoveDC (const unsigned int aSize, double *aData)
 Removes the DC component. More...
 
void Resample (unsigned int aSize, double *aInData, double *aOutData)
 Re-samples the data. More...
 

Private Attributes

unsigned int fIntermediateFrequency
 Intermediate sampling frequency. More...
 
unsigned int fResampleFactor
 Resampling factor (>=1). More...
 
IIRFilteriirFilter [NORDER]
 Downsampling filters. More...
 
IIRFilteriirFilterHP [NORDERHP]
 Highpass filters. More...
 
bool presample
 Pre-sample flag. More...
 

Detailed Description

Transform discrete time series.

A timeseries, sampled at a native frequency is transformed in the time domain. Supported transformations (in this order):

  • Remove DC frequency
  • High-pass filter (order=12)
  • Window the data
  • Resample to a working frequency

Once the transformations are configured, call Transform() to transform your timeseries.

Author
Florent Robinet

Constructor & Destructor Documentation

◆ Sample()

Sample::Sample ( const unsigned int  aVerbosity = 0)

Constructor of the Sample class.

Parameters
[in]aVerbosityVerbosity level.

◆ ~Sample()

Sample::~Sample ( void  )
virtual

Destructor of the Sample class.

Member Function Documentation

◆ GetHighPassFrequency()

double Sample::GetHighPassFrequency ( void  )
inline

Returns the current highpass frequency.

◆ GetNativeFrequency()

unsigned int Sample::GetNativeFrequency ( void  )
inline

Returns the current native sampling frequency [Hz].

◆ GetWindowSize()

unsigned int Sample::GetWindowSize ( void  )
inline

Returns the window size (=0 if no windowing).

◆ GetWorkingFrequency()

unsigned int Sample::GetWorkingFrequency ( void  )
inline

Returns the current working sampling frequency [Hz].

◆ HighPass()

void Sample::HighPass ( const unsigned int  aSize,
double *  aData 
)
private

Highpasses the data.

The data vector, sampled at the native frequency, is highpassed.

Parameters
[in]aSizeData vector size.
[in,out]aDataPointer to the data vector.

◆ MakeHighPassFilters()

void Sample::MakeHighPassFilters ( void  )
private

Constructs the highpass filters.

Using Highpass frequency and Native frequency.

◆ MakeSamplingFilters()

void Sample::MakeSamplingFilters ( void  )
private

Constructs the re-sampling filters.

Using Native frequency and Working frequency.

◆ PreSample()

void Sample::PreSample ( unsigned int &  aSize,
double *  aData 
)
private

Pre-samples the data.

The input data vector is resampled to the power-of-two just below.

Note
The output vector size does not change. However, the returned size gets smaller!
Parameters
[in,out]aSizeData vector size.
[in,out]aDataPointer to the data vector.

◆ RemoveDC()

void Sample::RemoveDC ( const unsigned int  aSize,
double *  aData 
)
private

Removes the DC component.

Parameters
[in]aSizeData vector size.
[in,out]aDataPointer to the data vector.

◆ Resample()

void Sample::Resample ( unsigned int  aSize,
double *  aInData,
double *  aOutData 
)
private

Re-samples the data.

The input data vector, sampled at the native frequency, is resampled to the working frequency.

Warning
The output vector must be the right size (fWorkingFrequency)!
Parameters
[in]aSizeInput data vector size.
[in]aInDataPointer to the input data vector.
[out]aOutDataPointer to the output data vector.

◆ SetDCRemoval()

void Sample::SetDCRemoval ( const bool  aDCremove = true)
inline

Activates/Deactivates the DC removal.

The DC component is computed and is subtracted from all data samples. The final vector has a DC component equal to 0.

Parameters
[in]aDCremoveActivate/deactivate the DC removal.

◆ SetFrequencies()

bool Sample::SetFrequencies ( const unsigned int  aNativeFrequency,
const unsigned int  aWorkingFrequency,
const double  aHighPassFrequency = 0.0 
)

Defines frequencies for the transformation.

It is possible to work with a sampling frequency smaller than the native frequency, often for performance reasons. It must be an integer value and a power of 2. When transformed (see Transform()), the input data are first downsampled to the working frequency with an anti-aliasing filter.

It is also possible to highpass the data before downsampling.

Parameters
[in]aNativeFrequencyNative sampling frequency [Hz].
[in]aWorkingFrequencyWorking sampling frequency [Hz].
[in]aHighPassFrequencyHighpass frequency [Hz].
Returns
true if the frequencies were successfuly changed, false otherwise.

◆ SetHighPassFrequency()

bool Sample::SetHighPassFrequency ( const double  aHighPassFrequency)
inline

Defines a highpass frequency.

It is possible to highpass the data. This function sets a new highpass frequency. When transformed (see Transform()), the input data are filtered.

Parameters
[in]aHighPassFrequencyHighpass frequency [Hz].
Returns
true if the frequency was successfuly changed, false otherwise.

◆ SetNativeFrequency()

bool Sample::SetNativeFrequency ( const int  aNativeFrequency)
inline

Sets a new native sampling frequency.

Parameters
[in]aNativeFrequencyNew native sampling frequency [Hz].
Returns
true if the frequency was successfuly changed, false otherwise.

◆ SetWindow()

void Sample::SetWindow ( const unsigned int  aWindowSize,
double *  aWindow 
)
inline

Defines the window.

Parameters
[in]aWindowSizeWindow size: it must match the size of input data when calling Transform().
[in]aWindowArray of window values.

◆ SetWorkingFrequency()

bool Sample::SetWorkingFrequency ( const unsigned int  aWorkingFrequency)
inline

Sets a new working sampling frequency.

It is possible to work with a sampling frequency smaller than the native frequency, often for performance reasons. This function sets a new working frequency. It must be an integer value and a power of 2. When transformed (see Transform()), the input data are first downsampled to the working frequency with an anti-aliasing filter.

Parameters
[in]aWorkingFrequencyNew working sampling frequency [Hz].
Returns
true if the frequency was successfuly changed, false otherwise.

◆ Transform()

bool Sample::Transform ( const unsigned int  aInSize,
double *  aInData,
const unsigned int  aOutSize,
double *  aOutData 
)

Transforms data.

The input data vector (time-domain) is transformed in this order:

The input and output vectors must have an integer duration.

Warning
The window is set with SetWindow(). The window size must match the input data size.
The memory for the output vector must be allocated with the right size before calling this function. No size check will be performed and the data size provided by the user will be trusted.
The input vector can be altered in case of presampling. Do not use after calling this function.
Parameters
[in]aInSizeInput vector size.
[in]aInDataInput vector.
[in]aOutSizeOutput vector size.
[in]aOutDataOutput vector.

Member Data Documentation

◆ fHighPassFrequency

double Sample::fHighPassFrequency
protected

Cutoff frequency.

◆ fIntermediateFrequency

unsigned int Sample::fIntermediateFrequency
private

Intermediate sampling frequency.

◆ fNativeFrequency

unsigned int Sample::fNativeFrequency
protected

Native sampling frequency.

◆ fRemoveDC

bool Sample::fRemoveDC
protected

DC removal flag.

◆ fResampleFactor

unsigned int Sample::fResampleFactor
private

Resampling factor (>=1).

◆ fVerbosity

unsigned int Sample::fVerbosity
protected

Verbosity level.

◆ fWindow

double* Sample::fWindow
protected

Window.

◆ fWindowSize

unsigned int Sample::fWindowSize
protected

Window size.

◆ fWorkingFrequency

unsigned int Sample::fWorkingFrequency
protected

Working sampling frequency.

◆ iirFilter

IIRFilter* Sample::iirFilter[NORDER]
private

Downsampling filters.

◆ iirFilterHP

IIRFilter* Sample::iirFilterHP[NORDERHP]
private

Highpass filters.

◆ presample

bool Sample::presample
private

Pre-sample flag.


The documentation for this class was generated from the following files: