diff --git a/lib/jt4.f90 b/lib/jt4.f90 index 4d91e1541..214072551 100644 --- a/lib/jt4.f90 +++ b/lib/jt4.f90 @@ -3,7 +3,6 @@ module jt4 integer iutc(MAXAVE) integer nfsave(MAXAVE) integer listutc(10) - logical ok(MAXAVE) real ppsave(207,7,MAXAVE) !Accumulated data for message averaging real rsymbol(207,7) real dtsave(MAXAVE) diff --git a/lib/jt4_decode.f90 b/lib/jt4_decode.f90 index 8b55ea6b5..57292d63c 100644 --- a/lib/jt4_decode.f90 +++ b/lib/jt4_decode.f90 @@ -114,6 +114,7 @@ contains real ccfblue(-5:540) !CCF in time real ccfred(-224:224) !CCF in frequency + real ps0(450) ! real z(458,65) logical first,prtavg @@ -123,7 +124,7 @@ contains data first/.true./,nutc0/-999/,nfreq0/-999999/ save - if(first .or. nclearave) then + if(first) then nsave=0 first=.false. blank=' ' @@ -154,15 +155,15 @@ contains ! Attempt to synchronize: look for sync pattern, get DF and DT. call timer('sync4 ',0) - call sync4(dat,npts,ntol,1,nfqso,4,mode4,minw+1,dtx,dfx, & - snrx,snrsync,ccfblue,ccfred,flip,width) + mousedf=nint(nfqso + 1.5*4.375*mode4 - 1270.46) + call sync4(dat,npts,ntol,1,MouseDF,4,mode4,minw+1,dtx,dfx, & + snrx,snrsync,ccfblue,ccfred,flip,width,ps0) sync=snrsync dtxz=dtx-0.8 nfreqz=dfx + 1270.46 - 1.5*4.375*mode4 call timer('sync4 ',1) snrx=db(sync) - 26. - if(snrx.lt.-26.0) snrx=-26.0 nsnr=nint(snrx) if(sync.lt.syncmin) then if (associated (this%decode_callback)) then @@ -226,8 +227,8 @@ contains nsave=mod(nsave-1,64)+1 call timer('avg4 ',0) call this%avg4(nutc,sync,dtx,flip,nfreq,mode4,ntol,ndepth,neme, & - nclearave,mycall,hiscall,hisgrid,nfanoave,avemsg,qave, & - deepave,ich,ndeepave) + mycall,hiscall,hisgrid,nfanoave,avemsg,qave,deepave,ich, & + ndeepave) call timer('avg4 ',1) endif @@ -284,8 +285,7 @@ contains end subroutine wsjt4 subroutine avg4(this,nutc,snrsync,dtxx,flip,nfreq,mode4,ntol,ndepth,neme, & - nclearave, mycall,hiscall,hisgrid,nfanoave,avemsg,qave,deepave, & - ichbest,ndeepave) + mycall,hiscall,hisgrid,nfanoave,avemsg,qave,deepave,ichbest,ndeepave) ! Decodes averaged JT4 data @@ -297,14 +297,14 @@ contains character*1 csync,cused(64) real sym(207,7) integer iused(64) - logical first,nclearave + logical first data first/.true./ save - if(first .or. nclearave) then + if(first) then iutc=-1 nfsave=0 - dtdiff=0.25 + dtdiff=0.2 first=.false. endif @@ -320,33 +320,19 @@ contains flipsave(nsave)=flip ppsave(1:207,1:7,nsave)=rsymbol(1:207,1:7) -10 dtsum=0. - nsum=0 - ok=.false. - - do i=1,nsave - if(iutc(i).lt.0) cycle - if(mod(iutc(i),2).ne.mod(nutc,2)) cycle !Use only same sequence - if(abs(nfreq-nfsave(i)).gt.ntol) cycle !Freq must match - if(flip.ne.flipsave(i)) cycle !Sync (*/#) must match - if(abs(dtxx-dtsave(i)).gt.2*dtdiff) cycle !Pk-to-pk DT range < 2*dtdiff - dtsum=dtsum+dtsave(i) - nsum=nsum+1 - ok(i)=.true. - enddo - dtave=0. - if(nsum.ge.1) dtave=dtsum/nsum - - sym=0. +10 sym=0. syncsum=0. dtsum=0. nfsum=0 nsum=0 - do i=1,nsave + + do i=1,64 cused(i)='.' - dttest=dtsave(i)-dtave - if(.not.ok(i)) cycle - if(abs(dttest).gt.dtdiff) cycle !DT must match + if(iutc(i).lt.0) cycle + if(mod(iutc(i),2).ne.mod(nutc,2)) cycle !Use only same sequence + if(abs(dtxx-dtsave(i)).gt.dtdiff) cycle !DT must match + if(abs(nfreq-nfsave(i)).gt.ntol) cycle !Freq must match + if(flip.ne.flipsave(i)) cycle !Sync (*/#) must match sym(1:207,1:7)=sym(1:207,1:7) + ppsave(1:207,1:7,i) syncsum=syncsum + syncsave(i) dtsum=dtsum + dtsave(i) diff --git a/lib/sync4.f90 b/lib/sync4.f90 index 4fdf6f481..c7f33b470 100644 --- a/lib/sync4.f90 +++ b/lib/sync4.f90 @@ -1,5 +1,5 @@ -subroutine sync4(dat,jz,ntol,NFreeze,nfqso,mode,mode4,minwidth, & - dtx,dfx,snrx,snrsync,ccfblue,ccfred1,flip,width) +subroutine sync4(dat,jz,ntol,NFreeze,MouseDF,mode,mode4,minwidth, & + dtx,dfx,snrx,snrsync,ccfblue,ccfred1,flip,width,ps0) ! Synchronizes JT4 data, finding the best-fit DT and DF. @@ -9,6 +9,7 @@ subroutine sync4(dat,jz,ntol,NFreeze,nfqso,mode,mode4,minwidth, & integer ntol !Range of DF search real dat(jz) real psavg(NHMAX) !Average spectrum of whole record + real ps0(450) !Avg spectrum for plotting real s2(NHMAX,NSMAX) !2d spectrum, stepped by half-symbols real ccfblue(-5:540) !CCF with pseudorandom sequence real ccfred(-450:450) !Peak of ccfblue, as function of freq @@ -22,6 +23,9 @@ subroutine sync4(dat,jz,ntol,NFreeze,nfqso,mode,mode4,minwidth, & data nch/1,2,4,9,18,36,72/ save +! write(*,3001) 'A',ntol,nfreeze,mousedf,mode,mode4,minwidth +!3001 format(a1,6i6) + ! Do FFTs of twice symbol length, stepped by half symbols. Note that ! we have already downsampled the data by factor of 2. nsym=207 @@ -42,21 +46,18 @@ subroutine sync4(dat,jz,ntol,NFreeze,nfqso,mode,mode4,minwidth, & nsmo=min(10*mode4,150) call flat1b(psavg,nsmo,s2,nh,nsteps,NHMAX,NSMAX) !Flatten spectra - if(mode4.ge.9) then - call smo(psavg,nh,tmp,mode4/4) - psavg=psavg/(mode4/4.0) - do j=1,nsteps - call smo(s2(1,j),nh,tmp,mode4/4) - enddo - s2=s2/(mode4/4.0) - endif + if(mode4.ge.9) call smo(psavg,nh,tmp,mode4/4) + + i0=132 + do i=1,450 + ps0(i)=5.0*(psavg(i0+2*i) + psavg(i0+2*i+1) - 2.0) + enddo ! Set freq and lag ranges famin=200.0 + 3*mode4*df fbmax=2700.0 - 3*mode4*df fa=famin fb=fbmax - mousedf=nint(nfqso + 1.5*4.375*mode4 - 1270.46) if(NFreeze.eq.1) then fa=max(famin,1270.46+MouseDF-ntol) fb=min(fbmax,1270.46+MouseDF+ntol) @@ -76,23 +77,21 @@ subroutine sync4(dat,jz,ntol,NFreeze,nfqso,mode,mode4,minwidth, & ccfred=0. jmax=-1000 jmin=1000 -! rewind 83 do ich=minwidth,7 !Find best width + kz=nch(ich)/2 savered=.false. - do i=ia,ib !Find best frequency channel for CCF + do i=ia+kz,ib-kz !Find best frequency channel for CCF call xcor4(s2,i,nsteps,nsym,lag1,lag2,ich,mode4,ccfblue,ccf0, & lagpk0,flip) j=i-i0 + 3*mode4 if(j.ge.-372 .and. j.le.372) then ccfred(j)=ccf0 -! write(83,4001) i*df,ccf0 -!4001 format(f10.1,e12.3) jmax=max(j,jmax) jmin=min(j,jmin) endif -! Normalize ccfblue so that baseline rms = 1.0 +! Find rms of the CCF, without main peak call slope(ccfblue(lag1),lag2-lag1+1,lagpk0-lag1+1.0) sync=abs(ccfblue(lagpk0)) @@ -174,28 +173,7 @@ subroutine sync4(dat,jz,ntol,NFreeze,nfqso,mode,mode4,minwidth, & enddo width=(i-i1)*df -! rewind 80 -! rewind 81 -! rewind 82 - -! do i=1,NHMAX -! write(80,3004) i*df,psavg(i),sum(s2(i,1:nsteps)) -!3004 format(f10.1,2e12.3) -! enddo - -! do i=jmin,jmax -! write(81,3001) i,ccfred1(i),width -!3001 format(i5,2f10.3) -! enddo -! do i=lag1,lag2 -! write(82,3002) i,ccfblue(i) -!3002 format(i5,f10.3) -! enddo -! flush(80) -! flush(81) -! flush(82) -! flush(83) - return end subroutine sync4 +include 'flat1b.f90'