From df69562a9fc1cb7e75354684f8f24feff68e91ce Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Mon, 19 Oct 2020 15:24:32 -0400 Subject: [PATCH] More tweaks to QRA65 decoder. --- lib/qra65_decode.f90 | 32 +++++++++++++++----------------- lib/qra_loops.f90 | 9 ++++++--- lib/sync_qra65.f90 | 17 ++++++++++++++++- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/lib/qra65_decode.f90 b/lib/qra65_decode.f90 index beb174527..e7ff43626 100644 --- a/lib/qra65_decode.f90 +++ b/lib/qra65_decode.f90 @@ -118,21 +118,20 @@ contains call sync_qra65(iwave,ntrperiod*12000,mode65,nsps,nfqso,ntol,xdt,f0,snr1) call timer('sync_q65',1) - jpk0=(xdt+1.0)*6000 !### - if(jpk0.lt.0) jpk0=0 - - fac=1.0/32767.0 - dd=fac*iwave - nmode=65 - - call ana64(dd,npts,c00) - - call timer('qraloops',0) - call qra_loops(c00,npts/2,nmode,mode65,nsubmode,nFadingModel, & - ndepth,nc1,nc2,ng2,naptype,jpk0,xdt,f0,width,snr2,irc,dat4) - call timer('qraloops',1) - xdt=xdt+0.4 !### Empirical -- WHY ??? ### - snr2=snr2 + db(6912.0/nsps) + irc=-1 + if(snr1.ge.2.7) then + jpk0=(xdt+1.0)*6000 !### + if(jpk0.lt.0) jpk0=0 + fac=1.0/32767.0 + dd=fac*iwave + nmode=65 + call ana64(dd,npts,c00) + call timer('qraloops',0) + call qra_loops(c00,npts/2,nmode,mode65,nsubmode,nFadingModel, & + ndepth,nc1,nc2,ng2,naptype,jpk0,xdt,f0,width,snr2,irc,dat4) + call timer('qraloops',1) + snr2=snr2 + db(6912.0/nsps) + endif decoded=' ' if(irc.ge.0) then call unpackmsg(dat4,decoded) !Unpack the user message @@ -146,8 +145,7 @@ contains call this%callback(nutc,sync,nsnr,xdt,f0,decoded, & irc,qual,ntrperiod,fmid,w50) else - snr2=0. - nsnr=-30 + nsnr=db(snr1) - 32.0 !### TEMPORARY? ### call this%callback(nutc,sync,nsnr,xdt,f0,decoded, & irc,qual,ntrperiod,fmid,w50) diff --git a/lib/qra_loops.f90 b/lib/qra_loops.f90 index 73eeb20f7..f2d1e30e5 100644 --- a/lib/qra_loops.f90 +++ b/lib/qra_loops.f90 @@ -31,17 +31,19 @@ subroutine qra_loops(c00,npts2,mode,mode64,nsubmode,nFadingModel, & if(ndepth.eq.3) maxdist=30 do idf=1,idfmax - ndf=idfn/2 + ndf=idf/2 if(mod(idf,2).eq.0) ndf=-ndf a=0. - a(1)=-(f0+0.868*ndf) + a(1)=-(f0+0.4*ndf) call twkfreq(c00,c0,npts2,6000.0,a) do idt=1,idtmax ndt=idt/2 if(mod(idt,2).eq.0) ndt=-ndt jpk=jpk0 + 240*ndt !240/6000 = 0.04 s = tsym/32 if(jpk.lt.0) jpk=0 + call timer('spec64 ',0) call spec64(c0,nsps,mode,jpk,s3,LL,NN) + call timer('spec64 ',1) call pctile(s3,LL*NN,40,base) s3=s3/base where(s3(1:LL*NN)>s3lim) s3(1:LL*NN)=s3lim @@ -91,7 +93,8 @@ subroutine qra_loops(c00,npts2,mode,mode64,nsubmode,nFadingModel, & ndist=ndistx endif -200 continue +200 if(mode.eq.65) xdt=xdt+0.4 !### Empirical -- WHY ??? ### + !### For tests only: if(irc.ge.0) then open(53,file='fort.53',status='unknown',position='append') diff --git a/lib/sync_qra65.f90 b/lib/sync_qra65.f90 index b18aa8870..401efcc3c 100644 --- a/lib/sync_qra65.f90 +++ b/lib/sync_qra65.f90 @@ -97,7 +97,22 @@ subroutine sync_qra65(iwave,nmax,mode65,nsps,nfqso,ntol,xdt,f0,snr1) jpk=ijpk(2)-27 f0=nfqso + ipk*df xdt=jpk*dtstep - snr1=maxval(ccf)/22.0 + sq=0. + nsq=0 + do j=lag1,lag2 + if(abs(j-jpk).gt.6) then + sq=sq + ccf(ipk,j)**2 + nsq=nsq+1 + endif + enddo + rms=sqrt(sq/nsq) + snr1=ccf(ipk,jpk)/rms + +! do j=lag1,lag2 +! write(55,3055) j,j*dtstep,ccf(ipk,j)/rms +!3055 format(i5,f8.3,f10.3) +! enddo + return end subroutine sync_qra65