In file FIRFilter/FIRFilter.hh:

class FIRFilter : public Pipe

Digital FIR filter implementation API.

Inheritance:


Public Methods

FIRFilter (void)
Default constructor.
FIRFilter (int length, float Sample)
Construct an empty filter instance.
FIRFilter (const FIRFilter& model)
Copy constructor.
virtual ~FIRFilter (void)
Filter destructor.
virtual FIRFilter* clone (void) const
Clone a FIR filter.
void dataCheck (const TSeries& ts) const
Check input data validity.
Time getCurrentTime (void) const
Get the current time.
int getLength (void) const throw()
Get the filter length.
double getRate (void) const throw()
Get the sample rate.
Time getStartTime (void) const
Get the start time.
bool getStat (void) const throw()
Test the history status.
Interval getTimeDelay (void) const
Get the current time.
bool inUse (void) const
Test the filter acitivity status.
void dump (std::ostream& ostr) const throw()
Print the Filter status.
TSeries apply (const TSeries& in)
Filter a Time Series.
TSeries& apply (const TSeries& in, TSeries& out) throw(std::invalid_argument)
Filter a TSeries into an output object.
void apply (int N, const float* in, float* out)
Filter a float array.
void apply (int N, const double* in, double* out)
Filter a float array.
void apply (int N, const fComplex* in, fComplex* out)
Filter a float array.
void reset (void)
Set filter coefficients.
FIRFilter& operator= (const FIRFilter& model) throw()
Copy constructor.
void setCoefs (int N, const double* Coefs) throw()
Set filter coefficients.
void setCoefs (const double* Coefs) throw()
Modify filter coefficients.
void setHistory (int N, const float* Hist=0, Time t=Time(0)) throw()
Set history.
void setHistory (int N, const double* Hist, Time t=Time(0)) throw()
Set history.
void setHistory (int N, const fComplex* Hist, Time t=Time(0)) throw()
Set history.
void setLength (int N) throw()
Set Length.
void setRate (double F) throw()
Set the filter sample Rate.
virtual bool Xfer (fComplex& coeff, double f) const throw()
Get a transfer coefficent of a Filter.
bool Xfer (fComplex* tf, const float* freqs, int points) const throw()
Get the transfer function of a Filter.
FSeries Xfer (float Fmin=0.0, float Fmax=0.0, float dF=1.0) const throw()
Get the transfer function of a Filter.

Protected Methods

bool xfer (fComplex& coeff, double f) const throw()
Get a transfer coefficent of a Filter.

Inherited from Pipe:

Public Methods

virtual TSeries operator)(const TSeries& in)
FilterIO& operator)(const FilterIO& in)
virtual bool isDataValid(const TSeries& in) const
KeyChain& getInputKeys(void) const
KeyChain& getOutputKeys(void) const

Inherited from FilterBase:

Public Methods

virtual bool rootGetStartTime(Time& t) const throw()
virtual bool rootGetCurrentTime(Time& t) const throw()

Documentation

The Filter class object implements a digital FIR filter that can be used to filter time series (TSeries) data. Filter class instances carry the signal history as well as the filter coefficients to prevent the introduction of edge effect when filtering a long series in serveral pieces. Each signal (channel) to be filtered must use a separate Filter instance.
FIRFilter(void)
Default constructor. No coefficient or history storage is allocated.

FIRFilter(int length, float Sample)
A real-valued Order 'length'-1 digital FIR filter is constructed which will operate on data sampled with specified frequency. The filter coefficients remain uninitialized and the history data is cleared.
Parameters:
length - Number of terms (zeros) in the filter.
Sample - Nominal sampling rate.

FIRFilter(const FIRFilter& model)
A filter is constructed with the same length, frequency and coefficients as the argument Filter. The history is zeroed.
Parameters:
model - Filter to be copied.

virtual ~FIRFilter(void)
Destroy the filter object and release any memory allocated for filter coefficients or history information.

virtual FIRFilter* clone(void) const
Create an identical FIR filter and return a pointer to the new filter. The history is zeroed.
Returns:
pointer to an identical filter.

void dataCheck(const TSeries& ts) const
Test whether the TSeries is valid as input data for the filter. a runtime_error exception is thrown if the data are invalid.

Time getCurrentTime(void) const
Get the expected start time of the next TSeries to be filtered.
Returns:
true The current time.

int getLength(void) const throw()
Get the filter length. The filter state is not affected.
Returns:
The filter length (Order+1)

double getRate(void) const throw()
Get the sample rate. The filter state is not affected.
Returns:
The nominal sample rate in Hz.

Time getStartTime(void) const
Get the start time of this filter run. This is set by the first filter operation after the filter has been created or reset.
Returns:
true The start time.

bool getStat(void) const throw()
Tests whether the previous filter operation used valid history data. History data is considered to be valid if the history buffer is full and the start time of the input data is equal to the time stamp on the history data. The filter state is not affected.
Returns:
true if the filter history data was valid for the last operation.

Interval getTimeDelay(void) const
Get the expected start time of the next TSeries to be filtered.
Returns:
true The current time.

bool inUse(void) const
Test the filter acitivity status.
Returns:
true if the filter is being used.

void dump(std::ostream& ostr) const throw()
All filter coefficients and history data are formatted and written to the specified ostream.
Parameters:
ostr - Output stream to receive the Filter info.

TSeries apply(const TSeries& in)
The TSeries is filtered and the result placed in a new TSeries. The resulting TSeries is left on the stack and must be copied to be made permanent. The filter status flag is set if there are insufficient history entries (less than the Filter order) or if the TSeries start time isn't contiguous with the previous data. The input samples are appended to the filter history as the filter response is calculated.
Returns:
A new TSeries containing the filter response to the input series.
Parameters:
in - Time series to be filtered.

TSeries& apply(const TSeries& in, TSeries& out) throw(std::invalid_argument)
The TSeries is filtered and the result stored in a specified output TSeries. The output TSeries must already exist. The filter status flag is set if there are insufficient history entries (less than the Filter order) or if the TSeries start time isn't contiguous with the previous data. The input samples are appended to the filter history as the filter response is calculated.
Returns:
reference to the TSeries containing the filter response.
Parameters:
in - Time series to be filtered.
out - Time series into which the filter response will be stored.

void apply(int N, const float* in, float* out)
An N-point float series is filtered from in and stored in out. in may overlap out. The input samples are appended to the filter history as the filter response is calculated.
Parameters:
N - Number of elements in the input series.
in - Float array containing the input series.
out - Float array to contain the filter response. the end of out may overlap the start of in.

void apply(int N, const double* in, double* out)
An N-point double series is filtered from in and stored in out. in may overlap out. The input samples are appended to the filter history as the filter response is calculated.
Parameters:
N - Number of elements in the input series.
in - Float array containing the input series.
out - Float array to contain the filter response. the end of out may overlap the start of in.

void apply(int N, const fComplex* in, fComplex* out)
An N-point complex series is filtered from in and stored in out. in may overlap out. The input samples are appended to the filter history as the filter response is calculated.
Parameters:
N - Number of elements in the input series.
in - Float array containing the input series.
out - Float array to contain the filter response. the end of out may overlap the start of in.

void reset(void)
Set the filter length and coefficients. The filter history buffer is cleared.
Parameters:
N - Number of coefficients to set.
Coefs - A list of filter coefficients (filter impulse response).

FIRFilter& operator=(const FIRFilter& model) throw()
A filter is constructed with the same length, frequency and coefficients as the argument Filter. The history is zeroed.
Parameters:
model - Filter to be copied.

void setCoefs(int N, const double* Coefs) throw()
Set the filter length and coefficients. The filter history buffer is cleared.
Parameters:
N - Number of coefficients to set.
Coefs - A list of filter coefficients (filter impulse response).

void setCoefs(const double* Coefs) throw()
Modify the filter coefficients without clearing the filter history buffer.
Parameters:
Coefs - A list of filter coefficients (filter impulse response).

void setHistory(int N, const float* Hist=0, Time t=Time(0)) throw()
The specified samples are copied to the Filter history vector. If the number of samples specified is greater than the filter size, only the last Norder samples are used. If the data vector argument is omitted the number of history terms is set as specified and any current data are prefixed with zeroes as needed to fill out the requested number of terms. The history time is optional and represents the time of the latest sample.
Parameters:
N - Number of history elements to preset.
Hist - Filter history vector.
t - Time of the last sample in the history list.

void setHistory(int N, const double* Hist, Time t=Time(0)) throw()
The specified samples are copied to the Filter history vector. If the number of samples specified is greater than the filter size, only the last Norder samples are used. If the data vector argument is omitted the number of history terms is set as specified and any current data are prefixed with zeroes as needed to fill out the requested number of terms. The history time is optional and represents the time of the latest sample.
Parameters:
N - Number of history elements to preset.
Hist - Filter history vector.
t - Time of the last sample in the history list.

void setHistory(int N, const fComplex* Hist, Time t=Time(0)) throw()
The specified samples are copied to the Filter history vector. If the number of samples specified is greater than the filter size, only the last Norder samples are used. If the data vector argument is omitted the number of history terms is set as specified and any current data are prefixed with zeroes as needed to fill out the requested number of terms. The history time is optional and represents the time of the latest sample.
Parameters:
N - Number of history elements to preset.
Hist - Filter history vector.
t - Time of the last sample in the history list.

void setLength(int N) throw()
Set the filter length (order+1). The coefficients and history of the filter are cleared.
Parameters:
N - new filter length.

void setRate(double F) throw()
Set the filter sample Rate.
Parameters:
F - New sample frequency.

virtual bool Xfer(fComplex& coeff, double f) const throw()
The transfer coefficient of the filter at the specified frequency is calculated and returned as a complex number. Filters that support a fast way to compute a transfer coefficient should override xfer rather than this method.
Returns:
true if successful
Parameters:
coeff - a complex number representing the Filter response at the specified frequency (return)
f - Frequency at which to sample the transfer function.

bool Xfer(fComplex* tf, const float* freqs, int points) const throw()
The transfer function of the filter at the specified frequency points is calculated and returned as a complex array. The frequency points are user supplied. The return array must be at least of length points.
Returns:
true if successful
Parameters:
freqs - Frequency points
points - Number of points.
tf - Transfer function (return)

FSeries Xfer(float Fmin=0.0, float Fmax=0.0, float dF=1.0) const throw()
The transfer function of the filter in the specified frequency interval is calculated and returned as a complex frequency series.
Returns:
a complex FSeries containing the Filter response at each frequency step.
Parameters:
Fmin - Minimum frequency at which to sample the transfer function.
Fmax - Maximum frequency at which to sample the transfer function.
dF - Frequency step.

bool xfer(fComplex& coeff, double f) const throw()
The transfer coefficient of the filter at the specified frequency is calculated and returned as a complex number.
Returns:
true if successful
Parameters:
coeff - a complex number representing the Filter response at the specified frequency (return)
f - Frequency at which to sample the transfer function.


Direct child classes:
LPEFilter
Author:
John G. Zweizig
Version:
1.2; Last modified: June 24, 2003

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++