WSJT-X/lib/ft8/get_spectrum_baseline.f90
Steve Franke a0d471cb0b Improve FT8 SNR estimates in two ways:
(i) SNR no longer saturates at +20 dB
(ii) a large signal in the passband no longer causes the
SNR of weaker signals to be biased low.
2019-11-27 15:58:52 -06:00

44 lines
1.0 KiB
Fortran

subroutine get_spectrum_baseline(dd,nfa,nfb,sbase)
include 'ft8_params.f90'
parameter(NST=NFFT1/2,NF=NMAX/NST-1)
real s(NH1,NF)
real savg(NH1)
real sbase(NH1)
real x(NFFT1)
real window(NFFT1)
complex cx(0:NH1)
real dd(NMAX)
equivalence (x,cx)
logical first
data first/.true./
save first,window
if(first) then
first=.false.
pi=4.0*atan(1.)
window=0.
call nuttal_window(window,NFFT1)
window=window/sum(window)*NSPS*2/300.0
endif
! Compute symbol spectra, stepping by NSTEP steps.
savg=0.
df=12000.0/NFFT1
do j=1,NF
ia=(j-1)*NST + 1
ib=ia+NFFT1-1
if(ib.gt.NMAX) exit
x=dd(ia:ib)*window
call four2a(x,NFFT1,1,-1,0) !r2c FFT
s(1:NH1,j)=abs(cx(1:NH1))**2
savg=savg + s(1:NH1,j) !Average spectrum
enddo
if(nfa.lt.nint(200.0)) nfa=nint(200.0)
if(nfb.gt.nint(4910.0)) nfb=nint(4910.0)
call baseline(savg,nfa,nfb,sbase)
return
end subroutine get_spectrum_baseline