From 4573c78acdcb2f8aec68df439d9a1247f3c8c9e4 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Wed, 3 Mar 2021 11:52:36 -0500 Subject: [PATCH] Remove iscat Fortran routines. --- lib/geniscat.f90 | 55 ------------- lib/iscat.f90 | 206 ---------------------------------------------- lib/synciscat.f90 | 185 ----------------------------------------- 3 files changed, 446 deletions(-) delete mode 100644 lib/geniscat.f90 delete mode 100644 lib/iscat.f90 delete mode 100644 lib/synciscat.f90 diff --git a/lib/geniscat.f90 b/lib/geniscat.f90 deleted file mode 100644 index 6df6ed981..000000000 --- a/lib/geniscat.f90 +++ /dev/null @@ -1,55 +0,0 @@ -subroutine geniscat(msg,msgsent,itone) - -! Generate an ISCAT waveform. - - parameter (NSZ=1291) - character msg*28,msgsent*28 !Message to be transmitted - integer imsg(30) - integer itone(NSZ) - real*8 sps - character c*42 - integer icos(4) !Costas array - data icos/0,1,3,2/ - data nsync/4/,nlen/2/,ndat/18/ - data c/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ /.?@-'/ - - sps=256.d0*12000.d0/11025.d0 - nsym=int(30*12000.d0/sps) - nblk=nsync+nlen+ndat - - do i=22,1,-1 - if(msg(i:i).ne.' ' .and. msg(i:i).ne.char(0)) exit - enddo - nmsg=i - msglen=nmsg+1 - k=0 - kk=1 - imsg(1)=40 !Always start with BOM char: '@' - do i=1,nmsg !Define the tone sequence - imsg(i+1)=36 !Illegal char set to blank - do j=1,42 - if(msg(i:i).eq.c(j:j)) imsg(i+1)=j-1 - enddo - enddo - - do i=1,nsym !Total symbols in 30 s - j=mod(i-1,nblk)+1 - if(j.le.nsync) then - itone(i)=icos(j) !Insert 4x4 Costas array - else if(j.gt.nsync .and. j.le.nsync+nlen) then - itone(i)=msglen !Insert message-length indicator - if(j.ge.nsync+2) then - n=msglen + 5*(j-nsync-1) - if(n.gt.41) n=n-42 - itone(i)=n - endif - else - k=k+1 - kk=mod(k-1,msglen)+1 - itone(i)=imsg(kk) - endif - enddo - msgsent=msg - - return -end subroutine geniscat diff --git a/lib/iscat.f90 b/lib/iscat.f90 deleted file mode 100644 index 17d1454f5..000000000 --- a/lib/iscat.f90 +++ /dev/null @@ -1,206 +0,0 @@ -subroutine iscat(cdat0,npts0,nh,npct,t2,pick,cfile6,minsync,ntol, & - mousebutton,mode4,nafc,nmore,psavg,maxlines,nlines,line) - -! Decode an ISCAT signal - - parameter (NMAX=30*3101) - parameter (NSZ=4*1400) - character cfile6*6 !File time - character c42*42 - character msg*29,msg1*29,msgbig*29 - character*80 line(100) - character csync*1 - complex cdat0(NMAX) - complex cdat(NMAX) - real s0(288,NSZ) - real fs1(0:41,30) - real psavg(72) !Average spectrum of whole file - integer nsum(30) - integer ntol - integer icos(4) - logical pick,last - data icos/0,1,3,2/ - data nsync/4/,nlen/2/,ndat/18/ - data c42/'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ /.?@-'/ - save cdat,s0 - - nlines = 0 - fsample=3100.78125 !Sample rate after 9/32 downsampling - nsps=144/mode4 - - bigworst=-1.e30 !Silence compiler warnings ... - bigxsync=0. - bigsig=-1.e30 - msglenbig=0 - ndf0big=0 - nfdotbig=0 - bigt2=0. - bigavg=0. - bigtana=0. - if(nmore.eq.-999) bigsig=-1 !... to here - - last=.false. - do inf=1,6 !Loop over data-segment sizes - nframes=2**inf - if(nframes*24*nsps.gt.npts0) then - nframes=npts0/(24*nsps) - last=.true. - endif - npts=nframes*24*nsps - - do ia=1,npts0-npts,nsps*24 !Loop over start times stepped by 1 frame - ib=ia+npts-1 - cdat(1:npts)=cdat0(ia:ib) - t3=(ia + 0.5*npts)/fsample + 0.9 - if(pick) t3=t2+t3 - -! Compute symbol spectra and establish sync: - call synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol, & - mousebutton,mode4,nafc,psavg,xsync,sig,ndf0,msglen, & - ipk,jpk,idf,df1) - nfdot=nint(idf*df1) - - isync=xsync - if(msglen.eq.0 .or. isync.lt.max(minsync,0)) then - msglen=0 - worst=1. - avg=1. - ndf0=0 - cycle - endif - - ipk3=0 !Silence compiler warning - nblk=nsync+nlen+ndat - fs1=0. - nsum=0 - nfold=jsym/96 - jb=96*nfold - k=0 - n=0 - do j=jpk,jsym,4 !Fold information symbols into fs1 - k=k+1 - km=mod(k-1,nblk)+1 - if(km.gt.6) then - n=n+1 - m=mod(n-1,msglen)+1 - ii=nint(idf*float(j-jb/2)/float(jb)) - do i=0,41 - iii=ii+ipk+2*i - if(iii.ge.1 .and. iii.le.288) fs1(i,m)=fs1(i,m) + s0(iii,j) - enddo - nsum(m)=nsum(m)+1 - endif - enddo - - do m=1,msglen - fs1(0:41,m)=fs1(0:41,m)/nsum(m) - enddo - -! Read out the message contents: - msg= ' ' - msg1=' ' - mpk=0 - worst=9999. - sum=0. - do m=1,msglen - smax=0. - smax2=0. - do i=0,41 - if(fs1(i,m).gt.smax) then - smax=fs1(i,m) - ipk3=i - endif - enddo - do i=0,41 - if(fs1(i,m).gt.smax2 .and. i.ne.ipk3) smax2=fs1(i,m) - enddo - rr=0. - if(smax2.gt.0.0) rr=smax/smax2 - sum=sum + rr - if(rr.lt.worst) worst=rr - if(ipk3.eq.40) mpk=m - msg1(m:m)=c42(ipk3+1:ipk3+1) - enddo - - avg=sum/msglen - if(mpk.eq.1) then - msg=msg1(2:) - else if(mpk.lt.msglen) then - msg=msg1(mpk+1:msglen)//msg1(1:mpk-1) - else - msg=msg1(1:msglen-1) - endif - - ttot=npts/3100.78125 - - if(worst.gt.bigworst) then - bigworst=worst - bigavg=avg - bigxsync=xsync - bigsig=sig - ndf0big=ndf0 - nfdotbig=nfdot - msgbig=msg - msglenbig=msglen - bigt2=t3 - bigtana=nframes*24*nsps/fsample - endif - - isync = xsync - if(avg.gt.2.5 .and. xsync.ge.max(float(minsync),1.5) .and. & - maxlines.ge.2) then - nsig=nint(sig) - nworst=10.0*(worst-1.0) - navg=10.0*(avg-1.0) - if(nworst.gt.10) nworst=10 - if(navg.gt.10) navg=10 - tana=nframes*24*nsps/fsample - csync=' ' - if(isync.ge.1) csync='*' - if(nlines.le.maxlines-1) nlines = nlines + 1 - write(line(nlines),1020) cfile6,isync,nsig,t2,ndf0,nfdot,csync, & - msg(1:28),msglen,navg,nworst,tana,char(0) - endif - enddo - if(last) exit - enddo - - worst=bigworst - avg=bigavg - xsync=bigxsync - sig=bigsig - ndf0=ndf0big - nfdot=nfdotbig - msg=msgbig - msglen=msglenbig - t2=bigt2 - tana=bigtana - - isync=xsync - nworst=10.0*(worst-1.0) - navg=10.0*(avg-1.0) - if(nworst.gt.10) nworst=10 - if(navg.gt.10) navg=10 - - if(navg.le.0 .or. isync.lt.max(minsync,0)) then - msg=' ' - nworst=0 - navg=0 - ndf0=0 - nfdot=0 - sig=-20 - msglen=0 - tana=0. - t2=0. - endif - csync=' ' - if(isync.ge.1) csync='*' - nsig=nint(sig) - - if(nlines.le.maxlines-1) nlines = nlines + 1 - write(line(nlines),1020) cfile6,isync,nsig,t2,ndf0,nfdot,csync,msg(1:28), & - msglen,navg,nworst,tana,char(0) -1020 format(a6,2i4,f5.1,i5,i4,1x,a1,2x,a28,i4,i3,2x,i1,f5.1,a1) - - return -end subroutine iscat diff --git a/lib/synciscat.f90 b/lib/synciscat.f90 deleted file mode 100644 index 747eeca64..000000000 --- a/lib/synciscat.f90 +++ /dev/null @@ -1,185 +0,0 @@ -subroutine synciscat(cdat,npts,nh,npct,s0,jsym,df,ntol, & - mousebutton,mode4,nafc,psavg,xsync,sig,ndf0,msglen, & - ipk,jpk,idf,df1) - -! Synchronize an ISCAT signal -! cdat() is the downsampled analytic signal. -! Sample rate = fsample = BW = 11025 * (9/32) = 3100.78125 Hz -! npts, nsps, etc., are all reduced by 9/32 - - parameter (NMAX=30*3101) - parameter (NSZ=4*1400) - complex cdat(NMAX) - complex c(288) - real s0(288,NSZ) - real fs0(288,96) !108 = 96 + 3*4 - real savg(288) - real sref(288) - real psavg(72) !Average spectrum of whole file - integer icos(4) - data icos/0,1,3,2/ - data nsync/4/,nlen/2/,ndat/18/ - -! Silence compiler warnings: - sigbest=-20.0 - ndf0best=0 - msglenbest=0 - ipkbest=0 - jpkbest=0 - ipk2=0 - idfbest=mousebutton - - fsample=3100.78125 !New sample rate - nsps=144/mode4 - nsym=npts/nsps - 1 - nblk=nsync+nlen+ndat - nfft=2*nsps !FFTs at twice the symbol length, - - kstep=nsps/4 ! stepped by 1/4 symbol - df=fsample/nfft - fac=1.0/1000.0 !Somewhat arbitrary - savg=0. - s0=0. - - ia=1-kstep - do j=1,4*nsym !Compute symbol spectra - ia=ia+kstep - ib=ia+nsps-1 - if(ib.gt.npts) exit - c(1:nsps)=fac*cdat(ia:ib) - c(nsps+1:nfft)=0. - call four2a(c,nfft,1,-1,1) - do i=1,nfft - s0(i,j)=real(c(i))**2 + aimag(c(i))**2 - savg(i)=savg(i) + s0(i,j) !Accumulate avg spectrum - enddo - i0=40 - enddo - - jsym=4*nsym - savg=savg/jsym - - do i=1,71 !Compute spectrum in dB, for plot - if(mode4.eq.1) then - psavg(i)=2*db(savg(4*i)+savg(4*i-1)+savg(4*i-2)+savg(4*i-3)) + 1.0 - else - psavg(i)=2*db(savg(2*i)+savg(2*i-1)) + 7.0 - endif - enddo - - do i=nh+1,nfft-nh - call pctile(savg(i-nh),2*nh+1,npct,sref(i)) - enddo - sref(1:nh)=sref(nh+11) - sref(nfft-nh+1:nfft)=sref(nfft-nh) - - do i=1,nfft !Normalize the symbol spectra - fac=1.0/sref(i) - if(i.lt.11) fac=1.0/savg(11) - do j=1,jsym - s0(i,j)=fac*s0(i,j) - enddo - enddo - - nfold=jsym/96 - jb=96*nfold - - ttot=npts/fsample !Length of record (s) - df1=df/ttot !Step size for f1=fdot - idf1=int(-25.0/df1) - idf2=int(5.0/df1) - if(nafc.eq.0) then - idf1=0 - idf2=0 - else if(mod(-idf1,2).eq.1) then - idf1=idf1-1 - endif - - xsyncbest=0. - do idf=idf1,idf2 !Loop over fdot - fs0=0. - do j=1,jb !Fold s0 into fs0, modulo 4*nblk - k=mod(j-1,4*nblk)+1 - ii=nint(idf*float(j-jb/2)/float(jb)) - ia=max(1-ii,1) - ib=min(nfft-ii,nfft) - do i=ia,ib - fs0(i,k)=fs0(i,k) + s0(i+ii,j) - enddo - enddo - ref=nfold*4 - - i0=27 - if(mode4.eq.1) i0=95 - ia=i0-nint(ntol/df) - ib=i0+nint(ntol/df) - if(ia.lt.1) ia=1 - if(ib.gt.nfft-3) ib=nfft-3 - - smax=0. - ipk=1 - jpk=1 - do j=0,4*nblk-1 !Find sync pattern: lags 0-95 - do i=ia,ib !Search specified freq range - ss=0. - do n=1,4 !Sum over 4 sync tones - k=j+4*n-3 - if(k.gt.96) k=k-96 - ss=ss + fs0(i+2*icos(n),k) - enddo - if(ss.gt.smax) then - smax=ss - ipk=i !Frequency offset, DF - jpk=j+1 !Time offset, DT - endif - enddo - enddo - - xsync=smax/ref - 1.0 - if(nfold.lt.26) xsync=xsync * sqrt(nfold/26.0) - xsync=xsync-0.5 !Empirical - - sig=db(smax/ref - 1.0) - 15.0 - if(mode4.eq.1) sig=sig-5.0 -! if(sig.lt.-20 .or. xsync.lt.1.0) sig=-20.0 -! if(sig.lt.-20) sig=-20.0 - ndf0=nint(df*(ipk-i0)) - - smax=0. - ja=jpk+16 - if(ja.gt.4*nblk) ja=ja-4*nblk - jj=jpk+20 - if(jj.gt.4*nblk) jj=jj-4*nblk - do i=ipk,ipk+60,2 !Find User's message length - ss=fs0(i,ja) + fs0(i+10,jj) - if(ss.gt.smax) then - smax=ss - ipk2=i - endif - enddo - - msglen=(ipk2-ipk)/2 - if(msglen.lt.2 .or. msglen.gt.29) cycle - - if(xsync.ge.xsyncbest) then - xsyncbest=xsync - sigbest=sig - ndf0best=ndf0 - msglenbest=msglen - ipkbest=ipk - jpkbest=jpk - idfbest=idf - endif - enddo - - xsync=xsyncbest - sig=sigbest - ndf0=ndf0best - msglen=msglenbest - ipk=ipkbest - jpk=jpkbest - idf=idfbest - if(nafc.eq.0) idf=0 - - return -end subroutine synciscat