edu.harvard.seas.iis.util.dsp
Class LowPassFilter

java.lang.Object
  extended by edu.harvard.seas.iis.util.dsp.LowPassFilter

public class LowPassFilter
extends Object

Implementation of NER and NERD filters from Kaiser, J. F. and Reed, W. A. (1977). Data smoothing using low-pass digital filters. Review of Scientific Instruments, 48(11):1447-1457.

Author:
kgajos

Constructor Summary
LowPassFilter(double[] coefficients)
           
 
Method Summary
static double[] differentiatingFilter(double[] data, double[] coefficients, double timeUnitsPerSample)
          runs a differentiating filter (that also does some smoothing -- otherwise differentiating noisy data amplifies noise)
static double[] filter(double[] data, double[] coefficients)
          runs a filter with given coefficients (no time shifting)
static double filterSingle(double[] data, double[] coefficients, int offset)
          assumes that the length of data and the coefficients array is the same and computes the filtered value for the middle element in the array
static void main(String[] args)
           
static double[] ner(double al, double be, double de, int maxNumCoefs)
          generate coefficients for a smoothing filter (nearly-equal ripple (NER) filter)
static double[] nerd(double al, double be, double de, int maxNumCoefs)
          Generate coefficients for a differentiating filter
 Double onlineFilter(double datum)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LowPassFilter

public LowPassFilter(double[] coefficients)
Method Detail

onlineFilter

public Double onlineFilter(double datum)

filter

public static double[] filter(double[] data,
                              double[] coefficients)
runs a filter with given coefficients (no time shifting)

Parameters:
data - data to be filtered
coefficients - filter coefficients (from the ner filter)
Returns:
filtered data (same size as the original)

filterSingle

public static double filterSingle(double[] data,
                                  double[] coefficients,
                                  int offset)
assumes that the length of data and the coefficients array is the same and computes the filtered value for the middle element in the array

Parameters:
data -
coefficients -
Returns:

differentiatingFilter

public static double[] differentiatingFilter(double[] data,
                                             double[] coefficients,
                                             double timeUnitsPerSample)
runs a differentiating filter (that also does some smoothing -- otherwise differentiating noisy data amplifies noise)

Parameters:
data - input time series
coefficients - filter coefficients (from the nerd filter)
timeUnitsPerSample - sampling interval -- important to make sure that the output of the filter is in correct units (e.g., if input is speed with 100 samples per second and the output is to be in m/s^2, then this param should be 0.01)
Returns:

ner

public static double[] ner(double al,
                           double be,
                           double de,
                           int maxNumCoefs)
generate coefficients for a smoothing filter (nearly-equal ripple (NER) filter)

Parameters:
al - stopband loss in db
be - relative location of stopband; 0 < be < 1 and be = 2*stopband_frequency / sampling_frequency
de - relative width of transition band; 0 < de < 1
maxNumCoefs - maximum number of coefficients to generate (the paper suggests 150)
Returns:

nerd

public static double[] nerd(double al,
                            double be,
                            double de,
                            int maxNumCoefs)
Generate coefficients for a differentiating filter

Parameters:
al - stopband loss in db
be - relative location of stopband; 0 < be < 1 and be = 2*stopband_frequency / sampling_frequency
de - relative width of transition band; 0 < de < 1
maxNumCoefs - maximum number of coefficients to generate (the paper suggests 150)
Returns:

main

public static void main(String[] args)