Bumped max candidates to 300 (configurable) and cleaned up some sync code

This commit is contained in:
Jordan Sherer 2020-05-02 14:48:46 -04:00
parent bef896c771
commit 2d6ac83606
15 changed files with 87 additions and 49 deletions

View File

@ -5,12 +5,13 @@ subroutine js8_downsample(dd,newdat,f0,c1)
!include 'js8_params.f90' !include 'js8_params.f90'
parameter (NDFFT1=NSPS*NDD, NDFFT2=NDFFT1/NDOWN) ! Downconverted FFT Size - 192000/60 = 3200 parameter (NDFFT1=NSPS*NDD, NDFFT2=NDFFT1/NDOWN) ! Downconverted FFT Size - 192000/60 = 3200
parameter (NTAPER=1) ! Should we taper the downsample?
logical newdat,first logical newdat,first
complex c1(0:NDFFT2-1) complex c1(0:NDFFT2-1)
complex cx(0:NDFFT1/2) complex cx(0:NDFFT1/2)
real*4 dd(NMAX),x(NDFFT1),taper(0:NDD) real dd(NMAX),x(NDFFT1),taper(0:NDD)
equivalence (x,cx) equivalence (x,cx)
data first/.true./ data first/.true./
save cx,first,taper save cx,first,taper
@ -22,6 +23,7 @@ subroutine js8_downsample(dd,newdat,f0,c1)
enddo enddo
first=.false. first=.false.
endif endif
if(newdat) then if(newdat) then
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> newdat', NMAX, NDFFT1 write(*,*) '<DecodeDebug> newdat', NMAX, NDFFT1
@ -54,8 +56,12 @@ subroutine js8_downsample(dd,newdat,f0,c1)
c1(k)=cx(i) c1(k)=cx(i)
k=k+1 k=k+1
enddo enddo
if(NTAPER.eq.1) then
c1(0:NDD)=c1(0:NDD)*taper(NDD:0:-1) c1(0:NDD)=c1(0:NDD)*taper(NDD:0:-1)
c1(k-1-NDD:k-1)=c1(k-1-NDD:k-1)*taper c1(k-1-NDD:k-1)=c1(k-1-NDD:k-1)*taper
endif
c1=cshift(c1,i0-ib) c1=cshift(c1,i0-ib)
call four2a(c1,NDFFT2,1,1,1) !c2c FFT back to time domain call four2a(c1,NDFFT2,1,1,1) !c2c FFT back to time domain
fac=1.0/sqrt(float(NDFFT1)*NDFFT2) fac=1.0/sqrt(float(NDFFT1)*NDFFT2)

View File

@ -19,3 +19,5 @@ parameter (NSTEP=NSPS/4) !Rough time-sync step size
parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps) parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps)
parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol
parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol
parameter (NFSRCH=5) !Search frequency range in Hz (i.e., +/- 2.5 Hz)
parameter (NMAXCAND=300) !Maxiumum number of candidate signals

View File

@ -17,3 +17,5 @@ parameter (NSTEP=NSPS/4) !Rough time-sync step size
parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps) parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps)
parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol
parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol
parameter (NFSRCH=5) !Search frequency range in Hz (i.e., +/- 2.5 Hz)
parameter (NMAXCAND=300) !Maxiumum number of candidate signals

View File

@ -17,3 +17,5 @@ parameter (NSTEP=NSPS/4) !Rough time-sync step size
parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps) parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps)
parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol
parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol
parameter (NFSRCH=5) !Search frequency range in Hz (i.e., +/- 2.5 Hz)
parameter (NMAXCAND=300) !Maxiumum number of candidate signals

View File

@ -111,8 +111,7 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
call js8_downsample(dd0,newdat,f1,cd0) !Mix f1 to baseband and downsample call js8_downsample(dd0,newdat,f1,cd0) !Mix f1 to baseband and downsample
call timer('js8_down',1) call timer('js8_down',1)
xdt=xdt+ASTART i0=nint((xdt+ASTART)*fs2) !Initial guess for start of signal
i0=nint(xdt*fs2) !Initial guess for start of signal
smax=0.0 smax=0.0
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
@ -122,28 +121,31 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
do idt=i0-NQSYMBOL,i0+NQSYMBOL !Search over +/- one quarter symbol do idt=i0-NQSYMBOL,i0+NQSYMBOL !Search over +/- one quarter symbol
call syncjs8d(cd0,icos,idt,ctwk,0,sync) call syncjs8d(cd0,icos,idt,ctwk,0,sync)
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> ', 'idt', idt, 'sync', sync write(*,*) '<DecodeDebug> idt', idt, 'sync', sync
flush(6) flush(6)
endif endif
if(sync.gt.smax) then if(sync.gt.smax) then
smax=sync smax=sync
ibest=idt ibest=idt
endif endif
enddo enddo
xdt2=ibest*dt2 !Improved estimate for DT xdt2=ibest*dt2 !Improved estimate for DT
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> ', 'xdt2', xdt2, 'ibest', ibest write(*,*) '<DecodeDebug> xdt2', xdt2, 'ibest', ibest
flush(6) flush(6)
endif endif
! Now peak up in frequency ! Now peak up in frequency
i0=nint(xdt2*fs2) i0=nint(xdt2*fs2)
smax=0.0 smax=0.0
do ifr=-5,5 !Search over +/- 2.5 Hz ! Search over +/- 1/2*nfsrch Hz (i.e., +/- 2.5Hz)
do ifr=-NFSRCH,NFSRCH
! compute the ctwk samples at the delta frequency to by used in syncjs8d ! compute the ctwk samples at the delta frequency to by used in syncjs8d
! to detect peaks at frequencies +/- 2.5 Hz so we can align the decoder ! to detect peaks at frequencies +/- 2.5 Hz so we can align the decoder
! for the best possible chance at decoding. ! for the best possible chance at decoding.
@ -151,6 +153,7 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
! NOTE: this does not need to compute the entire set of samples for the ! NOTE: this does not need to compute the entire set of samples for the
! costas arrays...it only needs to do it for the delta frequency ! costas arrays...it only needs to do it for the delta frequency
! whose conjugate is multiplied against each csync array in syncjs8d ! whose conjugate is multiplied against each csync array in syncjs8d
delf=ifr*0.5 delf=ifr*0.5
dphi=twopi*delf*dt2 dphi=twopi*delf*dt2
phi=0.0 phi=0.0
@ -160,18 +163,23 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
enddo enddo
call syncjs8d(cd0,icos,i0,ctwk,1,sync) call syncjs8d(cd0,icos,i0,ctwk,1,sync)
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> ', 'df', delf, 'sync', sync write(*,*) '<DecodeDebug> df', delf, 'sync', sync
flush(6) flush(6)
endif endif
if( sync .gt. smax ) then if( sync .gt. smax ) then
smax=sync smax=sync
delfbest=delf delfbest=delf
endif endif
enddo enddo
a=0.0 a=0.0
a(1)=-delfbest a(1)=-delfbest
call twkfreq1(cd0,NP2,fs2,a,cd0) call twkfreq1(cd0,NP2,fs2,a,cd0)
xdt=xdt2 xdt=xdt2
f1=f1+delfbest !Improved estimate of DF f1=f1+delfbest !Improved estimate of DF
@ -197,7 +205,7 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
s2(0:7,k)=abs(csymb(1:8))/1e3 s2(0:7,k)=abs(csymb(1:8))/1e3
enddo enddo
! sync quality check ! sync quality check
is1=0 is1=0
is2=0 is2=0
is3=0 is3=0
@ -209,7 +217,8 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
ip=maxloc(s2(:,k+72)) ip=maxloc(s2(:,k+72))
if(icos7c(k-1).eq.(ip(1)-1)) is3=is3+1 if(icos7c(k-1).eq.(ip(1)-1)) is3=is3+1
enddo enddo
! hard sync sum - max is 21
! hard sync sum - max is 21
nsync=is1+is2+is3 nsync=is1+is2+is3
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
@ -222,10 +231,12 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
call timer('badnsync', 0) call timer('badnsync', 0)
nbadcrc=1 nbadcrc=1
call timer('badnsync', 1) call timer('badnsync', 1)
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> bad sync', nsync write(*,*) '<DecodeDebug> bad sync', f1, xdt, nsync
flush(6) flush(6)
endif endif
return return
endif endif
@ -239,6 +250,7 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
enddo enddo
call indexx(s1sort,8*ND,indxs1) call indexx(s1sort,8*ND,indxs1)
xmeds1=s1sort(indxs1(nint(0.5*8*ND))) xmeds1=s1sort(indxs1(nint(0.5*8*ND)))
s1=s1/xmeds1 s1=s1/xmeds1
@ -340,25 +352,21 @@ subroutine js8dec(dd0,icos,newdat,nQSOProgress,nfqso,nftx,ndepth,lapon,lapcqonly
llra=scalefac*bmetap ! llr's for use with ap llra=scalefac*bmetap ! llr's for use with ap
apmag=scalefac*(maxval(abs(bmetap))*1.01) apmag=scalefac*(maxval(abs(bmetap))*1.01)
! pass # ! pass #
!------------------------------ !------------------------------
! 1 regular decoding ! 1 regular decoding
! 2 erase 24 ! 2 erase 24
! 3 erase 48 ! 3 erase 48
! 4 ap pass 1 ! 4 ap pass 1
! 5 ap pass 2 ! 5 ap pass 2
! 6 ap pass 3 ! 6 ap pass 3
! 7 ap pass 4, etc. ! 7 ap pass 4, etc.
!if(lapon) then if(lapon) then
! if(.not.lapcqonly) then npasses=4+nappasses(nQSOProgress)
! npasses=4+nappasses(nQSOProgress) else
! else
! npasses=5
! endif
!else
npasses=4 npasses=4
!endif endif
do ipass=1,npasses do ipass=1,npasses

View File

@ -17,3 +17,5 @@ parameter (NSTEP=NSPS/4) !Rough time-sync step size
parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps) parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps)
parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol
parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol
parameter (NFSRCH=5) !Search frequency range in Hz (i.e., +/- 2.5 Hz)
parameter (NMAXCAND=300) !Maxiumum number of candidate signals

View File

@ -17,3 +17,5 @@ parameter (NSTEP=NSPS/4) !Rough time-sync step size
parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps) parameter (NHSYM=NMAX/NSTEP-3) !Number of symbol spectra (1/4-sym steps)
parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol parameter (NDOWN=NSPS/NDOWNSPS) !Downsample factor to 32 samples per symbol
parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol parameter (NQSYMBOL=NDOWNSPS/4) !Downsample factor of a quarter symbol
parameter (NFSRCH=5) !Search frequency range in Hz (i.e., +/- 2.5 Hz)
parameter (NMAXCAND=300) !Maxiumum number of candidate signals

View File

@ -45,7 +45,7 @@ subroutine subtractjs8(dd,itone,f0,dt)
flush(6) flush(6)
endif endif
if(NSHIFT.ne.1) then if(NSHIFT.eq.0) then
pi=4.0*atan(1.0) pi=4.0*atan(1.0)
fac=1.0/float(NFFT) fac=1.0/float(NFFT)
sum=0.0 sum=0.0

View File

@ -9,8 +9,8 @@ subroutine syncjs8(dd,icos,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
real x(NFFT1) real x(NFFT1)
real sync2d(NH1,-JZ:JZ) real sync2d(NH1,-JZ:JZ)
real red(NH1) real red(NH1)
real candidate0(3,200) real candidate0(3,NMAXCAND)
real candidate(3,200) real candidate(3,NMAXCAND)
real dd(NMAX) real dd(NMAX)
integer icos integer icos
integer jpeak(NH1) integer jpeak(NH1)
@ -144,15 +144,20 @@ subroutine syncjs8(dd,icos,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
red=red/base red=red/base
k=0 k=0
do i=1,min(200,iz) do i=1,min(iz,NMAXCAND)
if(k.ge.200) exit if(k.ge.NMAXCAND) exit
n=ia + indx(iz+1-i) - 1 n=ia + indx(iz+1-i) - 1
if(red(n).lt.syncmin.or.isnan(red(n))) exit if(red(n).lt.syncmin.or.isnan(red(n))) exit
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> red candidate', red(n), n*df, (jpeak(n)-1)*tstep write(*,*) '<DecodeDebug> red candidate', red(n), n*df, (jpeak(n)-1)*tstep
flush(6) flush(6)
endif endif
k=k+1 k=k+1
candidate0(1,k)=n*df candidate0(1,k)=n*df
candidate0(2,k)=(jpeak(n)-1)*tstep candidate0(2,k)=(jpeak(n)-1)*tstep
candidate0(3,k)=red(n) candidate0(3,k)=red(n)
@ -181,14 +186,13 @@ subroutine syncjs8(dd,icos,nfa,nfb,syncmin,nfqso,s,candidate,ncand,sbase)
if(abs(candidate0(1,i)-nfqso).lt.10.0) candidate0(1,i)=-candidate0(1,i) if(abs(candidate0(1,i)-nfqso).lt.10.0) candidate0(1,i)=-candidate0(1,i)
enddo enddo
fac=20.0/maxval(s) fac=20.0/maxval(s)
s=fac*s s=fac*s
! Sort by sync ! Sort by sync
! call indexx(candidate0(3,1:ncand),ncand,indx) ! call indexx(candidate0(3,1:ncand),ncand,indx)
! Sort by frequency ! Sort by frequency
call indexx(candidate0(1,1:ncand),ncand,indx) call indexx(candidate0(1,1:ncand),ncand,indx)
k=1 k=1

View File

@ -32,7 +32,7 @@ subroutine syncjs8d(cd0,icos,i0,ctwk,itwk,sync)
flush(6) flush(6)
endif endif
! Set some constants and compute the csync array. ! Set some constants and compute the csync array.
if( first ) then if( first ) then
twopi=8.0*atan(1.0) twopi=8.0*atan(1.0)
@ -58,7 +58,7 @@ subroutine syncjs8d(cd0,icos,i0,ctwk,itwk,sync)
phic=mod(phia+dphic,twopi) phic=mod(phia+dphic,twopi)
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug> computing costas waveforms', k, i, j, phia, phib, phic, dphia, dphib, dphic write(*,*) '<DecodeDebug> computing costas waveforms', i, j, phia, phib, phic, dphia, dphib, dphic
flush(6) flush(6)
endif endif
enddo enddo

View File

@ -35,7 +35,7 @@ contains
procedure(js8a_decode_callback) :: callback procedure(js8a_decode_callback) :: callback
real s(NH1,NHSYM) real s(NH1,NHSYM)
real sbase(NH1) real sbase(NH1)
real candidate(3,200) real candidate(3,NMAXCAND)
real dd(NMAX) real dd(NMAX)
logical, intent(in) :: lft8apon,lapcqonly,nagain logical, intent(in) :: lft8apon,lapcqonly,nagain
logical newdat,lsubtract,ldupe,bcontest logical newdat,lsubtract,ldupe,bcontest
@ -97,6 +97,16 @@ contains
if(NWRITELOG.eq.1) then if(NWRITELOG.eq.1) then
write(*,*) '<DecodeDebug>', ncand, "candidates" write(*,*) '<DecodeDebug>', ncand, "candidates"
flush(6) flush(6)
do icand=1,ncand
sync=candidate(3,icand)
f1=candidate(1,icand)
xdt=candidate(2,icand)
xbase=10.0**(0.1*(sbase(nint(f1/(12000.0/NFFT1)))-40.0)) ! 3.125Hz
write(*,*) '<DecodeDebug> candidate', icand, 'f1', f1, 'sync', sync, 'xdt', xdt, 'xbase', xbase
flush(6)
enddo
endif endif
do icand=1,ncand do icand=1,ncand

View File

@ -35,7 +35,7 @@ contains
procedure(js8b_decode_callback) :: callback procedure(js8b_decode_callback) :: callback
real s(NH1,NHSYM) real s(NH1,NHSYM)
real sbase(NH1) real sbase(NH1)
real candidate(3,200) real candidate(3,NMAXCAND)
real dd(NMAX) real dd(NMAX)
logical, intent(in) :: lft8apon,lapcqonly,nagain logical, intent(in) :: lft8apon,lapcqonly,nagain
logical newdat,lsubtract,ldupe,bcontest logical newdat,lsubtract,ldupe,bcontest

View File

@ -35,7 +35,7 @@ contains
procedure(js8c_decode_callback) :: callback procedure(js8c_decode_callback) :: callback
real s(NH1,NHSYM) real s(NH1,NHSYM)
real sbase(NH1) real sbase(NH1)
real candidate(3,200) real candidate(3,NMAXCAND)
real dd(NMAX) real dd(NMAX)
logical, intent(in) :: lft8apon,lapcqonly,nagain logical, intent(in) :: lft8apon,lapcqonly,nagain
logical newdat,lsubtract,ldupe,bcontest logical newdat,lsubtract,ldupe,bcontest

View File

@ -35,7 +35,7 @@ contains
procedure(js8e_decode_callback) :: callback procedure(js8e_decode_callback) :: callback
real s(NH1,NHSYM) real s(NH1,NHSYM)
real sbase(NH1) real sbase(NH1)
real candidate(3,200) real candidate(3,NMAXCAND)
real dd(NMAX) real dd(NMAX)
logical, intent(in) :: lft8apon,lapcqonly,nagain logical, intent(in) :: lft8apon,lapcqonly,nagain
logical newdat,lsubtract,ldupe,bcontest logical newdat,lsubtract,ldupe,bcontest

View File

@ -35,7 +35,7 @@ contains
procedure(js8i_decode_callback) :: callback procedure(js8i_decode_callback) :: callback
real s(NH1,NHSYM) real s(NH1,NHSYM)
real sbase(NH1) real sbase(NH1)
real candidate(3,200) real candidate(3,NMAXCAND)
real dd(NMAX) real dd(NMAX)
logical, intent(in) :: lft8apon,lapcqonly,nagain logical, intent(in) :: lft8apon,lapcqonly,nagain
logical newdat,lsubtract,ldupe,bcontest logical newdat,lsubtract,ldupe,bcontest