FT4: Only do the big FFT once for each candidate. Duh.

This commit is contained in:
Steve Franke
2019-03-30 15:55:05 -05:00
parent 68308e23aa
commit 68f82c95de
2 changed files with 14 additions and 10 deletions
+9 -7
View File
@@ -1,4 +1,4 @@
subroutine ft4_downsample(iwave,f0,c)
subroutine ft4_downsample(iwave,newdata,f0,c)
! Input: i*2 data in iwave() at sample rate 12000 Hz
! Output: Complex data in c(), sampled at 1200 Hz
@@ -11,9 +11,9 @@ subroutine ft4_downsample(iwave,f0,c)
complex cx(0:NMAX/2)
real x(NMAX), window(0:NFFT2-1)
equivalence (x,cx)
logical first
logical first, newdata
data first/.true./
save first,window
save first,window,x
df=12000.0/NMAX
baud=12000.0/NSPS
@@ -32,14 +32,16 @@ subroutine ft4_downsample(iwave,f0,c)
first=.false.
endif
x=iwave
call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
if(newdata) then
x=iwave
call four2a(x,NMAX,1,-1,0) !r2c FFT to freq domain
endif
i0=nint(f0/df)
c1=0.
c1(0)=cx(i0)
do i=1,NFFT2/2
if(i0+i.le.NMAX/2) c1(i)=cx(i0+i)
if(i0-i.ge.0) c1(NFFT2-i)=cx(i0-i)
if(i0+i.le.NMAX/2) c1(i)=cx(i0+i)
if(i0-i.ge.0) c1(NFFT2-i)=cx(i0-i)
enddo
c1=c1*window/NFFT2
call four2a(c1,NFFT2,1,1,1) !c2c FFT back to time domain