From 335cc41faa09462ee60c8e78d59c468a6579d03d Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 4 Aug 2020 13:13:49 -0400 Subject: [PATCH] More code cleanup. Rename sync66a to sync66. --- CMakeLists.txt | 2 +- lib/qra66_decode.f90 | 2 +- lib/sync66.f90 | 142 +++++++++++++++++++++++++++---------------- lib/sync66a.f90 | 98 ----------------------------- 4 files changed, 92 insertions(+), 152 deletions(-) delete mode 100644 lib/sync66a.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index fe32cc8f5..de57adccb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -577,7 +577,7 @@ set (wsjt_FSRCS lib/symspec65.f90 lib/sync4.f90 lib/sync64.f90 - lib/sync66a.f90 + lib/sync66.f90 lib/sync65.f90 lib/ft4/getcandidates4.f90 lib/ft4/get_ft4_bitmetrics.f90 diff --git a/lib/qra66_decode.f90 b/lib/qra66_decode.f90 index 8892769d0..f914a1fb2 100644 --- a/lib/qra66_decode.f90 +++ b/lib/qra66_decode.f90 @@ -92,7 +92,7 @@ contains call four2a(c0,nfft2,1,1,1) !Inverse c2c FFT call timer('sync66 ',0) - call sync66a(iwave,15*12000,nsps,nfqso,ntol,xdt,f0,snr1) + call sync66(iwave,15*12000,nsps,nfqso,ntol,xdt,f0,snr1) call timer('sync66 ',1) jpk=(xdt+0.5)*6000 - 384 !### Empirical ### if(jpk.lt.0) jpk=0 diff --git a/lib/sync66.f90 b/lib/sync66.f90 index bc8b41805..e259f04ac 100644 --- a/lib/sync66.f90 +++ b/lib/sync66.f90 @@ -1,60 +1,98 @@ -subroutine sync66(c0,f0,jpk,sync) +subroutine sync66(iwave,nmax,nsps,nfqso,ntol,xdt,f0,snr1) -! Use the sync vector to find xdt (and improved f0 ?) - - PARAMETER (NMAX=15*6000) - parameter (NSPS=960) !Samples per symbol at 6000 Hz - complex c0(0:NMAX-1) !Complex data at 6000 S/s - complex csync0(0:NSPS-1) - complex csync1(0:NSPS-1) - complex z - integer b11(11) !Barker 11 code - data b11/1,1,1,0,0,0,1,0,0,1,0/ !Barker 11 definition - data mode66z/-1/ - save + parameter (NSTEP=4) !Quarter-symbol steps + parameter (IZ=1600,JZ=352,NSPSMAX=1920) + integer*2 iwave(0:nmax-1) !Raw data + integer b11(11) !Barker 11 code + integer ijpk(2) !Indices i and j at peak of sync_sig + real s1(IZ,JZ) !Symbol spectra + real x(JZ) !Work array; 2FSK sync modulation + real sync(4*85) !sync vector + real sync_sig(-64:64,-15:15) + complex c0(0:NSPSMAX) !Complex spectrum of symbol + data b11/1,1,1,0,0,0,1,0,0,1,0/ !Barker 11 code + data sync(1)/99.0/ + save sync - twopi=8.0*atan(1.0) - baud=6000.0/NSPS - dt=1.0/6000.0 - - dphi0=twopi*f0**dt - dphi1=twopi*(f0+baud)*dt - phi0=0. - phi1=0. - - do i=0,NSPS-1 !Compute csync for f0 and f0+baud - csync0(i)=cmplx(cos(phi0),sin(phi0)) - csync1(i)=cmplx(cos(phi1),sin(phi1)) - phi0=phi0 + dphi0 - phi1=phi1 + dphi1 - if(phi0.gt.twopi) phi0=phi0-twopi - if(phi1.gt.twopi) phi1=phi1-twopi - enddo - - sqmax=0. - jstep=NSPS/8 - do j0=0,6000,jstep - sq=0. + if(sync(1).eq.99.0) then + sync=0. do k=1,22 - i=k - if(i.gt.11) i=i-11 - j1=j0 + 4*(k-1)*NSPS - if(b11(i).eq.0) then - z=dot_product(c0(j1:j1+NSPS-1),csync0) - else - z=dot_product(c0(j1:j1+NSPS-1),csync1) - endif - z=0.001*z - sq=sq + real(z)**2 + aimag(z)**2 + kk=k + if(kk.gt.11) kk=k-11 + sync(16*k-15)=2.0*b11(kk) - 1.0 + enddo + endif + + nfft=2*NSPS + df=12000.0/nfft !3.125 Hz + istep=nsps/NSTEP + fac=1/32767.0 + do j=1,JZ !Compute symbol spectra + ia=(j-1)*istep + ib=ia+nsps-1 + k=-1 + do i=ia,ib,2 + xx=iwave(i) + yy=iwave(i+1) + k=k+1 + c0(k)=fac*cmplx(xx,yy) + enddo + c0(k+1:nfft/2)=0. + call four2a(c0,nfft,1,-1,0) !r2c FFT + do i=1,IZ + s1(i,j)=real(c0(i))**2 + aimag(c0(i))**2 enddo - write(52,3052) j0/6000.0,sq,j0,j1 -3052 format(f10.6,f12.3,2i8) - if(sq.gt.smax) then - smax=sq - jpk=j0 - endif enddo - sync=smax + + i0=nint(nfqso/df) + call pctile(s1(i0-64:i0+192,1:JZ),129*JZ,40,base) + s1=s1/base + s1max=20.0 + +! Apply AGC + do j=1,JZ + x(j)=maxval(s1(i0-64:i0+192,j)) + if(x(j).gt.s1max) s1(i0-64:i0+192,j)=s1(i0-64:i0+192,j)*s1max/x(j) + enddo + + dt4=nsps/(NSTEP*12000.0) + j0=0.5/dt4 + + sync_sig=0. + ia=min(64,nint(ntol/df)) + do i=-ia,ia + x=s1(i0+2+i,:)-s1(i0+i,:) + do lag=-15,15 +! Make this simpler: just add the 22 nonzero values? + do n=1,4*85 + j=n+lag+11 + if(j.ge.1 .and. j.le.JZ) sync_sig(i,lag)=sync_sig(i,lag) + sync(n)*x(j) + enddo + enddo + enddo + + ijpk=maxloc(sync_sig) + ii=ijpk(1)-65 + jj=ijpk(2)-16 + +! Use peakup() here? + f0=nfqso + ii*df + jdt=jj + tsym=nsps/12000.0 + xdt=jdt*tsym/4.0 + + snr1=maxval(sync_sig)/22.0 + +! do i=-64,64 +! write(62,3062) nfqso+i*df,sync_sig(i,jj) +!3062 format(2f12.3) +! enddo + +! do j=-15,15 +! write(63,3063) j,j*dt4,sync_sig(ii,j) +!3063 format(i5,2f12.3) +! enddo return end subroutine sync66 + diff --git a/lib/sync66a.f90 b/lib/sync66a.f90 deleted file mode 100644 index 249c3b742..000000000 --- a/lib/sync66a.f90 +++ /dev/null @@ -1,98 +0,0 @@ -subroutine sync66a(iwave,nmax,nsps,nfqso,ntol,xdt,f0,snr1) - - parameter (NSTEP=4) !Quarter-symbol steps - parameter (IZ=1600,JZ=352,NSPSMAX=1920) - integer*2 iwave(0:nmax-1) !Raw data - integer b11(11) !Barker 11 code - integer ijpk(2) !Indices i and j at peak of sync_sig - real s1(IZ,JZ) !Symbol spectra - real x(JZ) !Work array; 2FSK sync modulation - real sync(4*85) !sync vector - real sync_sig(-64:64,-15:15) - complex c0(0:NSPSMAX) !Complex spectrum of symbol - data b11/1,1,1,0,0,0,1,0,0,1,0/ !Barker 11 code - data sync(1)/99.0/ - save sync - - if(sync(1).eq.99.0) then - sync=0. - do k=1,22 - kk=k - if(kk.gt.11) kk=k-11 - sync(16*k-15)=2.0*b11(kk) - 1.0 - enddo - endif - - nfft=2*NSPS - df=12000.0/nfft !3.125 Hz - istep=nsps/NSTEP - fac=1/32767.0 - do j=1,JZ !Compute symbol spectra - ia=(j-1)*istep - ib=ia+nsps-1 - k=-1 - do i=ia,ib,2 - xx=iwave(i) - yy=iwave(i+1) - k=k+1 - c0(k)=fac*cmplx(xx,yy) - enddo - c0(k+1:nfft/2)=0. - call four2a(c0,nfft,1,-1,0) !r2c FFT - do i=1,IZ - s1(i,j)=real(c0(i))**2 + aimag(c0(i))**2 - enddo - enddo - - i0=nint(nfqso/df) - call pctile(s1(i0-64:i0+192,1:JZ),129*JZ,40,base) - s1=s1/base - s1max=20.0 - -! Apply AGC - do j=1,JZ - x(j)=maxval(s1(i0-64:i0+192,j)) - if(x(j).gt.s1max) s1(i0-64:i0+192,j)=s1(i0-64:i0+192,j)*s1max/x(j) - enddo - - dt4=nsps/(NSTEP*12000.0) - j0=0.5/dt4 - - sync_sig=0. - ia=min(64,nint(ntol/df)) - do i=-ia,ia - x=s1(i0+2+i,:)-s1(i0+i,:) - do lag=-15,15 -! Make this simpler: just add the 22 nonzero values? - do n=1,4*85 - j=n+lag+11 - if(j.ge.1 .and. j.le.JZ) sync_sig(i,lag)=sync_sig(i,lag) + sync(n)*x(j) - enddo - enddo - enddo - - ijpk=maxloc(sync_sig) - ii=ijpk(1)-65 - jj=ijpk(2)-16 - -! Use peakup() here? - f0=nfqso + ii*df - jdt=jj - tsym=nsps/12000.0 - xdt=jdt*tsym/4.0 - - snr1=maxval(sync_sig)/22.0 - -! do i=-64,64 -! write(62,3062) nfqso+i*df,sync_sig(i,jj) -!3062 format(2f12.3) -! enddo - -! do j=-15,15 -! write(63,3063) j,j*dt4,sync_sig(ii,j) -!3063 format(i5,2f12.3) -! enddo - - return -end subroutine sync66a -