Lecture 16: Spectral Filtering: C Christopher S. Bretherton Winter 2015
Lecture 16: Spectral Filtering: C Christopher S. Bretherton Winter 2015
Christopher
c S. Bretherton
Winter 2015
16.1 Introduction
Filtering a time series means removal of the spectral power at some chosen
frequencies while retaining other frequencies. A high-pass filter retains higher
frequencies while removing low frequencies; a low-pass filter does the opposite.
A band-pass filter removes all frequencies outside a prespecified band.
Filters are widely used for digital signal processing (DSP) as well as time
series analysis. In DSP applications, filters must be very efficient and they often
must be causal (rely only on prior data samples to do the filtering in real time).
This lecture will focus on simple Matlab-based filtering approaches for analysis
of time series or spatial data, where these may be less important considerations.
1
Atm S 552 Lecture 16 Bretherton - Winter 2015 2
For a perfect filter, R(f ) = 1 and the filter power |R(f )|2 = 1 for the frequen-
cies being retained and they are zero for the frequencies removed. A Fourier
filter (without tapering) has this ideal characteristic. Other filters alway have
some spectral leakage (spectral power in undesired frequencies) or phase shift
(R(f ) is complex, with nonzero phase).
Here the filter is defined by the weights wp . For instance, for a centered running
mean over a window length (2P + 1)∆t, we would take P1 = −P , P2 = P , and
wp = 1/(2P + 1), p = −P, . . . , P . This is a symmetric filter with equal weights
at positive and negative lags, so does not create phase shifts. A running mean
is often used as a crude low-pass filter, because it is easy to understand.
Unlike a Fourier filter, this filter is localized so the filtered time series uses
only elements of the original time series within a finite range of lags p between
P1 and P2 . Given an ‘impulsive’ input which is zero except at a single time
j = 0 at which it is 1, the filtered time series or impulse response function will
be vp = wp , p = 0, ±1, ±2, ..., which will also be zero except at a finite band of
time lags P1 to P2 , hence the name FIR.
The convolution theorem relates the filter response R(f ) to the weights.
The DFT version of this assumes that periodic extension of the time series
uj , j = 1, . . . , N, beyond its endpoints is used to calculate the convolution sums.
It states that if we define the weight vector
That is, the FIR filter obtained by convolution with w has a response function
given by its DFT:
R(fm ) = ŵm . (16.4.4)
Hence the filter power is proportional to the power spectrum of w. If the filter
is symmetric, it is easy to show ŵ is real, corresponding to R having zero phase
shift at all frequencies.
Matlab script runningmean shows how to use the DFT and the convolution
theorem to calculate the response function and power of a centered running
mean filter of length 2P + 1 = 5, given a window length of 100. One sees that
the running mean filter does a great job of zeroing out signals with f ∆t = 1/5
whose period is 5∆t, but is less efficient in removing most other high-frequency
signals. Thus the running mean is far from being an ideal low-pass filter.
As also shown in the script, a Gaussian smoother wp ∝ exp(−p2 /2P 2 ) with
P ≥ 1 can do a better job of removing high frequencies than can a running-mean
smoother, at the expense of needing to extend the time series somewhat more
to allow filtering near its end points. Such a filter will mainly pass frequencies
f < (2πP ∆t)−1 ; the case shown has P = 1.5.