Re: bandpass filter [message #33672] |
Sun, 19 January 2003 19:06 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
tom (tom2959@21cn.com) writes:
> Hi,where can I find bandpass filter(for example,Butter-worth) written in
> IDL?
IDL> filename = Filepath(['examples','demo','demosrc'], 'd_filter.pro']
IDL> Print, filename
Look on lines 545-564 of this file. You will find this:
case filtertype of
; Define Butterworth filter types.
;
0: BEGIN
if (bandtype EQ 0) then begin ; Compute lowpass filter.
filter = 1.0d / (1.0d + (distfun / cutoff)^(2 * order))
endif else if (bandtype EQ 1) then begin ; Compute highpass filter.
filter = 1.0d / (1.0d + (cutoff / distfun)^(2 * order))
endif else begin ;Bandpass or bandreject
filter = distfun^2 - cutoff^2 ;Dist squared
zeroes = WHERE(abs(filter) EQ 0.0, count)
if (count NE 0) then filter[zeroes] = 1d-4 ;Avoid divide by 0
filter = 1.0d / (1.0d + $ ; Compute bandreject filter.
((distfun * bandwidth) / filter) ^ (2 * order))
if (bandtype EQ 2) then $ ; Compute bandpass filter.
filter = 1.0 - filter
endelse
end ; of 0
If you want to see this code in operation, type "demo" at the
IDL prompt. Then select "Signal Processing". You can play around
all you like.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|