comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Using IDL to make a signal filter
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Using IDL to make a signal filter [message #61358 is a reply to message #61280] Mon, 14 July 2008 10:33 Go to previous messageGo to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Mon, 14 Jul 2008 04:08:15 -0700 (PDT), ICBM0926
<ICBM0926@gmail.com> wrote:

> I have an 1D vector data in IDL from an analytical laser formula which
> contains 2 laser frequencies. I wrote a program trying to filter my 1D
> vector and get the waveform of one of the frequencies. I used 1D FFT
> and a mask
> function(step function). I applied the mask function to the frequency
> domain data. I've covered both positive and negative frequencies. I
> did inverse 1d FFT to retrieve the signal. I found that
> the amplitude of the signal is only half as it should be. Could
> anybody tell me what went wrong?


In the example below, you see first a sum of three sinus waves, all
with amplitude 1. After filtering two of them out, 1 sinus is
remaining with amplitude 1, not 0.5 as in your case. Does this help?



pro test

; Time domain
freq1=2.
freq2=3.
freq3=4.
dtime=0.05
ntime=200

time=dtime*findgen(ntime)
signal=sin(2*!pi*freq1*time)+sin(2*!pi*freq2*time)+sin(2*!pi *freq3*time)

; Frequency domain
nfreq=ntime/2+1
freq=findgen(nfreq)/(dtime*ntime)
freq=[freq,reverse(-freq[1:nfreq-1-(~(ntime mod 2))])]
fsignal=fft(signal,-1)

; Frequency domain filter
f_low = 0
f_high = 2.5
steep=20.
freqfilter= 1./(1.+(freq/f_high)^steep)
fsignalfilt=fsignal*freqfilter

; Back to time domain
signalfilt=fft(fsignalfilt,1)

; Plot
window,0
!P.MULTI=[0,2,2]
plot,freq[0:nfreq-1],abs(fsignal[0:nfreq-1])^2,xtitle='frequ ency',ytitle='spectrum',title='Original
Spectrum'
plot,freq[0:nfreq-1],freqfilter[0:nfreq-1],xtitle='frequency ',ytitle='filter',title='Filter'
plot,freq[0:nfreq-1],abs(fsignalfilt[0:nfreq-1])^2,xtitle='f requency',ytitle='filtered
spectrum',title='Filtered spectrum'

window,1
!P.MULTI=[0,1,2]
plot,time,signal,xtitle='time',ytitle='signal'
plot,time,signalfilt,xtitle='time',ytitle='filtered signal'
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Edge detection for saturn's rings
Next Topic: centering dialog_pickfile, printersetup, etc...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 03:18:28 PDT 2025

Total time taken to generate the page: 0.09291 seconds