Integrate the latest algorithm for hinted decoding.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6365 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2016-01-08 20:51:13 +00:00
parent 92479967c7
commit a864cbfdeb
5 changed files with 68 additions and 116 deletions

View File

@ -5,28 +5,25 @@ subroutine exp_decode65(s3,mrs,mrs2,mrsym,mr2sym,mrprob,mode65,flip, &
use prog_args
parameter (NMAX=10000)
real s3(64,63)
real pp(NMAX),bb(NMAX)
integer*1 sym1(0:62,NMAX)
integer*1 sym2(0:62,NMAX)
integer mrs(63),mrs2(63)
integer mrsym(0:62),mr2sym(0:62),mrprob(0:62)
integer dgen(12),sym(0:62),sym_rev(0:62)
integer test(0:62)
! integer test(0:62)
character*6 mycall,hiscall0,hisgrid0,hiscall(NMAX)
character*4 hisgrid(NMAX)
character callsign*12,grid*4
character*180 line
character ceme*3,msg*22
character*22 msg0(1000),decoded
character*22 msg0(2*NMAX+100),decoded
logical*1 eme(NMAX)
logical first
data first/.true./,nn/0/
save first,sym1,nused,msg0,sym2,nn
! print*,mycall,hiscall0,hisgrid0,nexp_decode
data first/.true./
save first,sym1,nused,msg0,sym2
if(first) then
neme=1
neme=0
open(23,file=trim(data_dir)//'/CALL3.TXT',status='unknown')
icall=0
j=0
@ -55,27 +52,23 @@ subroutine exp_decode65(s3,mrs,mrs2,mrsym,mr2sym,mrprob,mode65,flip, &
10 ncalls=j
close(23)
! NB: generation of test messages is not yet complete!
j=0
do i=1,ncalls
if(neme.eq.1 .and. (.not.eme(i))) cycle
!### Special for tests ###
do isnr=-20,-30,-1
j=j+1
msg=mycall//' '//hiscall(i)//' '//hisgrid(i)
if(isnr.ne.-20) write(msg(14:18),"(i3,' ')") isnr
call fmtmsg(msg,iz)
call packmsg(msg,dgen,itype) !Pack message into 72 bits
call rs_encode(dgen,sym_rev) !RS encode
sym(0:62)=sym_rev(62:0:-1)
sym1(0:62,j)=sym
call interleave63(sym_rev,1) !Interleave channel symbols
call graycode(sym_rev,63,1,sym_rev) !Apply Gray code
sym2(0:62,j)=sym_rev(0:62)
msg0(j)=msg
enddo
j=j+1
msg=mycall//' '//hiscall(i)//' '//hisgrid(i)
! if(isnr.ne.-20) write(msg(14:18),"(i3,' ')") isnr
call fmtmsg(msg,iz)
call packmsg(msg,dgen,itype) !Pack message into 72 bits
call rs_encode(dgen,sym_rev) !RS encode
sym(0:62)=sym_rev(62:0:-1)
sym1(0:62,j)=sym
call interleave63(sym_rev,1) !Interleave channel symbols
call graycode(sym_rev,63,1,sym_rev) !Apply Gray code
sym2(0:62,j)=sym_rev(0:62)
msg0(j)=msg
enddo
nused=j
first=.false.
@ -86,82 +79,57 @@ subroutine exp_decode65(s3,mrs,mrs2,mrsym,mr2sym,mrprob,mode65,flip, &
ref0=ref0 + s3(mrs(j)+1,j)
enddo
p1=-1.e30
p2=-1.e30
bb1=1.e30
bb2=1.e30
u1=0.
u1=-99.0
u2=u1
dtotal=199.0
! Find p1 and p2 (best and second-best) codeword from a list, using
! matched filters
ip1=1 !Silence compiler warning
ip2=1
! Find u1 and u2 (best and second-best) codeword from a list, using
! a bank of matched filters on the symbol spectra s3(i,j).
ipk=1
do k=1,nused
pp(k)=0.
if(k.ge.2 .and. k.le.64 .and. flip.lt.0.0) cycle
! Test all messages if flip=+1; skip the CQ messages if flip=-1.
if(flip.gt.0.0 .or. msg0(k)(1:3).ne.'CQ ') then
psum=0.
ref=ref0
do j=1,63
! i=ncode(j,k)+1
i=sym2(j-1,k)+1
psum=psum + s3(i,j)
if(i.eq.mrs(j)+1) ref=ref - s3(i,j) + s3(mrs2(j)+1,j)
enddo
p=psum/ref
pp(k)=p
if(p.gt.p1) then
p1=p
ip1=k
! Find the FT-defined soft distance
! test=sym1(0:62,k)
! nh=0
! ns=0
! do i=0,62
! j=62-i
! if(mrsym(j).ne.test(i)) then
! nh=nh+1
! if(mr2sym(j).ne.test(i)) ns=ns+mrprob(j)
! endif
! enddo
! ds=ns*63.0/sum(mrprob)
if(p.gt.u1) then
u2=u1
u1=p
ipk=k
! nhard=nh
! dsoft=ds
! dtotal=nh+ds
! ncandidates=0
! ntry=0
endif
endif
! Find best and second-best codeword using the FT-defined soft distance
test=sym1(0:62,k)
nh=0
ns=0
do i=0,62
j=62-i
if(mrsym(j).ne.test(i)) then
nh=nh+1
if(mr2sym(j).ne.test(i)) ns=ns+mrprob(j)
endif
enddo
ds=ns*63.0/sum(mrprob)
bb(k)=nh+ds
if(nh+ds.lt.bb1) then
nhard=nh
dsoft=ds
bb1=nh+ds
ncandidates=0
ntry=0
ip2=k
endif
enddo
do i=1,nused
if(pp(i).gt.p2 .and. pp(i).ne.p1) p2=pp(i)
if(bb(i).lt.bb2 .and. bb(i).ne.bb1) bb2=bb(i)
enddo
! ### DO NOT REMOVE ###
rewind 77
write(77,*) p1,p2
call flush(77)
! ### Works OK without these three lines (in both Windows and Linux)
! ### if compiled without optimization.
bias=max(1.12*p2,0.335)
if(mode65.eq.2) bias=max(1.08*p2,0.405)
if(mode65.ge.4) bias=max(1.04*p2,0.505)
if(p2.eq.p1 .and. p1.ne.-1.e30) stop 'Error in deep65'
qual=100.0*(p1-bias)
decoded=' '
if(bb1.le.110.0) decoded=msg0(ip2)
nn=nn+1
qual2=110.0-bb1 + 1.0
qual=100.0*(u1-1.12*u2)
qmin=1.0
if(qual.ge.qmin) decoded=msg0(ipk)
return
end subroutine exp_decode65

View File

@ -72,6 +72,8 @@ subroutine extract(s3,nadd,ntrials,naggressive,ndepth,mycall_12, &
call interleave63(mr2sym,-1) !from second-most-reliable symbols
call interleave63(mr2prob,-1)
ntry=0
iftest=0
if(iftest.eq.2) go to 10
call timer('ftrsd ',0)
param=0
@ -91,19 +93,19 @@ subroutine extract(s3,nadd,ntrials,naggressive,ndepth,mycall_12, &
r0=0.90
endif
if(ntotal.le.nd0 .and. rtt.le.r0) nft=1
! nft=1 !### TEST ONLY ###
if(iftest.eq.1) nft=1 !### TEST ONLY ###
if(nft.eq.0 .and. ndepth.ge.5) then
call timer('exp_deco',0)
10 if(iftest.eq.2 .or. (nft.eq.0 .and. ndepth.ge.5)) then
mode65=1
flip=1.0
qmin=1.0
call timer('exp_deco',0)
call exp_decode65(s3,mrs,mrs2,mrsym,mr2sym,mrprob,mode65,flip, &
mycall,hiscall,hisgrid,nexp_decode,qual,decoded)
if(qual.ge.qmin) then
nft=2
else
decoded=' '
!### param=0
ntry=0
endif
call timer('exp_deco',1)
@ -132,9 +134,6 @@ subroutine extract(s3,nadd,ntrials,naggressive,ndepth,mycall_12, &
900 continue
if(nft.eq.1 .and. nhard.lt.0) decoded=' '
! write(71,3300) nft,nhard,ntotal,int(qual),ncount,decoded
!3300 format(5i5,2x,a22)
return
end subroutine extract

View File

@ -163,13 +163,14 @@ contains
naggressive,ndepth,mycall,hiscall,hisgrid,nexp_decode, &
sync2,a,dtx,nft,qual,nhist,decoded)
call timer('decod65a',1)
if(nhard_min.gt.50) cycle
n=naggressive
rtt=0.001*nrtt1000
if(nhard_min.gt.h0(n)) cycle
if(ntotal_min.gt.d0(n)) cycle
if(rtt.gt.r0(n)) cycle
if(nft.lt.2) then
if(nhard_min.gt.50) cycle
if(nhard_min.gt.h0(n)) cycle
if(ntotal_min.gt.d0(n)) cycle
if(rtt.gt.r0(n)) cycle
endif
! !### Suppress false decodes in crowded HF bands ###
! if(naggressive.eq.0 .and. ntrials.le.10000) then
@ -177,7 +178,6 @@ contains
! if(nhard_min.ge.42 .or. ntotal_min.ge.71) cycle
! endif
! endif
if(decoded.eq.decoded0 .and. abs(freq-freq0).lt. 3.0 .and. &
minsync.ge.0) cycle !Don't display dupes
if(decoded.ne.' ' .or. minsync.lt.0) then

View File

@ -38,26 +38,20 @@ program stats
ntotal,rtt,ntry,nft,nqual,decoded
1010 format(i4.4,f5.1,i4,f5.1,i5,i6,i3,i4,f6.3,i8,i2,i3,1x,a22)
! ndfreq=9999
! do ifreq=600,2400,200
! n=abs(nfreq-ifreq)
! if(n.lt.ndfreq) ndfreq=n
! enddo
ndfreq=abs(nfreq-1500)
if(sync.ge.1.0 .and. abs(dt).le.ttol .and. ndfreq.le.nftol) then
nsynced=nsynced+1
else
nbadsync=nbadsync+1
endif
if(decoded.eq.' ') cycle
! if(ntotal.le.83 .and. rtt.le.0.90) then !nag=10
if(ntotal.le.81 .and. rtt.le.0.87) then !nag=0
if(nft.eq.2 .or. (ntotal.le.81 .and. rtt.le.0.87)) then !nag=0
if(decoded(1:11).eq.'K1ABC W9XYZ') then
ngood=ngood+1
if(ncandidates.eq.0) nbm=nbm+1
if(nft.eq.1 .and. ncandidates.eq.0) nbm=nbm+1
if(nft.eq.1) nftok=nftok+1
if(nft.ge.1) nhint=nhint+1
if(nft.ge.2) nhint=nhint+1
else
nbad=nbad+1
endif

View File

@ -57,9 +57,6 @@ subroutine sync65(ss,nfa,nfb,naggressive,ntol,nhsym,ca,ncand,nrobust)
ncand=ncand+1
endif
endif
! write(76,1010) i,freq,ccfred(i),itry,ncand
!1010 format(i6,2f10.2,i5,i6)
! flush(76)
if(itry.ne.0) then
call xcor(ss,i,nhsym,nsym,lag1,lag2,ccfblue,ccf0,lagpk,flip,fdot,nrobust)
call slope(ccfblue(lag1),lag2-lag1+1,lagpk-lag1+1.0)
@ -71,12 +68,6 @@ subroutine sync65(ss,nfa,nfb,naggressive,ntol,nhsym,ca,ncand,nrobust)
dtx=xlag*2048.0/11025.0
ccfblue(lag1)=0.
ccfblue(lag2)=0.
! open(14,file="/tmp/fort.14",access="append")
! do j=lag1,lag2
! write(14,1020) j,ccfblue(j)
!1020 format(i5,f10.3)
! enddo
! close(14)
ca(ncand)%freq=freq
ca(ncand)%dt=dtx
ca(ncand)%sync=ccfred(i)