Add temporary program for testing JT65 and Q65 sync for possible use in MAP65.

This commit is contained in:
Joe Taylor 2021-05-11 12:50:18 -04:00
parent 28699d6224
commit 0e069f7f3b
4 changed files with 185 additions and 0 deletions

View File

@ -1,6 +1,7 @@
set (libm65_FSRCS
# Modules come first:
wideband_sync.f90
wideband2_sync.f90
# Non-module Fortran routines:
afc65b.f90
@ -135,6 +136,9 @@ target_link_libraries (m65 m65impl ${FFTW3_LIBRARIES})
add_executable (mapsim mapsim.f90)
target_link_libraries (mapsim m65impl ${FFTW3_LIBRARIES})
add_executable (synctest synctest.f90)
target_link_libraries (synctest m65impl ${FFTW3_LIBRARIES})
install (
TARGETS m65 mapsim
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime

View File

@ -19,6 +19,11 @@ subroutine decode0(dd,ss,savg,nstandalone)
call timer('decode0 ',0)
!###
! npol=1 + 3*nxpol
! write(50) nutc,npol,ss(1:npol,:,:),savg(1:npol,:)
!###
nkhz_center=nint(1000.0*(fcenter-int(fcenter)))
ntone_spacing=2**(nmode/10)
call timer('wb_sync ',0)

73
map65/libm65/synctest.f90 Normal file
View File

@ -0,0 +1,73 @@
program synctest
use wideband2_sync
use timer_module, only: timer
use timer_impl, only: init_timer, fini_timer
parameter (MAX0=1000,MAX_CANDIDATES=20)
real ss(4,322,NFFT),savg(4,NFFT)
real candidate(MAX_CANDIDATES,5) !snr1,f0,xdt0,ipol,flip
integer indx(NFFT)
logical skip
character*8 arg
open(50,file='50.a',form='unformatted',status='old')
call getarg(1,arg)
read (arg,*) iutc
do ifile=1,999
read(50,end=999) nutc,npol,ss(1:npol,:,:),savg(1:npol,:)
if(nutc.eq.iutc) exit
enddo
close(50)
call init_timer('timer.out')
call timer('synctest',0)
print*,nutc,npol
ntone_spacing=1
call timer('wb_sync ',0)
call wb2_sync(ss,savg,ntone_spacing)
call timer('wb_sync ',1)
df3=96000.0/NFFT
ia=nint(7000.0/df3)
ib=nint(89000.0/df3)
iz=ib-ia+1
do i=ia,ib
f0=0.001*i*df3
write(13,1000) f0,sync_dat(i,2:5)
1000 format(3f10.3,2f5.0)
enddo
call timer('indexx ',0)
call indexx(sync_dat(ia:ib,2),iz,indx)
call timer('indexx ',1)
k=0
do i=1,MAX0
j=indx(iz+1-i) + ia - 1
f0=0.001*j*df3
snr1=sync_dat(j,2)
if(snr1.lt.3.0) exit
skip=.false.
do n=1,k
diffhz=1000.0*(f0-candidate(n,2))
if(diffhz.gt.-10.0 .and. diffhz.lt.108.0) skip=.true.
enddo
if(skip) cycle
k=k+1
candidate(k,1)=snr1 !snr1
candidate(k,2)=f0 !f0
candidate(k,3)=sync_dat(j,3) !xdt0
candidate(k,4)=sync_dat(j,4) !ipol
candidate(k,5)=sync_dat(j,5) !flip
write(*,1010) k,candidate(k,1:5)
1010 format(i3,3f10.3,2f6.0)
if(k.ge.MAX_CANDIDATES) exit
enddo
999 call timer('synctest',1)
call timer('synctest',101)
call fini_timer()
end program synctest

View File

@ -0,0 +1,103 @@
module wideband2_sync
parameter (NFFT=32768)
integer isync(22)
integer nkhz_center
real sync_dat(NFFT,5) !fkhz, ccfmax, xdt, ipol, flip
contains
subroutine wb2_sync(ss,savg,ntone_spacing)
! Compute "orange sync curve" using the Q65 sync pattern
parameter (LAGMAX=30)
real ss(4,322,NFFT)
real savg(4,NFFT)
logical first
character*1 c1
integer isync0(22)
integer jsync0(63)
! Q65 sync symbols
data isync0/1,9,12,13,15,22,23,26,27,33,35,38,46,50,55,60,62,66,69,74,76,85/
data jsync0/ &
1, 4, 5, 9, 10, 11, 12, 13, 14, 16, 18, 22, 24, 25, 28, 32, &
33, 34, 37, 38, 39, 40, 42, 43, 45, 46, 47, 48, 52, 53, 55, 57, &
59, 60, 63, 64, 66, 68, 70, 73, 80, 81, 89, 90, 92, 95, 97, 98, &
100,102,104,107,108,111,114,119,120,121,122,123,124,125,126/
data first/.true./
save first
do j=322,1,-1
if(sum(ss(1,j,1:NFFT)).gt.0.0) exit
enddo
jz=j
tstep=2048.0/11025.0 !0.185760 s: 0.5*tsym_jt65, 0.3096*tsym_q65
if(first) then
fac=0.6/tstep
do i=1,22 !Expand the Q65 sync stride
isync(i)=nint((isync0(i)-1)*fac) + 1
enddo
do i=1,63
jsync0(i)=2*(jsync0(i)-1) + 1
enddo
first=.false.
endif
df=96000.0/NFFT
ia=nint(7000.0/df) !Flat frequency range for WSE converters
ib=nint(89000.0/df)
lagbest=-1
ipolbest=-1
do i=ia,ib
ccfmax=0.
do ipol=1,4
do lag=0,LAGMAX
ccf=0.
do j=1,22
k=isync(j) + lag
ccf=ccf + ss(ipol,k,i+1) + ss(ipol,k+1,i+1) + ss(ipol,k+2,i+1)
enddo
ccf=ccf - savg(ipol,i+1)*3*22/float(jz)
if(ccf.gt.ccfmax) then
ipolbest=ipol
lagbest=lag
ccfmax=ccf
flip=0.
endif
ccf=0.
do j=1,63
k=jsync0(j) + lag
ccf=ccf + ss(ipol,k,i+1) + ss(ipol,k+1,i+1)
enddo
ccf=ccf - savg(ipol,i+1)*2*63/float(jz)
if(ccf.gt.ccfmax) then
ipolbest=ipol
lagbest=lag
ccfmax=ccf
flip=1.0
endif
enddo ! lag
enddo !ipol
fkhz=0.001*i*df + nkhz_center - 48.0
xdt=lagbest*tstep-1.0
sync_dat(i,1)=fkhz
sync_dat(i,2)=ccfmax
sync_dat(i,3)=xdt
sync_dat(i,4)=ipolbest
sync_dat(i,5)=flip
enddo
call pctile(sync_dat(ia:ib,2),ib-ia+1,50,base)
sync_dat(ia:ib,2)=sync_dat(ia:ib,2)/base
return
end subroutine wb2_sync
end module wideband2_sync