Merge branch 'feat-fst280' of bitbucket.org:k1jt/wsjtx into feat-fst280

This commit is contained in:
Bill Somerville 2020-07-16 23:10:42 +01:00
commit 5b705d54d2
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
2 changed files with 93 additions and 78 deletions

View File

@ -733,7 +733,11 @@ contains
write(13,1002) nutc,nint(sync),nsnr,dt,freq,0,decoded0 write(13,1002) nutc,nint(sync),nsnr,dt,freq,0,decoded0
1002 format(i6.6,i4,i5,f6.1,f8.0,i4,3x,a37,' FST240') 1002 format(i6.6,i4,i5,f6.1,f8.0,i4,3x,a37,' FST240')
else else
if(fmid.ne.-999.0) write(decoded0(16:21),'(f6.3)') w50 if(fmid.ne.-999.0) then
if(w50.lt.0.95) write(decoded0(18:22),'(f5.3)') w50
if(w50.ge.0.95) write(decoded0(18:22),'(f5.2)') w50
if(decoded0(18:18).eq.'0') decoded0(18:18)=' '
endif
write(*,1003) nutc,nsnr,dt,nint(freq),decoded0,annot write(*,1003) nutc,nsnr,dt,nint(freq),decoded0,annot
1003 format(i4.4,i4,f5.1,i5,' ` ',1x,a37,1x,a2,2f7.3) 1003 format(i4.4,i4,f5.1,i5,' ` ',1x,a37,1x,a2,2f7.3)
write(13,1004) nutc,nint(sync),nsnr,dt,freq,0,decoded0 write(13,1004) nutc,nint(sync),nsnr,dt,freq,0,decoded0

View File

@ -811,87 +811,98 @@ contains
end subroutine get_candidates_fst240 end subroutine get_candidates_fst240
subroutine write_ref(itone,iwave,nsps,nmax,ndown,hmod,i0,fc,fmid,w50) subroutine write_ref(itone,iwave,nsps,nmax,ndown,hmod,i0,fc,fmid,w50)
complex cwave(nmax)
complex, allocatable :: c(:) ! On "plotspec" special request, compute Doppler spread for a decoded signal
real,allocatable :: ss(:)
integer itone(160) complex, allocatable :: cwave(:) !Reconstructed complex signal
integer*2 iwave(nmax) complex, allocatable :: g(:) !Channel gain, g(t) in QEX paper
integer hmod real,allocatable :: ss(:) !Computed power spectrum of g(t)
integer itone(160) !Tones for this message
integer*2 iwave(nmax) !Raw Rx data
integer hmod !Modulation index
data ncall/0/ data ncall/0/
save ncall save ncall
ncall=ncall+1 ncall=ncall+1
allocate(c(0:nmax-1)) nfft=2*nmax
allocate(cwave(0:nmax-1))
allocate(g(0:nfft-1))
wave=0 wave=0
fsample=12000.0 fsample=12000.0
nsym=160 nsym=160
call gen_fst240wave(itone,nsym,nsps,nmax,fsample,hmod,fc,1,cwave,wave)
call gen_fst240wave(itone,nsym,nsps,nmax,fsample,hmod,fc, &
1,cwave,wave)
cwave=cshift(cwave,-i0*ndown) cwave=cshift(cwave,-i0*ndown)
! do i=1,nmax
! write(51,1000) i,iwave(i),cwave(i)
!1000 format(2i10,f12.6)
! enddo
fac=1.0/32768 fac=1.0/32768
c=fac*float(iwave)*conjg(cwave) g(0:nmax-1)=fac*float(iwave)*conjg(cwave)
call four2a(c,nmax,1,-1,1) !Forward c2c FFT g(nmax:)=0.
call four2a(g,nfft,1,-1,1) !Forward c2c FFT
df=12000.0/nmax df=12000.0/nfft
ia=1.0/df ia=1.0/df
smax=0. smax=0.
do i=-ia,ia do i=-ia,ia !Find smax in +/- 1 Hz around 0.
j=i j=i
if(j.lt.0) j=i+nmax if(j.lt.0) j=i+nfft
s=real(c(j))**2 + aimag(c(j))**2 s=real(g(j))**2 + aimag(g(j))**2
smax=max(s,smax) smax=max(s,smax)
enddo enddo
ia=10.1/df ia=10.1/df
allocate(ss(-ia:ia)) allocate(ss(-ia:ia)) !Allocate space for +/- 10 Hz
sum1=0. sum1=0.
sum2=0. sum2=0.
ns=0 ns=0
do i=-ia,ia do i=-ia,ia
j=i j=i
if(j.lt.0) j=i+nmax if(j.lt.0) j=i+nfft
ss(i)=(real(c(j))**2 + aimag(c(j))**2)/smax ss(i)=(real(g(j))**2 + aimag(g(j))**2)/smax
f=i*df f=i*df
if(f.ge.-4.0 .and. f.le.-2.0) then if(f.ge.-4.0 .and. f.le.-2.0) then
sum1=sum1 + ss(i) sum1=sum1 + ss(i) !Power between -2 and -4 Hz
ns=ns+1 ns=ns+1
else if(f.ge.2.0 .and. f.le.4.0) then else if(f.ge.2.0 .and. f.le.4.0) then
sum2=sum2 + ss(i) sum2=sum2 + ss(i) !Power between +2 and +4 Hz
endif endif
enddo enddo
avg=min(sum1/ns,sum2/ns) avg=min(sum1/ns,sum2/ns) !Compute avg from smaller sum
sum1=0. sum1=0.
do i=-ia,ia do i=-ia,ia
f=i*df f=i*df
if(abs(f).le.1.0) sum1=sum1 + ss(i)-avg if(abs(f).le.1.0) sum1=sum1 + ss(i)-avg !Power in abs(f) < 1 Hz
y=0.99*ss(i) + ncall-1 enddo
ia=nint(1.0/df) + 1
sum2=0.0
xi1=-999
xi2=-999
xi3=-999
sum2z=0.
do i=-ia,ia !Find freq range that has 50% of signal power
sum2=sum2 + ss(i)-avg
if(sum2.ge.0.25*sum1 .and. xi1.eq.-999.0) then
xi1=i - 1 + (sum2-0.25*sum1)/(sum2-sum2z)
endif
if(sum2.ge.0.50*sum1 .and. xi2.eq.-999.0) then
xi2=i - 1 + (sum2-0.50*sum1)/(sum2-sum2z)
endif
if(sum2.ge.0.75*sum1) then
xi3=i - 1 + (sum2-0.75*sum1)/(sum2-sum2z)
exit
endif
sum2z=sum2
enddo
xdiff=sqrt(1.0+(xi3-xi1)**2) !Keep small values from fluctuating too widely
w50=xdiff*df !Compute Doppler spread
fmid=xi2*df !Frequency midpoint of signal powere
do i=-ia,ia !Save the spectrum for plotting
f=i*df
y=0.99*ss(i+nint(xi2)) + ncall-1
write(52,1010) f,y write(52,1010) f,y
1010 format(f12.6,f12.6) 1010 format(f12.6,f12.6)
enddo enddo
ia=nint(1.0/df)
sum2=0.0
i1=-999
i2=-999
i3=-999
do i=-ia,ia
sum2=sum2 + ss(i)-avg
if(sum2.ge.0.25*sum1 .and. i1.eq.-999) i1=i
if(sum2.ge.0.50*sum1 .and. i2.eq.-999) i2=i
if(sum2.ge.0.75*sum1) then
i3=i
exit
endif
enddo
fmid=i2*df
w50=(i3-i1+1)*df
return return
end subroutine write_ref end subroutine write_ref