Several optional sync vectors.

This commit is contained in:
Joe Taylor 2024-02-26 15:08:48 -05:00
parent cbb42e9cdd
commit f263a70dd3
2 changed files with 49 additions and 29 deletions

View File

@ -23,7 +23,7 @@ subroutine sfox_sync(iwave,fsample,isync,f,t)
ftol=20.0
ia=nint((fsync-ftol)/df)
ib=nint((fsync+ftol)/df)
lagmax=1.0/dtstep
lagmax=1.5/dtstep
lag1=-lagmax
lag2=lagmax
@ -61,8 +61,6 @@ subroutine sfox_sync(iwave,fsample,isync,f,t)
enddo
savg=savg/jz
!###
ccfbest=0.
ibest=0
lagpk=0
@ -106,11 +104,20 @@ subroutine sfox_sync(iwave,fsample,isync,f,t)
! write(*,4100) ibest,lagbest,f,dxi*df,t,dxj*dtstep
!4100 format(2i6,2f10.1,2f10.3)
! print*,'aaa',ibest,lagbest
! do lag=lag1,lag2
! write(51,3051) lag*dtstep,ccf(ibest,lag)
!3051 format(2f12.4)
! enddo
nsum=0
sq=0.
do lag=lag1,lag2
if(abs(lag-lagbest).gt.3) then
sq=sq + ccf(ibest,lag)**2
nsum=nsum+1
endif
write(51,3051) lag*dtstep,ccf(ibest,lag)
3051 format(2f12.4)
enddo
rms=sqrt(sq/nsum)
snrsync=ccf(ibest,lagbest)/rms
! print*,'snr:',snrsync
return
end subroutine sfox_sync

View File

@ -13,6 +13,7 @@ program sfoxtest
integer isync(44)
integer jsync(171)
integer itone(171)
integer nsb(10)
real*4 xnoise(NMAX) !Random noise
real*4 dat(NMAX) !Generated real data
complex cdat(NMAX) !Generated complex waveform
@ -39,6 +40,8 @@ program sfoxtest
116, 122, 130, 131, 134, 136, 137, 140, 146, 154, &
159, 161, 163, 165/
data nsb/1,2,4,7,11,16,22,29,37,39/
nargs=iargc()
if(nargs.ne.11) then
print*,'Usage: sfoxtest f0 DT ITU M N K NS v hs nfiles snr'
@ -83,11 +86,13 @@ program sfoxtest
call sfox_init(mm0,nn0,kk0,itu,fspread,delay,fsample,ns0)
tsync=NSYNC/fsample
txt=(NN+NS)*NSPS/fsample
nstype=nv/10
nv=mod(nv,10)
write(*,1000) MM,NN,KK,NSPS,baud,bw,itu,tsync,txt
write(*,1000) MM,NN,KK,NSPS,baud,bw,itu,tsync,txt,nstype
1000 format('M:',i2,' Base code: (',i3,',',i3,') NSPS:',i5, &
' Baud:',f7.3,' BW:',f9.3/ &
'Channel: ',a2,' Tsync:',f4.1,' TxT:',f5.1/)
'Channel: ',a2,' Tsync:',f4.1,' TxT:',f5.1,' SyncType:',i2/)
! Allocate storage for arrays that depend on code parameters.
allocate(s3(0:NQ-1,0:NN-1))
@ -103,25 +108,33 @@ program sfoxtest
allocate(correct(0:NN-1))
idum=-1
jsync=0
jsync(1)=1
jsync(NDS)=1
ms=2
do i=1,100000
j=1 + (NDS-1)*ran1(idum)
if(jsync(j).eq.0) then
jsync(j)=1
ms=ms+1
if(ms.eq.NS) exit
endif
enddo
j=0
do i=1,NDS
if(jsync(i).eq.1) then
j=j+1
isync(j)=i
endif
enddo
if(nstype.eq.2) then
jsync=0
jsync(1)=1
jsync(NDS)=1
ms=2
do i=1,100000
j=1 + (NDS-1)*ran1(idum)
if(jsync(j).eq.0) then
jsync(j)=1
ms=ms+1
if(ms.eq.NS) exit
endif
enddo
j=0
do i=1,NDS
if(jsync(i).eq.1) then
j=j+1
isync(j)=i
endif
enddo
else if(nstype.eq.3) then
isync(1:10)=nsb
isync(11:20)=nsb + isync(10) + 2
isync(21:30)=nsb + isync(20) + 2
isync(31:40)=nsb + isync(30) + 2
isync(41:44)=nsb(1:4) + isync(40) + 2
endif
rms=100.
baud=fsample/nsps !Keying rate, 11.719 baud for nsps=1024