Improvements to decoder for short JTMSK messages. Still needs work!

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6461 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2016-02-02 19:49:17 +00:00
parent dc69144396
commit 5fc5597652
2 changed files with 70 additions and 52 deletions

View File

@ -2,9 +2,6 @@ subroutine jtmsk_decode(id2,narg,line)
! Decoder for JTMSK
use timer_module, only: timer
use timer_impl, only: limtrace
parameter (NMAX=30*12000)
parameter (NFFTMAX=512*1024)
parameter (NSPM=1404) !Samples per JTMSK message
@ -42,16 +39,12 @@ subroutine jtmsk_decode(id2,narg,line)
d(0:npts-1)=id2(0:npts-1)
rms=sqrt(dot_product(d(0:npts-1),d(0:npts-1))/npts)
d(0:npts-1)=d(0:npts-1)/rms
call timer('mskdt ',0)
call mskdt(d,npts,ty,yellow,nyel)
nyel=min(nyel,5)
call timer('mskdt ',1)
n=log(float(npts))/log(2.0) + 1.0
nfft=min(2**n,1024*1024)
call timer('analytic',0)
call analytic(d,npts,nfft,c) !Convert to analytic signal
call timer('analytic',1)
nbefore=NSPM
nafter=4*NSPM
@ -72,13 +65,9 @@ subroutine jtmsk_decode(id2,narg,line)
if(mod(itry,2).eq.1) idf1=-idf1
if(abs(idf1).gt.ntol) exit
fpk=idf1 + nrxfreq
call timer('tweak1 ',0)
call tweak1(cdat2,iz,1500.0-fpk,cdat)
call timer('tweak1 ',1)
call timer('syncmsk ',0)
call syncmsk(cdat,iz,jpk,ipk,idf,rmax,snr,metric,msg)
call timer('syncmsk ',1)
freq=fpk+idf
if(metric.eq.-9999) cycle !No output if no significant sync
t0=(ia+jpk)/12000.0
@ -103,14 +92,14 @@ subroutine jtmsk_decode(id2,narg,line)
900 if(nline.eq.0) then
msg=' '
call jtmsk_short(c,npts,narg,tbest,msg)
call jtmsk_short(c,npts,narg,tbest,idfpk,msg)
!### Needs work!
if(msg.ne.' ') then
nline=nline+1
j=nint(12000.0*tbest/512.0)
nsnr=nint(3*(yellow(j)-2.0))
write(line(nline),1020) nutc,nsnr,tbest,nrxfreq,msg
write(line(nline),1020) nutc,nsnr,tbest,nrxfreq+idfpk,msg
endif
!###

View File

@ -1,4 +1,6 @@
subroutine jtmsk_short(cdat,npts,narg,tbest,decoded)
subroutine jtmsk_short(cdat,npts,narg,tbest,idfpk,decoded)
! Decode short-format messages in JTMSK mode.
parameter (NMAX=15*12000,NSAVE=100)
character*22 msg,decoded,msgsent
@ -6,32 +8,36 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,decoded)
complex cdat(0:npts-1)
complex cw(0:209,0:4095) !Waveforms of possible messages
complex cb11(0:65) !Complex waveform of Barker 11
complex cd(0:511)
complex z1,z2a,z2b
real*8 dt,twopi,freq,phi,dphi0,dphi1,dphi
real r1(0:NMAX-1)
real r2(0:4095)
real r1save(NSAVE)
! integer*8 count0,count1,clkfreq
integer itone(234) !Message bits
integer jgood(NSAVE)
integer indx(NSAVE)
integer narg(0:13)
logical first
data rpt /'26 ','27 ','28 ','R26','R27','R28','RRR','73 '/
data first/.true./,nrxfreq0/-1/
save first,cw,cb11,nrxfreq0
data first/.true./,nrxfreq0/-1/,ttot/0.0/
save first,cw,cb11,nrxfreq0,ttot
nrxfreq=narg(10) !Target Rx audio frequency (Hz)
ntol=narg(11) !Search range, +/- ntol (Hz)
! call system_clock(count0,clkfreq)
nrxfreq=narg(10) !Target Rx audio frequency (Hz)
ntol=narg(11) !Search range, +/- ntol (Hz)
nhashcalls=narg(12)
if(first .or. nrxfreq.ne.nrxfreq0) then
dt=1.d0/12000.d0
twopi=8.d0*atan(1.d0)
freq=nrxfreq
dphi0=twopi*(freq-500.d0)*dt !Phase increment, lower tone
dphi1=twopi*(freq+500.d0)*dt !Phase increment, upper tone
nsym=35 !Number of symbols
nspm=6*nsym !Samples per message
dphi0=twopi*(freq-500.d0)*dt !Phase increment, lower tone
dphi1=twopi*(freq+500.d0)*dt !Phase increment, upper tone
nsym=35 !Number of symbols
nspm=6*nsym !Samples per message
msg="<C1ALL C2ALL> 73"
do imsg=0,4095 !Generate all possible message waveforms
@ -87,44 +93,59 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,decoded)
kmax=k
call indexx(r1save,kmax,indx)
df=12000.0/512.0
ibest2=-1
idfbest=0
u1best=0.
do kk=1,kmax
do kk=1,min(kmax,10)
k=indx(kmax+1-kk)
j=jgood(k)
if(j.lt.144 .or. j.gt.npts-210) cycle
t=j/12000.0
u1=0.
u2=0.
r2max=0.
ibest=-1
do imsg=0,4095
ssa=0.
ssb=0.
do i=0,209
ssa=ssa + real(cdat(j+i))**2 + aimag(cdat(j+i))**2
ssb=ssb + real(cdat(j+i-144))**2 + aimag(cdat(j+i-144))**2
do iidf=0,10
idf=20*((iidf+1)/2)
if(iand(iidf,1).eq.1) idf=-idf
call tweak1(cdat(j-144:j+209),354,float(-idf),cd)
cd(354:)=0.
do imsg=0,4095
ssa=0.
ssb=0.
do i=0,209
ssa=ssa + real(cd(144+i))**2 + aimag(cd(144+i))**2
ssb=ssb + real(cd(i))**2 + aimag(cdat(i))**2
enddo
z2a=dot_product(cw(0:209,imsg),cd(144:353))
z2b=dot_product(cw(0:65,imsg),cdat(144:209)) + &
dot_product(cw(66:209,imsg),cdat(0:143))
ssa=sqrt(ssa/210.0)*210.0
ssb=sqrt(ssb/210.0)*210.0
r2(imsg)=max(abs(z2a)/ssa,abs(z2b)/ssb)
if(r2(imsg).gt.r2max) then
r2max=r2(imsg)
ibest=imsg
u2=u1
u1=r2max
idfpk=idf
t2=t
n=0
if(imsg.eq.2296 .or. imsg.eq.2302) n=1
! write(51,3101) t,kk,nrxfreq+idf,ibest,n, &
! r1(j),u1,u2,u2/u1,r1(j)/r2max,idf
! flush(51)
endif
enddo
z2a=dot_product(cw(0:209,imsg),cdat(j:j+209))
z2b=dot_product(cw(0:65,imsg),cdat(j:j+65)) + &
dot_product(cw(66:209,imsg),cdat(j-144:j-1))
ssa=sqrt(ssa/210.0)*210.0
ssb=sqrt(ssb/210.0)*210.0
r2(imsg)=max(abs(z2a)/(0.908*ssa),abs(z2b)/(0.908*ssb))
if(r2(imsg).gt.r2max) then
r2max=r2(imsg)
ibest=imsg
u2=u1
u1=r2max
endif
enddo
r1_r2=r1(j)/r2max
t=j/12000.0
n=0
if(ibest/8.eq.narg(12) .and. iand(ibest,7).eq.3) n=1
! write(52,3101) t,nrxfreq,ibest/8,n,r1(j),u1,u2,u2/u1,r1_r2
! flush(52)
if(u1.ge.0.75 .and. u2/u1.lt.0.9 .and. r1_r2.lt.1.11) then
! write(*,3101) t,nrxfreq,ibest/8,n,r1(j),u1,u2,u2/u1,r1_r2
! write(*,3101) t2,kk,nrxfreq+idfpk,ibest,0, &
! r1(j),u1,u2,u2/u1,r1(j)/r2max,idfpk
if(u1.ge.0.71 .and. u2/u1.lt.0.91 .and. r1_r2.lt.1.3) then
if(u1.gt.u1best) then
irpt=iand(ibest,7)
ihash=ibest/8
@ -135,17 +156,25 @@ subroutine jtmsk_short(cdat,npts,narg,tbest,decoded)
u1best=u1
u2best=u2
ibest2=ibest
idfbest=idfpk
r1_r2best=r1_r2
nn=0
if(ihash.eq.narg(12) .and. iand(ibest2,7).eq.3) nn=1
if(ihash.eq.narg(12) .and. iand(ibest2,7).eq.0) nn=1
endif
endif
! if(r1best.gt.0.0) write(*,3101) tbest,kk,nrxfreq+idfbest,ibest,nn, &
! r1best,u1best,u2best,u2best/u1best,r1_r2best,idfbest
enddo
! if(r1best.gt.0.0) then
! write(*,3101) tbest,nrxfreq,ihash,nn,r1best,u1best,u2best, &
! u2best/u1best,r1_r2best
!3101 format(f7.2,3i6,5f8.2)
! write(*,3101) tbest,kk,nrxfreq+idfbest,ibest,nn,r1best,u1best,u2best, &
! u2best/u1best,r1_r2best,idfbest
!3101 format(f6.2,4i5,5f8.2,i6)
! endif
! call system_clock(count1,clkfreq)
! ttot=float(count1-count0)/float(clkfreq)
! write(*,3001) ttot
!3001 format('Execution time:',f7.3)
return
end subroutine jtmsk_short