0% found this document useful (0 votes)
42 views

Lecture 16: Spectral Filtering: C Christopher S. Bretherton Winter 2015

This document discusses spectral filtering of time series data. It introduces different types of filters, including high-pass, low-pass, and band-pass filters. Fourier filtering removes spectral power at chosen frequencies while retaining others by taking the discrete Fourier transform (DFT) of the time series, setting amplitudes of unwanted frequencies to zero, and taking the inverse DFT. Convolution filtering performs a weighted average of the time series using filter weights. The convolution theorem relates the filter response function to the weights. Matlab scripts are provided to demonstrate Fourier and convolution filtering.

Uploaded by

Priyo Tenan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Lecture 16: Spectral Filtering: C Christopher S. Bretherton Winter 2015

This document discusses spectral filtering of time series data. It introduces different types of filters, including high-pass, low-pass, and band-pass filters. Fourier filtering removes spectral power at chosen frequencies while retaining others by taking the discrete Fourier transform (DFT) of the time series, setting amplitudes of unwanted frequencies to zero, and taking the inverse DFT. Convolution filtering performs a weighted average of the time series using filter weights. The convolution theorem relates the filter response function to the weights. Matlab scripts are provided to demonstrate Fourier and convolution filtering.

Uploaded by

Priyo Tenan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lecture 16: Spectral Filtering

Christopher
c S. Bretherton
Winter 2015

Refs: Matlab Signal Processing Toolbox help; Hartmann notes, Chapter 7.

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.

16.2 Fourier filtering


The most obvious filter just uses the definition. If the time series is very long,
truncate or zero-pad it to an efficient length. If needed, detrend or otherwise
massage it so there is a minimal endpoint discontinuity. Then take its DFT,
zero out the Fourier amplitudes of the frequencies that we don’t want (including
corresponding negative frequencies), then take the IDFT to get the filtered time
series. This is also a great way of getting rid of discrete frequencies such as a
daily or annual cycle, as we have already noted.
A variant on this approach is to use windowed DFTs, but this leads to in-
convenient discontinuities in the filtered time series at the edges of the windows.
Fourier filters are great for many types of data analysis, but they are very
nonlocal, involving either periodicity assumptions or weighting all elements in
the time series. This is problematic if we need to filter a finite non-periodic
time series near its end points, in which case more sophisticated approaches are
needed.
The script music2 applies Fourier high (f > 880 Hz), low (f < 440 Hz) and
bandpass filters (440 < f < 880 Hz to our musical segment, to show how their
results look and sound.

1
Atm S 552 Lecture 16 Bretherton - Winter 2015 2

16.3 Filter response


In Fourier space, we can describe a filter by its spectral response function
R(f ). If ûm is the DFT of the original time series uj , and harmonic Mm and
frequency fm = Mm /(N ∆t) correspond to index m, then the DFT of the filtered
time series vj is
v̂m = R(fm )ûm .
Hence the filter affects the power spectrum:
f
Sm
= |R(fM )|2 .
Sm

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).

16.4 Convolution theorem and spectral distor-


tion due to tapering
The simplest kind of filter, called FIR (Finite Impulse Response) involves weighted
averaging or convolution:
P2
X
vj = wp uj−p . (16.4.1)
p=P1

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

w = [w0 w1 . . . wN/2−1 w−N/2 . . . w−1 ] = {wM (m) } (16.4.2)


Atm S 552 Lecture 16 Bretherton - Winter 2015 3

(here wp = 0 outside the range −P1 ≤ p ≤ P2 ) and ŵ = DFT(w), then

v̂m = ŵm ûm . (16.4.3)

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.

You might also like