Search:
wiki:fir
Last modified 18 months ago Last modified on 03/25/12 13:49:41

# Earthworm Module: fir

Contributed by:

## Function

Implements a general-purpose FIR filter for trace data.

## Details

The fir module implements a general-purpose FIR filter routine to process wave data (TYPE_TRACEBUF2) coming from the InRing defined in decimate.d. Decimated trace messages are written to the OutRing with their SCNs changed as specified in fir.d. The filtered trace message retains its TYPE_TRACEBUF2 type, but it (normally) has a new SCNL name. This module can be configured as a low-pass, high-pass, multi-band pass or notch filter. By using multiple Band commands in the configuration file any of these filter types can be specified.

This FIR filter causes considerable time delay in the data. Fortunately filter has linear phase so the delay does not change the shape of the wave. This delay is removed by adjusting the timestamp of the output data, resulting in zero phase delay. Note that there will be small precursory artifacts before impulsive wave arrivals. See "Of Poles and Zeros" by Frank Scherbaum for more details. The FIR filter coefficients are determined using the Remez Exchange algorithm. This produces an equi-ripple filter. The coefficients and zeroes of the filter, as well as the effective delay, are logged on startup. (FIR filters have no poles.)

### Example Configuration File

    #
    #                     Configuration File for Fir
    #
    MyModId          MOD_FIR
    InRing           WAVE_RING       # Transport ring to find waveform data on,
    OutRing          WAVE_RING       # Transport ring to write output to,
                                     # InRing and OutRing may be the same.
    HeartBeatInterval     30         # Heartbeat interval, in seconds,
    LogFile            1             # 1 -> Keep log, 0 -> no log file
    #Debug		 		 # Write out debug messages (optional)

    MaxGap              1.5         # Maximum gap, in sample periods, allowed
                                    # between trace data points.
                                    # When exceeded, channel is restarted.

    # Specify the filter frequency response characteristics with two or more
    # commands fo the form: Band
    #
    # where:
    #   f_low = low frequency limit of a band
    #   f_high = high frequency limit of a band
    #   level = desired level of the band: 1 for pass band, 0 for stop band
    #   deviation = amount of ripple allowed from desired level
    #
    # All frequencies specified must be in the range 0.0 - 1.0, where 1.0
    # corresponds to the Nyquist frequency. (Nyquist frequency is half the sample
    # rate and is the maximum frequency content that can be in a time series.)
    # One band must start at 0.0 frequency; one band must end at 1.0 frequency. Any
    # number of additional bands may be specified (up to a total of ten bands.)
    Band 0.0 0.3 1 0.005
    Band 0.4 1.0 0 0.005

    # If you want Fir to compute and log its filter coefficients and then
    # exit, specify "TestMode".
    #TestMode

    # NEW OPTIONAL SETTINGS FOR Earthworm release 7.5
    # optional setting to allow a queue buffer size larger than 100 messages, defaults to 100
    QueueSize 2000
    # optional setting to allow a shorter sleep between ring pollings, defaults to 500
    SleepMilliSeconds 50

     #
    # Specify logos of the messages to grab from the InRing.
    # TYPE_TRACEBUF is assumed, therefore only module ID and
    # installation ID need to be specified
    #
    GetWavesFrom    INST_WILDCARD MOD_WILDCARD  # TYPE_TRACEBUF (assumed)

    #
    # List SCNL codes of trace messages to fir and their output SCNL codes
    # Wildcard characters are not allowed here.
    #
    #        IN-SCNL     OUT-SCNL
    GetSCNL TEST EHZ UW --  TEST EWZ UW --

## Helpful Hints

### Download in other formats:

- Plain Text