The BUTTERWORTH function returns an array that contains the absolute value of the low-pass Butterworth kernel. In practice, it is useful for filtering out high-frequency noise.
This routine is written in the IDL language. Its source code can be found in the file butterworth.pro in the lib subdirectory of the IDL distribution.
The form of the filter is given by the following equation:
where Ω is the frequency, Ωc is the cutoff frequency, and N is the order.
Syntax
Result = BUTTERWORTH( X [, Y [, Z]] [, CUTOFF=value] [, ORDER=value] [, /ORIGIN] [, XDIM=value] [, YDIM=value] [, ZDIM=value] )
Return Value
The result is either a 1D, 2D, or 3D array with the dimensions of the result defined by the inputs X, Y, and Z.
Arguments
X
Either a scalar value containing the number of elements in the x direction or a vector of up to three elements giving the number of elements in the x, y, and z directions, respectively.
Y
The number of elements in the y direction. This argument is ignored if X contains more than one element.
Z
The number of elements in the z direction. This argument is ignored if X contains more than one element.
Keywords
CUTOFF
The cutoff frequency. The default value is 9.
ORDER
The order of the filter. The default value is 1.
ORIGIN
If set, the return array is centered at the corners of the array.
XDIM
The x spacing of the columns.
YDIM
The y spacing of the rows.
ZDIM
The z spacing of the planes.
Example
In the following example, we add high-frequency noise to a sine wave, and then filter out the noise with a Butterworth filter.
Create a filter and apply it to the signal:
x = 4*!PI/1000 * FINDGEN(1000)
y_signal = (SIN(x)+1)
y_noise = RANDOMU(SEED,1000)
y_summation = y_signal + y_noise
filter = BUTTERWORTH(1000, 2)
y_filtered = FFT( FFT(y_summation, -1) * filter, 1 )
Plot the results:
!p.MULTI = [0,0,4,0,0]
WINDOW, /FREE, XSIZE=(720), YSIZE=(720), $
TITLE='Butterworth Filter'
DEVICE, RETAIN=2, DECOMPOSED=0
LOADCT, 0
!p.color = 0
!p.background = 255
PLOT, x, y_signal, TITLE='Signal'
PLOT, x, y_noise, TITLE='Noise'
PLOT, x, y_signal + y_noise, TITLE='Signal + Noise'
PLOT, x, y_filtered, TITLE='Signal + Noise (Filtered)'
!p.MULTI=0
!p.color = 255
!p.background = 0
The example creates the following output:
Version History