Add some sanity checks to getcandidates4.f90

This commit is contained in:
Steve Franke 2019-03-28 11:13:26 -05:00
parent 3490c0d1e3
commit fe8aa87401

View File

@ -27,7 +27,7 @@ subroutine getcandidates4(id,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
! Compute symbol spectra, stepping by NSTEP steps.
savg=0.
tstep=NSTEP/12000.0
df=12000.0/NFFT1 !5.86 Hz
df=12000.0/NFFT1
fac=1.0/300.0
do j=1,NHSYM
ia=(j-1)*NSTEP + 1
@ -55,17 +55,28 @@ subroutine getcandidates4(id,fa,fb,syncmin,nfqso,maxcand,savg,candidate, &
indx=0
call indexx(savsm(n300:n2500),np,indx)
xn=savsm(nfa+indx(nint(0.3*np)))
savsm=savsm/xn
ncand=0
if(xn.le.1.e-8) return
savsm=savsm/xn
! call ft4_baseline(savg,nfa,nfb,sbase)
! savsm=savsm/sbase
f_offset = -1.5*12000/512
do i=nfa+1,nfb-1
if(savsm(i).ge.savsm(i-1) .and. savsm(i).ge.savsm(i+1) .and. savsm(i).ge.syncmin) then
del=0.5*(savsm(i-1)-savsm(i+1))/(savsm(i-1)-2*savsm(i)+savsm(i+1))
den=savsm(i-1)-2*savsm(i)+savsm(i+1)
if(den.ne.0.0) then
del=0.5*(savsm(i-1)-savsm(i+1))/den
else
del=0.0
endif
fpeak=(i+del)*df+f_offset
speak=savsm(i) - 0.25*(savsm(i-1)-savsm(i+1))*del
ncand=ncand+1
if(ncand.gt.maxcand) exit
if(ncand.gt.maxcand) then
ncand=maxcand
exit
endif
candidate(1,ncand)=fpeak
candidate(2,ncand)=-99.99
candidate(3,ncand)=speak