2019-04-18 15:16:39 -04:00
|
|
|
subroutine getcandidates4(dd,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
|
2019-01-21 20:31:54 -05:00
|
|
|
ncand,sbase)
|
|
|
|
|
2019-01-25 17:01:34 -05:00
|
|
|
include 'ft4_params.f90'
|
2019-01-21 20:31:54 -05:00
|
|
|
real s(NH1,NHSYM)
|
|
|
|
real savg(NH1),savsm(NH1)
|
|
|
|
real sbase(NH1)
|
|
|
|
real x(NFFT1)
|
2019-01-30 13:47:01 -05:00
|
|
|
real window(NFFT1)
|
2019-01-21 20:31:54 -05:00
|
|
|
complex cx(0:NH1)
|
2019-06-16 10:46:33 -04:00
|
|
|
real candidate(2,maxcand)
|
2019-04-18 15:16:39 -04:00
|
|
|
real dd(NMAX)
|
2019-01-27 20:19:47 -05:00
|
|
|
integer ipk(1)
|
2019-01-21 20:31:54 -05:00
|
|
|
equivalence (x,cx)
|
2019-01-30 13:47:01 -05:00
|
|
|
logical first
|
|
|
|
data first/.true./
|
|
|
|
save first,window
|
|
|
|
|
|
|
|
if(first) then
|
|
|
|
first=.false.
|
|
|
|
pi=4.0*atan(1.)
|
2019-03-03 14:02:22 -05:00
|
|
|
window=0.
|
|
|
|
call nuttal_window(window,NFFT1)
|
2019-01-30 13:47:01 -05:00
|
|
|
endif
|
2019-01-21 20:31:54 -05:00
|
|
|
|
|
|
|
! Compute symbol spectra, stepping by NSTEP steps.
|
|
|
|
savg=0.
|
2019-03-28 12:13:26 -04:00
|
|
|
df=12000.0/NFFT1
|
2019-01-21 20:31:54 -05:00
|
|
|
fac=1.0/300.0
|
|
|
|
do j=1,NHSYM
|
|
|
|
ia=(j-1)*NSTEP + 1
|
2019-01-30 13:47:01 -05:00
|
|
|
ib=ia+NFFT1-1
|
|
|
|
if(ib.gt.NMAX) exit
|
2019-04-18 15:16:39 -04:00
|
|
|
x=fac*dd(ia:ib)*window
|
2019-01-21 20:31:54 -05:00
|
|
|
call four2a(x,NFFT1,1,-1,0) !r2c FFT
|
|
|
|
do i=1,NH1
|
|
|
|
s(i,j)=real(cx(i))**2 + aimag(cx(i))**2
|
|
|
|
enddo
|
|
|
|
savg=savg + s(1:NH1,j) !Average spectrum
|
|
|
|
enddo
|
2019-05-25 11:58:04 -04:00
|
|
|
savg=savg/NHSYM
|
2019-01-21 20:31:54 -05:00
|
|
|
savsm=0.
|
2019-01-27 20:19:47 -05:00
|
|
|
do i=8,NH1-7
|
|
|
|
savsm(i)=sum(savg(i-7:i+7))/15.
|
2019-01-21 20:31:54 -05:00
|
|
|
enddo
|
2019-05-25 11:58:04 -04:00
|
|
|
|
2019-01-21 20:31:54 -05:00
|
|
|
nfa=fa/df
|
2019-05-27 17:34:53 -04:00
|
|
|
if(nfa.lt.nint(200.0/df)) nfa=nint(200.0/df)
|
2019-01-21 20:31:54 -05:00
|
|
|
nfb=fb/df
|
2019-06-04 15:53:45 -04:00
|
|
|
if(nfb.gt.nint(4910.0/df)) nfb=nint(4910.0/df)
|
2019-03-28 12:13:26 -04:00
|
|
|
ncand=0
|
2019-05-25 11:58:04 -04:00
|
|
|
call ft4_baseline(savg,nfa,nfb,sbase)
|
|
|
|
if(any(sbase(nfa:nfb).le.0)) return
|
|
|
|
savsm(nfa:nfb)=savsm(nfa:nfb)/sbase(nfa:nfb)
|
2019-05-22 18:02:15 -04:00
|
|
|
f_offset = -1.5*12000.0/NSPS
|
2019-02-02 17:29:17 -05:00
|
|
|
do i=nfa+1,nfb-1
|
2019-03-28 13:21:02 -04:00
|
|
|
if(savsm(i).ge.savsm(i-1) .and. savsm(i).ge.savsm(i+1) .and. &
|
|
|
|
savsm(i).ge.syncmin) then
|
|
|
|
den=savsm(i-1)-2*savsm(i)+savsm(i+1)
|
|
|
|
del=0.
|
|
|
|
if(den.ne.0.0) del=0.5*(savsm(i-1)-savsm(i+1))/den
|
|
|
|
fpeak=(i+del)*df+f_offset
|
2019-06-04 15:53:45 -04:00
|
|
|
if(fpeak.lt.200.0 .or. fpeak.gt.4910.0) cycle
|
2019-03-28 13:21:02 -04:00
|
|
|
speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del
|
|
|
|
ncand=ncand+1
|
|
|
|
candidate(1,ncand)=fpeak
|
2019-06-16 10:46:33 -04:00
|
|
|
candidate(2,ncand)=speak
|
2019-03-28 13:21:02 -04:00
|
|
|
if(ncand.eq.maxcand) exit
|
|
|
|
endif
|
2019-01-21 20:31:54 -05:00
|
|
|
enddo
|
2019-02-02 17:29:17 -05:00
|
|
|
|
2019-01-21 20:31:54 -05:00
|
|
|
return
|
|
|
|
end subroutine getcandidates4
|