summaryrefslogtreecommitdiff
path: root/qmap/libqmap
diff options
context:
space:
mode:
Diffstat (limited to 'qmap/libqmap')
-rwxr-xr-xqmap/libqmap/CMakeLists.txt9
-rwxr-xr-xqmap/libqmap/cfom.f9040
-rwxr-xr-xqmap/libqmap/cfom_iq.f9048
-rwxr-xr-xqmap/libqmap/chkstat.f9028
-rwxr-xr-xqmap/libqmap/decode0.f9027
-rwxr-xr-xqmap/libqmap/fftbig.f9056
-rwxr-xr-xqmap/libqmap/filbig.f90123
-rwxr-xr-xqmap/libqmap/four2a.f90115
-rwxr-xr-xqmap/libqmap/ftninit.f9013
-rwxr-xr-xqmap/libqmap/ftnquit.f902
-rwxr-xr-xqmap/libqmap/getcand2.f9077
-rwxr-xr-xqmap/libqmap/njunk.f902
-rwxr-xr-xqmap/libqmap/q65_sync.f9044
-rwxr-xr-xqmap/libqmap/q65b.f90102
-rwxr-xr-xqmap/libqmap/q65c.f9090
-rwxr-xr-xqmap/libqmap/qmapa.f9098
-rwxr-xr-xqmap/libqmap/read_qm.f9044
-rwxr-xr-xqmap/libqmap/recvpkt.f9021
-rwxr-xr-xqmap/libqmap/save_qm.f9063
-rwxr-xr-xqmap/libqmap/symspec.f9069
-rwxr-xr-xqmap/libqmap/zaptx.f909
21 files changed, 652 insertions, 428 deletions
diff --git a/qmap/libqmap/CMakeLists.txt b/qmap/libqmap/CMakeLists.txt
index ecf3ccdf..34e3382c 100755
--- a/qmap/libqmap/CMakeLists.txt
+++ b/qmap/libqmap/CMakeLists.txt
@@ -5,14 +5,14 @@ set (libq65_FSRCS
astro.f90
astro0.f90
astrosub.f90
+ chkstat.f90
dcoord.f90
decode0.f90
dot.f90
fchisq0.f90
- filbig.f90
- four2a.f90
+ fftbig.f90
ftninit.f90
- ftnquit.f90
+# ftnquit.f90
geocentric.f90
getcand2.f90
grid2deg.f90
@@ -24,12 +24,15 @@ set (libq65_FSRCS
q65c.f90
q65_sync.f90
qmapa.f90
+ read_qm.f90
recvpkt.f90
+ save_qm.f90
sun.f90
symspec.f90
timf2.f90
tm2.f90
toxyz.f90
+ zaptx.f90
f77_wisdom.f
)
diff --git a/qmap/libqmap/cfom.f90 b/qmap/libqmap/cfom.f90
new file mode 100755
index 00000000..986a39dc
--- /dev/null
+++ b/qmap/libqmap/cfom.f90
@@ -0,0 +1,40 @@
+subroutine cfom(dd,k0,k,ndop0)
+
+ parameter(NMAX=60*96000)
+ real dd(2,NMAX)
+ complex*16 w,wstep
+ complex*8 c
+ real*8 twopi,dphi
+ logical first
+ data first/.true./
+ save twopi,w,first
+
+ if(first) then
+ twopi=8.d0*atan(1.d0)
+ w=1.d0
+ first=.false.
+ endif
+
+ dop0=0.5*ndop0
+ dphi=dop0*twopi/96000.0
+ wstep=cmplx(cos(dphi),sin(dphi))
+
+ do j=k0+1,k
+ c=w*cmplx(dd(1,j),dd(2,j))
+ dd(1,j)=real(c)
+ dd(2,j)=aimag(c)
+ w=w*wstep
+ enddo
+
+ return
+end subroutine cfom
+
+subroutine zaptx(dd,k0,k)
+
+ parameter(NMAX=60*96000)
+ real dd(2,NMAX)
+
+ dd(1:2,k0+1:k)=0.
+
+ return
+end subroutine zaptx
diff --git a/qmap/libqmap/cfom_iq.f90 b/qmap/libqmap/cfom_iq.f90
new file mode 100755
index 00000000..f63af5ae
--- /dev/null
+++ b/qmap/libqmap/cfom_iq.f90
@@ -0,0 +1,48 @@
+program cfom_iq
+
+ parameter(NMAX=60*96000)
+ integer*2 id2(2,NMAX)
+ complex*16 c,w,wstep
+ real*8 fcenter,uth8,twopi,dphi
+ character*6 mygrid
+
+ twopi=8.d0*atan(1.d0)
+ open(10,file='231028_0131.iq',status='old',access='stream')
+ open(12,file='231028_0131.cfom',status='unknown',access='stream')
+
+ mygrid='FN20OG'
+ nyear=2023
+ month=10
+ nday=28
+ uth8=01 + 31.d0/60
+ nfreq=1296
+ call astrosub00(nyear,month,nday,uth8,nfreq,mygrid,ndop0)
+ call astrosub00(nyear,month,nday,uth8+1.d0/60.d0,nfreq,mygrid,ndop1)
+
+ print*,ndop0,ndop1
+
+ read(10) fcenter,id2(1:2,1:56*96000)
+ id2(1:2,56*96000+1:NMAX)=0
+
+ dop0=0.5*ndop0
+ dop1=0.5*ndop1
+ j=0
+ w=1.0
+ do isec=1,60
+ dop=dop0 + (isec-0.5)*(dop1-dop0)/60.
+ dphi=dop*twopi/96000.0
+ wstep=cmplx(cos(dphi),sin(dphi))
+ do n=1,96000
+ j=j+1
+ x=id2(1,j)
+ y=id2(2,j)
+ w=w*wstep
+ c=100.d0*w*cmplx(x,y)
+ id2(1,j)=0.01d0*real(c)
+ id2(2,j)=0.01d0*aimag(c)
+ enddo
+ enddo
+
+ write(12) fcenter,id2
+
+end program cfom_iq
diff --git a/qmap/libqmap/chkstat.f90 b/qmap/libqmap/chkstat.f90
new file mode 100755
index 00000000..cb0c69d1
--- /dev/null
+++ b/qmap/libqmap/chkstat.f90
@@ -0,0 +1,28 @@
+subroutine chkstat(dd,nhsym,pdb)
+
+ real dd(2,5760000)
+ real pdb(4)
+ integer ia(4),ib(4)
+ logical*1 btx0,btx1
+
+ btx0=.false.
+ btx1=.false.
+ ia(1)=23*96000+1
+ ib(1)=24*96000
+ ia(2)=27*96000+1
+ ib(2)=28*96000
+ ia(3)=53*96000+1
+ ib(3)=54*96000
+ ia(4)=57*96000+1
+ ib(4)=58*96000
+
+ do j=1,4
+ sq=0.
+ do i=ia(j),ib(j)
+ sq=sq + dd(1,i)*dd(1,i) + dd(2,i)*dd(2,i)
+ enddo
+ pdb(j)=db(1.0 + sq/(2.0*96000.0))
+ enddo
+
+ return
+end subroutine chkstat
diff --git a/qmap/libqmap/decode0.f90 b/qmap/libqmap/decode0.f90
index 7e61369d..55a58dc7 100755
--- a/qmap/libqmap/decode0.f90
+++ b/qmap/libqmap/decode0.f90
@@ -3,26 +3,26 @@ subroutine decode0(dd,ss,savg)
use timer_module, only: timer
parameter (NSMAX=60*96000)
- real*4 dd(2,NSMAX),ss(322,NFFT),savg(NFFT)
+ real*4 dd(2,NSMAX),ss(400,NFFT),savg(NFFT)
real*8 fcenter
integer offset
integer hist(0:32768)
+ logical*1 bAlso30
character mycall*12,hiscall*12,mygrid*6,hisgrid*6,datetime*20
character mycall0*12,hiscall0*12,hisgrid0*6
- character*60 result
- common/decodes/ndecodes,ncand,nQDecoderDone,nWDecoderBusy, &
- nWTransmitting,result(50)
+ character*64 result
+ common/decodes/ndecodes,ncand2,nQDecoderDone,nWDecoderBusy, &
+ nWTransmitting,kHzRequested,result(50)
common/npar/fcenter,nutc,fselected,mousedf,mousefqso,nagain, &
- ndepth,ndiskdat,neme,newdat,nfa,nfb,nfcal,nfshift, &
- mcall3,nkeep,ntol,nxant,nrxlog,nfsample,nxpol,nmode, &
+ ndepth,ndiskdat,ntx60,newdat,nfa,nfb,nfcal,nfshift, &
+ ntx30a,ntx30b,ntol,n60,nCFOM,nfsample,ndop58,nmode, &
ndop00,nsave,max_drift,offset,nhsym,mycall,mygrid, &
- hiscall,hisgrid,datetime
- data neme0/-99/
+ hiscall,hisgrid,datetime,junk1,junk2,bAlso30
save
nQDecoderDone=0
if(newdat.ne.0) then
- nz=96000*nhsym/5.3833
+ nz=96000*nhsym*0.15
hist=0
do i=1,nz
j1=min(abs(dd(1,i)),32768.0)
@@ -41,13 +41,12 @@ subroutine decode0(dd,ss,savg)
mycall0=mycall
hiscall0=hiscall
hisgrid0=hisgrid
- neme0=neme
call timer('qmapa ',0)
- call qmapa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb, &
- mousedf,mousefqso,nagain,nfshift,max_drift,offset, &
- nfcal,mycall,hiscall,hisgrid,nfsample,nmode,ndepth, &
- datetime,ndop00,fselected)
+ call qmapa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb, &
+ mousedf,mousefqso,nagain,ntx30a,ntx30b,nfshift,max_drift,offset, &
+ nfcal,mycall,hiscall,hisgrid,nfsample,nmode,ndepth, &
+ datetime,ndop00,fselected,bAlso30,nhsym,NCFOM)
call timer('qmapa ',1)
return
diff --git a/qmap/libqmap/fftbig.f90 b/qmap/libqmap/fftbig.f90
new file mode 100755
index 00000000..b807f6a1
--- /dev/null
+++ b/qmap/libqmap/fftbig.f90
@@ -0,0 +1,56 @@
+subroutine fftbig(dd,nmax)
+
+! Do the full length FFT of complex data stored in array dd(2,nmax).
+
+ use, intrinsic :: iso_c_binding
+
+ use FFTW3
+ use timer_module, only: timer
+ parameter (MAXFFT1=5376000)
+ real*4 dd(2,nmax) !Input data
+ complex ca(MAXFFT1) !FFT of input
+ real*8 df
+ type(C_PTR) :: plan1 !Pointer to FFTW plan
+ logical first
+ common/cacb/ca
+ equivalence (rfilt,cfilt)
+ data first/.true./,npatience/0/
+ save
+
+ if(nmax.lt.0) go to 900
+
+ nfft1=MAXFFT1
+ if(first) then
+ nflags=FFTW_ESTIMATE
+ if(npatience.eq.1) nflags=FFTW_ESTIMATE_PATIENT
+ if(npatience.eq.2) nflags=FFTW_MEASURE
+ if(npatience.eq.3) nflags=FFTW_PATIENT
+ if(npatience.eq.4) nflags=FFTW_EXHAUSTIVE
+
+! Plan the big FFT just once
+ call timer('FFTplan ',0)
+ plan1=fftwf_plan_dft_1d(nfft1,ca,ca,+1,nflags)
+ call timer('FFTplan ',1)
+ df=96000.d0/nfft1
+ first=.false.
+ endif
+
+ nz=min(nmax,nfft1)
+ do i=1,nz
+ ca(i)=cmplx(dd(1,i),dd(2,i))
+ enddo
+
+ if(nmax.lt.nfft1) then
+ do i=nmax+1,nfft1
+ ca(i)=0.
+ enddo
+ endif
+ call timer('FFTbig ',0)
+ call fftwf_execute_dft(plan1,ca,ca)
+ call timer('FFTbig ',1)
+ go to 999
+
+900 call fftwf_destroy_plan(plan1)
+
+999 return
+end subroutine fftbig
diff --git a/qmap/libqmap/filbig.f90 b/qmap/libqmap/filbig.f90
deleted file mode 100755
index 94a3fa1c..00000000
--- a/qmap/libqmap/filbig.f90
+++ /dev/null
@@ -1,123 +0,0 @@
-subroutine filbig(dd,nmax,f0,newdat,nfsample,c4a,n4)
-
-! Filter and downsample complex data stored in array dd(2,nmax).
-! Output is downsampled from 96000 Hz to 1375.125 Hz.
-
- use timer_module, only: timer
- parameter (MAXFFT1=5376000,MAXFFT2=77175)
- real*4 dd(2,nmax) !Input data
- complex ca(MAXFFT1) !FFT of input
- complex c4a(MAXFFT2) !Output data
- real*8 df
- real halfpulse(8) !Impulse response of filter (one sided)
- complex cfilt(MAXFFT2) !Filter (complex; imag = 0)
- real rfilt(MAXFFT2) !Filter (real)
- integer*8 plan1,plan2,plan3,plan4,plan5
- logical first
- include 'fftw3.f'
- common/cacb/ca
- equivalence (rfilt,cfilt)
- data first/.true./,npatience/1/
- data halfpulse/114.97547150,36.57879257,-20.93789101, &
- 5.89886379,1.59355187,-2.49138308,0.60910773,-0.04248129/
- save
-
- if(nmax.lt.0) go to 900
-
- nfft1=MAXFFT1
- nfft2=MAXFFT2
- if(nfsample.eq.95238) then
- nfft1=5120000
- nfft2=74088
- endif
-
- if(first) then
- nflags=FFTW_ESTIMATE
- if(npatience.eq.1) nflags=FFTW_ESTIMATE_PATIENT
- if(npatience.eq.2) nflags=FFTW_MEASURE
- if(npatience.eq.3) nflags=FFTW_PATIENT
- if(npatience.eq.4) nflags=FFTW_EXHAUSTIVE
-
-! Plan the FFTs just once
- call timer('FFTplans ',0)
- call sfftw_plan_dft_1d(plan1,nfft1,ca,ca,FFTW_BACKWARD,nflags)
- call sfftw_plan_dft_1d(plan3,nfft2,c4a,c4a,FFTW_FORWARD,nflags)
- call sfftw_plan_dft_1d(plan5,nfft2,cfilt,cfilt,FFTW_BACKWARD,nflags)
- call timer('FFTplans ',1)
-
-! Convert impulse response to filter function
- do i=1,nfft2
- cfilt(i)=0.
- enddo
- fac=0.00625/nfft1
- cfilt(1)=fac*halfpulse(1)
- do i=2,8
- cfilt(i)=fac*halfpulse(i)
- cfilt(nfft2+2-i)=fac*halfpulse(i)
- enddo
- call sfftw_execute(plan5)
-
- base=cfilt(nfft2/2+1)
- do i=1,nfft2
- rfilt(i)=real(cfilt(i))-base
- enddo
-
- df=96000.d0/nfft1
- if(nfsample.eq.95238) df=95238.1d0/nfft1
- first=.false.
- endif
-
-! When new data comes along, we need to compute a new "big FFT"
-! If we just have a new f0, continue with the existing ca.
-
- if(newdat.ne.0 .or. sum(abs(ca)).eq.0.0) then !### Test on ca should be unnecessary?
- nz=min(nmax,nfft1)
- do i=1,nz
- ca(i)=cmplx(dd(1,i),dd(2,i))
- enddo
-
- if(nmax.lt.nfft1) then
- do i=nmax+1,nfft1
- ca(i)=0.
- enddo
- endif
- call timer('FFTbig ',0)
- call sfftw_execute(plan1)
- call timer('FFTbig ',1)
-!### newdat=0
- endif
-
-! NB: f0 is the frequency at which we want our filter centered.
-! i0 is the bin number in ca closest to f0.
-
- i0=nint(f0/df) + 1
- nh=nfft2/2
- do i=1,nh !Copy data into c4a
- j=i0+i-1 !and apply the filter function
- if(j.ge.1 .and. j.le.nfft1) then
- c4a(i)=rfilt(i)*ca(j)
- else
- c4a(i)=0.
- endif
- enddo
- do i=nh+1,nfft2
- j=i0+i-1-nfft2
- if(j.lt.1) j=j+nfft1
- c4a(i)=rfilt(i)*ca(j)
- enddo
-
-! Do the short reverse transform, to go back to time domain.
- call timer('FFTsmall',0)
- call sfftw_execute(plan3)
- call timer('FFTsmall',1)
- n4=min(nmax/64,nfft2)
- go to 999
-
-900 call sfftw_destroy_plan(plan1)
- call sfftw_destroy_plan(plan2)
- call sfftw_destroy_plan(plan3)
- call sfftw_destroy_plan(plan4)
- call sfftw_destroy_plan(plan5)
-
-999 return
-end subroutine filbig
diff --git a/qmap/libqmap/four2a.f90 b/qmap/libqmap/four2a.f90
deleted file mode 100755
index 16a86bc5..00000000
--- a/qmap/libqmap/four2a.f90
+++ /dev/null
@@ -1,115 +0,0 @@
-subroutine four2a(a,nfft,ndim,isign,iform)
-
-! IFORM = 1, 0 or -1, as data is
-! complex, real, or the first half of a complex array. Transform
-! values are returned in array DATA. They are complex, real, or
-! the first half of a complex array, as IFORM = 1, -1 or 0.
-
-! The transform of a real array (IFORM = 0) dimensioned N(1) by N(2)
-! by ... will be returned in the same array, now considered to
-! be complex of dimensions N(1)/2+1 by N(2) by .... Note that if
-! IFORM = 0 or -1, N(1) must be even, and enough room must be
-! reserved. The missing values may be obtained by complex conjugation.
-
-! The reverse transformation of a half complex array dimensioned
-! N(1)/2+1 by N(2) by ..., is accomplished by setting IFORM
-! to -1. In the N array, N(1) must be the true N(1), not N(1)/2+1.
-! The transform will be real and returned to the input array.
-
-! This version of four2a makes calls to the FFTW library to do the
-! actual computations.
-
- use fftw3
- parameter (NPMAX=2100) !Max numberf of stored plans
- parameter (NSMALL=16384) !Max size of "small" FFTs
- complex a(nfft+1) !Array to be transformed
- complex aa(NSMALL) !Local copy of "small" a()
- integer nn(NPMAX),ns(NPMAX),nf(NPMAX) !Params of stored plans
- integer*8 nl(NPMAX),nloc !More params of plans
- integer*8 plan(NPMAX) !Pointers to stored plans
- logical found_plan
- data nplan/0/ !Number of stored plans
- common/patience/npatience,nthreads !Patience and threads for FFTW plans
- save plan,nplan,nn,ns,nf,nl
-
- if(nfft.lt.0) go to 999
-
- nloc=loc(a)
-
- found_plan = .false.
- !$omp critical(four2a_setup)
- do i=1,nplan
- if(nfft.eq.nn(i) .and. isign.eq.ns(i) .and. &
- iform.eq.nf(i) .and. nloc.eq.nl(i)) then
- found_plan = .true.
- exit
- end if
- enddo
-
- if(i.ge.NPMAX) stop 'Too many FFTW plans requested.'
-
- if (.not. found_plan) then
- nplan=nplan+1
- i=nplan
-
- nn(i)=nfft
- ns(i)=isign
- nf(i)=iform
- nl(i)=nloc
-
-! Planning: FFTW_ESTIMATE, FFTW_ESTIMATE_PATIENT, FFTW_MEASURE,
-! FFTW_PATIENT, FFTW_EXHAUSTIVE
- nflags=FFTW_ESTIMATE
- if(npatience.eq.1) nflags=FFTW_ESTIMATE_PATIENT
- if(npatience.eq.2) nflags=FFTW_MEASURE
- if(npatience.eq.3) nflags=FFTW_PATIENT
- if(npatience.eq.4) nflags=FFTW_EXHAUSTIVE
-
- if(nfft.le.NSMALL) then
- jz=nfft
- if(iform.eq.0) jz=nfft/2
- aa(1:jz)=a(1:jz)
- endif
-
- !$omp critical(fftw) ! serialize non thread-safe FFTW3 calls
- if(isign.eq.-1 .and. iform.eq.1) then
- call sfftw_plan_dft_1d(plan(i),nfft,a,a,FFTW_FORWARD,nflags)
- else if(isign.eq.1 .and. iform.eq.1) then
- call sfftw_plan_dft_1d(plan(i),nfft,a,a,FFTW_BACKWARD,nflags)
- else if(isign.eq.-1 .and. iform.eq.0) then
- call sfftw_plan_dft_r2c_1d(plan(i),nfft,a,a,nflags)
- else if(isign.eq.1 .and. iform.eq.-1) then
- call sfftw_plan_dft_c2r_1d(plan(i),nfft,a,a,nflags)
- else
- stop 'Unsupported request in four2a'
- endif
- !$omp end critical(fftw)
-
- if(nfft.le.NSMALL) then
- jz=nfft
- if(iform.eq.0) jz=nfft/2
- a(1:jz)=aa(1:jz)
- endif
- end if
- !$omp end critical(four2a_setup)
-
- call sfftw_execute(plan(i))
- return
-
-999 continue
-
- !$omp critical(four2a)
- do i=1,nplan
-! The test is only to silence a compiler warning:
- if(ndim.ne.-999) then
- !$omp critical(fftw) ! serialize non thread-safe FFTW3 calls
- call sfftw_destroy_plan(plan(i))
- !$omp end critical(fftw)
- end if
- enddo
-
- nplan=0
- !$omp end critical(four2a)
-
- return
-end subroutine four2a
diff --git a/qmap/libqmap/ftninit.f90 b/qmap/libqmap/ftninit.f90
index 7ed2fd16..e126537f 100755
--- a/qmap/libqmap/ftninit.f90
+++ b/qmap/libqmap/ftninit.f90
@@ -3,10 +3,8 @@ subroutine ftninit
use timer_impl, only: init_timer !,fini_timer, limtrace
use, intrinsic :: iso_c_binding, only: C_NULL_CHAR
use FFTW3
-! character*(*) appd
character*1 appd
character addpfx*8
- character wisfile*256
common/pfxcom/addpfx
lu=8
@@ -17,17 +15,6 @@ subroutine ftninit
open(12,file=appd//'/all_qmap.txt',status='unknown',position='append')
open(17,file=appd//'/red.dat',status='unknown')
open(19,file=appd//'/livecq.txt',status='unknown')
- open(71,file=appd//'/fort.71',status='unknown')
- open(72,file=appd//'/fort.72',status='unknown')
- open(73,file=appd//'/fort.73',status='unknown')
-
-! Import FFTW wisdom, if available:
- iret=fftwf_init_threads() !Initialize FFTW threading
-! Default to 1 thread, but use nthreads for the big ones
- call fftwf_plan_with_nthreads(1)
-! Import FFTW wisdom, if available
- wisfile=trim(appd)//'/m65_wisdom.dat'// C_NULL_CHAR
- iret=fftwf_import_wisdom_from_filename(wisfile)
return
end subroutine ftninit
diff --git a/qmap/libqmap/ftnquit.f90 b/qmap/libqmap/ftnquit.f90
index 5d84d9ec..1a329dee 100755
--- a/qmap/libqmap/ftnquit.f90
+++ b/qmap/libqmap/ftnquit.f90
@@ -2,7 +2,7 @@ subroutine ftnquit
! Destroy the FFTW plans
call four2a(a,-1,1,1,1)
- call filbig(id,-1,f0,newdat,nfsample,c4a,n4)
+ call fftbig(id,-1)
return
end subroutine ftnquit
diff --git a/qmap/libqmap/getcand2.f90 b/qmap/libqmap/getcand2.f90
index f0fb1b8a..08b0acc5 100755
--- a/qmap/libqmap/getcand2.f90
+++ b/qmap/libqmap/getcand2.f90
@@ -1,4 +1,5 @@
-subroutine getcand2(ss,savg0,nts_q65,nagain,ntol,f0_selected,cand,ncand)
+subroutine getcand2(ss,savg0,nts_q65,nagain,nhsym,ntx30a,ntx30b, &
+ ntol,f0_selected,bAlso30,cand,ncand2)
! Get candidates for Q65 decodes, based on presence of sync tone.
@@ -6,15 +7,18 @@ subroutine getcand2(ss,savg0,nts_q65,nagain,ntol,f0_selected,cand,ncand)
real :: snr !Relative S/N of sync detection
real :: f !Freq of sync tone, 0 to 96000 Hz
real :: xdt !DT of matching sync pattern, -1.0 to +4.0 s
+ integer :: ntrperiod !60 for Q65-60x, 30 for Q65-30x
+ integer :: iseq !0 for first half-minute, 1 for second half
end type candidate
parameter (NFFT=32768) !FFTs done in symspec()
parameter (MAX_CANDIDATES=50)
type(candidate) :: cand(MAX_CANDIDATES)
- real ss(322,NFFT) !Symbol spectra
+ real ss(400,NFFT) !Symbol spectra
real savg0(NFFT),savg(NFFT) !Average spectra over whole Rx sequence
integer ipk1(1) !Peak index of local portion of spectrum
logical sync_ok !True if sync pattern is present
+ logical*1 bAlso30
data nseg/16/,npct/40/
savg=savg0 !Save the original spectrum
@@ -35,7 +39,7 @@ subroutine getcand2(ss,savg0,nts_q65,nagain,ntol,f0_selected,cand,ncand)
nguard=5 !Guard range in bins
i1=1
i2=NFFT-nbw-nguard
- if(nagain.eq.1) then
+ if(nagain.ge.1) then
i1=nint((1000.0*f0_selected-ntol)/df)
i2=nint((1000.0*f0_selected+ntol)/df)
endif
@@ -48,20 +52,65 @@ subroutine getcand2(ss,savg0,nts_q65,nagain,ntol,f0_selected,cand,ncand)
i0=ipk1(1) + i - 1 !Index of local peak in savg()
fpk=0.001*i0*df !Frequency of peak (kHz)
! Check to see if sync tone is present.
- call q65_sync(ss,i0,nts_q65,sync_ok,snr_sync,xdt)
- if(.not.sync_ok) cycle
+ ntrperiod=60
+ iseq=0
+ if(nhsym.ge.200) then
+ call q65_sync(ss,i0,nts_q65,ntrperiod,iseq,sync_ok,snr_sync,xdt)
+ if(sync_ok) then
+! Sync tone is present, we have a candidate for decoding
+ j=j+1
+ cand(j)%f=fpk
+ cand(j)%xdt=xdt
+ cand(j)%snr=snr_sync
+ cand(j)%ntrperiod=ntrperiod
+ cand(j)%iseq=iseq
+ ia=max(1,min(i,i0-nguard))
+ ib=min(i0+nbw+nguard,32768)
+ savg(ia:ib)=0.
+ if(j.ge.MAX_CANDIDATES) exit
+ endif
+ endif
+
+ if(.not.bAlso30) cycle
+ ntrperiod=30
+
+ if(nhsym.le.200 .and. ntx30a.le.5) then
+ call q65_sync(ss,i0,nts_q65,ntrperiod,iseq,sync_ok,snr_sync,xdt)
+ if(sync_ok) then
+! Sync tone is present, we have a candidate for decoding
+ j=j+1
+ cand(j)%f=fpk
+ cand(j)%xdt=xdt
+ cand(j)%snr=snr_sync
+ cand(j)%ntrperiod=ntrperiod
+ cand(j)%iseq=iseq
+ ia=max(1,min(i,i0-nguard))
+ ib=min(i0+nbw+nguard,32768)
+ savg(ia:ib)=0.
+ if(j.ge.MAX_CANDIDATES) exit
+ endif
+ endif
+ iseq=1
+ if(nhsym.ge.330 .and. ntx30b.le.5) then
+ call q65_sync(ss,i0,nts_q65,ntrperiod,iseq,sync_ok,snr_sync,xdt)
+ if(sync_ok) then
! Sync tone is present, we have a candidate for decoding
- j=j+1
- cand(j)%f=fpk
- cand(j)%xdt=xdt
- cand(j)%snr=snr_sync
- ia=max(1,min(i,i0-nguard))
- ib=min(i0+nbw+nguard,32768)
- savg(ia:ib)=0.
- if(j.ge.MAX_CANDIDATES) exit
+ j=j+1
+ cand(j)%f=fpk
+ cand(j)%xdt=xdt
+ cand(j)%snr=snr_sync
+ cand(j)%ntrperiod=ntrperiod
+ cand(j)%iseq=iseq
+ ia=max(1,min(i,i0-nguard))
+ ib=min(i0+nbw+nguard,32768)
+ savg(ia:ib)=0.
+ if(j.ge.MAX_CANDIDATES) exit
+ endif
+ endif
+
enddo
- ncand=j !Total number of candidates found
+ ncand2=j !Total number of candidates found
return
end subroutine getcand2
diff --git a/qmap/libqmap/njunk.f90 b/qmap/libqmap/njunk.f90
index 04dfa916..8fa19aca 100755
--- a/qmap/libqmap/njunk.f90
+++ b/qmap/libqmap/njunk.f90
@@ -1 +1 @@
- parameter(NJUNK=41)
+ parameter(NJUNK=42)
diff --git a/qmap/libqmap/q65_sync.f90 b/qmap/libqmap/q65_sync.f90
index dec46f91..3e20d7a8 100755
--- a/qmap/libqmap/q65_sync.f90
+++ b/qmap/libqmap/q65_sync.f90
@@ -1,38 +1,42 @@
-subroutine q65_sync(ss,i0,nts_q65,sync_ok,snr,xdt)
+subroutine q65_sync(ss,i0,nts_q65,ntrperiod,iseq,sync_ok,snr,xdt)
! Test for presence of Q65 sync tone
parameter (NFFT=32768)
parameter (LAGMAX=33)
- real ss(322,NFFT) !Symbol spectra
+ real ss(400,NFFT) !Symbol spectra
real ccf(0:LAGMAX) !The WSJT "blue curve", peak at DT
logical sync_ok
- logical first
- integer isync(22),ipk(1)
+ integer isync0(22),isync(22),ipk(1)
! Q65 sync symbols
- data isync/1,9,12,13,15,22,23,26,27,33,35,38,46,50,55,60,62,66,69,74,76,85/
- data first/.true./
- save first,isync
+ data isync0/1,9,12,13,15,22,23,26,27,33,35,38,46,50,55,60,62,66,69,74,76,85/
- tstep=2048.0/11025.0 !0.185760 s: 0.5*tsym_jt65, 0.3096*tsym_q65
- if(first) then
- fac=0.6/tstep !3.230
- do i=1,22 !Expand the Q65 sync stride
- isync(i)=nint((isync(i)-1)*fac) + 1
- enddo
- first=.false.
- endif
+ sync_ok=.false.
+! if(ntrperiod.ne.60) return
+
+ tstep=0.15 !0.5*tsym_Q65-30x, 0.25*tsys_Q65-60x
+ nfac=4
+ if(ntrperiod.eq.30) nfac=2
+ do i=1,22 !Expand sync stride for Q65-60x
+ isync(i)=nfac*(isync0(i)-1) + 1
+ enddo
m=nts_q65/2
+ if(ntrperiod.eq.30) m=nts_q65/4
i1=max(1,i0-m)
i2=min(NFFT,i0+m)
ccf=0.
do lag=0,LAGMAX !Search over range of DT
do j=1,22 !Test for Q65 sync
- k=isync(j) + lag
- ccf(lag)=ccf(lag) + sum(ss(k,i1:i2)) + sum(ss(k+1,i1:i2)) &
- + sum(ss(k+2,i1:i2))
+ k=isync(j) + lag + iseq*200
+ if(k.ge.400) cycle
+ if(ntrperiod.eq.60) then
+ ccf(lag)=ccf(lag) + sum(ss(k,i1:i2)) + sum(ss(k+1,i1:i2)) &
+ + sum(ss(k+2,i1:i2)) + sum(ss(k+3,i1:i2))
+ else
+ ccf(lag)=ccf(lag) + sum(ss(k,i1:i2)) + sum(ss(k+1,i1:i2))
+ endif
! Q: Should we use weighted sums, perhaps a Lorentzian peak?
enddo
enddo
@@ -40,16 +44,20 @@ subroutine q65_sync(ss,i0,nts_q65,sync_ok,snr,xdt)
ipk=maxloc(ccf)
lagbest=ipk(1)-1
xdt=lagbest*tstep - 1.0
+ if(ntrperiod.eq.30) xd=xdt+0.6 !Why ???
xsum=0.
sq=0.
nsum=0
+ fpk=0.001*i0*96000.0/32768.0 + 32.0
do i=0,lagmax !Compute ave and rms of "blue curve"
if(abs(i-lagbest).gt.2) then
xsum=xsum+ccf(i)
sq=sq+ccf(i)**2
nsum=nsum+1
endif
+! write(40,3040) i,i*tstep-1.0,ccf(i),fpk
+!3040 format(i5,3f8.2)
enddo
ave=xsum/nsum
rms=sqrt(sq/nsum - ave*ave)
diff --git a/qmap/libqmap/q65b.f90 b/qmap/libqmap/q65b.f90
index 260aebf9..cd41626b 100755
--- a/qmap/libqmap/q65b.f90
+++ b/qmap/libqmap/q65b.f90
@@ -1,6 +1,7 @@
subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
- mycall0,hiscall0,hisgrid,mode_q65,f0,fqso,nkhz_center, newdat,nagain, &
- max_drift,offset,ndepth,datetime,ndop00,idec)
+ ntrperiod,iseq,mycall0,hiscall0,hisgrid,mode_q65,f0,fqso,nkhz_center, &
+ newdat,nagain,bClickDecode,max_drift,offset,ndepth,datetime,nCFOM, &
+ ndop00,nhsym,idec)
! This routine provides an interface between QMAP and the Q65 decoder
! in WSJT-X. All arguments are input data obtained from the QMAP GUI.
@@ -8,28 +9,34 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
! in common/cacb. Decoded messages are sent back to the GUI.
use q65_decode
+ use wavhdr
use timer_module, only: timer
parameter (MAXFFT1=5376000) !56*96000
parameter (MAXFFT2=336000) !56*6000 (downsampled by 1/16)
parameter (NMAX=60*12000)
parameter (RAD=57.2957795)
+ type(hdr) h
integer*2 iwave(60*12000)
integer offset
complex ca(MAXFFT1) !FFT of raw I/Q data from Linrad
complex cx(0:MAXFFT2-1),cz(0:MAXFFT2)
real*8 fcenter,freq0,freq1
+ logical*1 bClickDecode
character*12 mycall0,hiscall0
character*12 mycall,hiscall
character*6 hisgrid
character*4 grid4
- character*60 result
- character*20 datetime
- common/decodes/ndecodes,ncand,nQDecoderDone,nWDecoderBusy, &
- nWTransmitting,result(50)
+ character*3 csubmode
+ character*17 fname
+ character*64 result,ctmp
+ character*20 datetime,datetime1
+ common/decodes/ndecodes,ncand2,nQDecoderDone,nWDecoderBusy, &
+ nWTransmitting,kHzRequested,result(50)
common/cacb/ca
+ data ifile/0/
save
-
+
if(mycall0(1:1).ne.' ') mycall=mycall0
if(hiscall0(1:1).ne.' ') hiscall=hiscall0
if(hisgrid(1:4).ne.' ') grid4=hisgrid(1:4)
@@ -37,26 +44,18 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
! Find best frequency from sync_dat, the "orange sync curve".
df3=96000.0/32768.0
ipk=(1000.0*f0-1.0)/df3
+ if(nagain.ge.2) ipk = nint(1000.0*(fqso-nkhz_center+48.0)/df3)
nfft1=MAXFFT1
nfft2=MAXFFT2
df=96000.0/NFFT1
- if(nfsample.eq.95238) then
- nfft1=5120000
- nfft2=322560
- df=96000.0/nfft1
- endif
nh=nfft2/2
- f_mouse=1000.0*(fqso+48.0) + mousedf
k0=nint((ipk*df3-1000.0)/df)
- if(nagain.eq.1) k0=nint((f_mouse-1000.0)/df)
-
if(k0.lt.nh .or. k0.gt.MAXFFT1-nfft2+1) go to 900
fac=1.0/nfft2
- cx(0:nfft2-1)=ca(k0:k0+nfft2-1)
- cx=fac*cx
+ cx(0:nfft2-1)=fac*ca(k0:k0+nfft2-1)
! Here cx is frequency-domain data around the selected
-! QSO frequency, taken from the full-length FFT computed in filbig().
+! QSO frequency, taken from the full-length FFT computed in fftbig().
! Values for fsample, nfft1, nfft2, df, and the downsampled data rate
! are as follows:
@@ -89,19 +88,65 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
nsubmode=mode_q65-1
nfa=990 !Tight limits around ipk for the wideband decode
nfb=1010
- if(nagain.eq.1) then !For nagain=1, use limits of +/- ntol
+ if(nagain.ge.1) then !For nagain>=1, use limits of +/- ntol
nfa=max(100,1000-ntol)
nfb=min(2500,1000+ntol)
endif
nsnr0=-99 !Default snr for no decode
+ if(iseq.eq.1) iwave(1:360000)=iwave(360001:720000)
+
+ csubmode(1:2)='60'
+ csubmode(3:3)=char(ichar('A')+nsubmode)
+ nhhmmss=100*nutc
+ nutc1=nutc
+ datetime(12:13)='00'
+ datetime1=datetime
+ if(ntrperiod.eq.30) then
+ csubmode(1:2)='30'
+ nhhmmss=100*nutc + iseq*30
+ nutc1=nhhmmss
+ if(iseq.eq.1) datetime1(12:13)='30'
+ endif
+
+ if(nagain.ge.2) then
+ ifile=ifile+1
+ write(fname,1000) ifile
+1000 format('000000_',i6.6,'.wav')
+ open(27,file=fname,status='unknown',access='stream')
+ if(nagain.eq.2) then
+ h=default_header(12000,60*12000)
+ ia=1
+ ib=60*12000
+ else if(nagain.eq.3) then
+ h=default_header(12000,30*12000)
+ ia=1
+ ib=30*12000
+ else
+ h=default_header(12000,30*12000)
+ ia=30*12000 + 1
+ ib=60*12000
+ endif
+ write(27) h,iwave(ia:ib)
+ close(27)
+ go to 900
+ endif
+
! NB: Frequency of ipk is now shifted to 1000 Hz.
- call map65_mmdec(nutc,iwave,nqd,nsubmode,nfa,nfb,1000,ntol, &
- newdat,nagain,max_drift,ndepth,mycall,hiscall,hisgrid)
- MHz=fcenter
+ nagain2=0
+ call map65_mmdec(nutc1,iwave,nqd,ntrperiod,nsubmode,nfa,nfb,1000,ntol, &
+ newdat,nagain2,max_drift,ndepth,mycall,hiscall,hisgrid)
+ MHz=fcenter
freq0=MHz + 0.001d0*ikhz
if(nsnr0.gt.-99) then
+
+ do i=1,ndecodes !Check for dupes
+ i1=index(result(i)(42:),trim(msg0))
+! If this is a dupe, don't save it again:
+ if(i1.gt.0 .and. (.not.bClickDecode .or. nhsym.eq.390)) go to 800
+ enddo
+
nq65df=nint(1000*(0.001*k0*df+nkhz_center-48.0+1.000-1.27046-ikhz))-nfcal
nq65df=nq65df + nfreq0 - 1000
ikhz1=ikhz
@@ -110,15 +155,16 @@ subroutine q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
if(ndf.lt.-500) ikhz1=ikhz + (nq65df-500)/1000
ndf=nq65df - 1000*(ikhz1-ikhz)
freq1=freq0 + 0.001d0*(ikhz1-ikhz)
- ndecodes=ndecodes+1
frx=0.001*k0*df+nkhz_center-48.0+1.0 - 0.001*nfcal
fsked=frx - 0.001*ndop00/2.0 - 0.001*offset
- write(result(ndecodes),1120) nutc,frx,fsked,xdt0,nsnr0,trim(msg0)
-1120 format(i4.4,f9.3,f7.1,f7.2,i5,2x,a)
- write(12,1130) datetime,trim(result(ndecodes)(5:))
-1130 format(a11,1x,a)
+ ctmp=csubmode//' '//trim(msg0)
+ ndecodes=min(ndecodes+1,50)
+ write(result(ndecodes),1120) nhhmmss,frx,fsked,xdt0,nsnr0,trim(ctmp)
+1120 format(i6.6,f9.3,f7.1,f7.2,i5,2x,a)
+ write(12,1130) datetime1,trim(result(ndecodes)(7:))
+1130 format(a13,1x,a)
result(ndecodes)=trim(result(ndecodes))//char(0)
- idec=0
+800 idec=0
endif
900 flush(12)
diff --git a/qmap/libqmap/q65c.f90 b/qmap/libqmap/q65c.f90
index e2ac8cc1..42e24900 100755
--- a/qmap/libqmap/q65c.f90
+++ b/qmap/libqmap/q65c.f90
@@ -1,4 +1,4 @@
-subroutine q65c(itimer)
+subroutine q65c
use timer_module, only: timer
use timer_impl, only: fini_timer !, limtrace
@@ -10,42 +10,96 @@ subroutine q65c(itimer)
parameter (NFFT=32768)
include 'njunk.f90'
real*8 fcenter
+ real*4 pdb(4)
integer nparams0(NJUNK+3),nparams(NJUNK+3)
+! integer values(8)
logical first
+ logical*1 bAlso30
+ character*120 fname
+ character*22 revision
character*12 mycall,hiscall
character*6 mygrid,hisgrid
character*20 datetime
-
- common/datcom2/dd(2,5760000),ss(322,NFFT),savg(NFFT),nparams0
-
+ character*64 result
+ common/decodes/ndecodes,ncand2,nQDecoderDone,nWDecoderBusy, &
+ nWTransmitting,kHzRequested,result(50)
+ common/datcom2/dd(2,5760000),ss(400,NFFT),savg(NFFT),nparams0
+ common/savecom/revision,fname
!### REMEMBER that /npar/ is not updated until nparams=nparams0 is executed. ###
common/npar/fcenter,nutc,fselected,mousedf,mousefqso,nagain, &
- ndepth,ndiskdat,neme,newdat,nfcal,nfshift, &
- mcall3,nkeep,ntol,nxant,nrxlog,nfsample,nxpol,nmode, &
- ndop00,nsave,max_nhsym,mycall,mygrid,hiscall,hisgrid, &
- datetime,junk1,junk2
+ ndepth,ndiskdat,ntx60,newdat,nn1,nn2,nfcal,nfshift, &
+ ntx30a,ntx30b,ntol,n60,nCFOM,nfsample,ndop58,nmode, &
+ ndop00,nsave,nn3,nn4,nhsym,mycall,mygrid,hiscall,hisgrid, &
+ datetime,junk1,junk2,bAlso30
equivalence (nparams,fcenter)
data first/.true./
save first
nparams=nparams0 !Copy parameters into common/npar/
- if(itimer.ne.0) then
- call timer('decode0 ',101)
- call fini_timer
- return
- endif
-
- datetime(18:20)=':00'
+ datetime(12:)='00 '
npatience=1
newdat=1 !Always on ??
-! write(*,3001) 'aa',newdat,nagain,nfa,nfb,ntol,fselected
-!3001 format(a2,5i6,f10.3)
-! write(*,3001) 'bb',newdat,nagain,nfa,nfb,ntol,fselected
+ if(ndiskdat.eq.1) then
+ call chkstat(dd,nhsym,pdb)
+ if((abs(pdb(1)-pdb(2)).gt.3.0 .and. pdb(1).gt.1.0) .or. &
+ pdb(1).lt.1.0) ntx30a=20 !Tx 1st half
+ if((abs(pdb(3)-pdb(4)).gt.3.0 .and. pdb(3).gt.1.0) .or. &
+ pdb(3).lt.1.0) ntx30b=20 !Tx 2nd half
+ if(pdb(4).lt.0.04) then
+ ntx30a=0 !Older 56s files have no Tx
+ ntx30b=0 !Older 56s files have no Tx
+ endif
+ endif
+ if(ntx30a.gt.5) then
+ dd(1:2,1:30*96000)=0.
+ ss(1:200,1:NFFT)=0.
+ do i=1,NFFT
+ savg(i)=sum(ss(201:400,i))
+ enddo
+ endif
+ if(ntx30b.gt.5) then
+ dd(1:2,30*96000+1:60*96000)=0.
+ ss(201:400,1:NFFT)=0.
+ do i=1,NFFT
+ savg(i)=sum(ss(1:200,i))
+ enddo
+ endif
+
+ if(nhsym.gt.200 .and. ntx30b.gt.5) go to 10
call timer('decode0 ',0)
call decode0(dd,ss,savg)
call timer('decode0 ',1)
+10 continue
+! call date_and_time(VALUES=values)
+! n60b=values(7)
+! nd=n60b-n60
+! if(nd.lt.0) nd=nd+60
+! write(*,3002) nutc,nagain,nhsym,n60,n60b,nd,ntx30a,ntx30b,ndecodes, &
+! nsave,revision
+!3002 format('A',i5.4,i3,i5,7i4,1x,a22)
+! flush(6)
+
+ if(ndiskdat.eq.0) then
+ if(nhsym.eq.390 .and. &
+ (nsave.eq.2 .or. (nsave.eq.1 .and. ndecodes.ge.1))) then
+ call save_qm(fname,revision,mycall,mygrid,dd,ntx30a,ntx30b,fcenter, &
+ nutc,ndop00,ndop58)
+ endif
+ endif
+
return
end subroutine q65c
+
+subroutine all_done
+
+ use timer_module, only: timer
+ use timer_impl, only: fini_timer
+
+ call timer('decode0 ',101)
+ call fini_timer
+
+ return
+end subroutine all_done
diff --git a/qmap/libqmap/qmapa.f90 b/qmap/libqmap/qmapa.f90
index aead1daf..8d4f3381 100755
--- a/qmap/libqmap/qmapa.f90
+++ b/qmap/libqmap/qmapa.f90
@@ -1,6 +1,7 @@
subroutine qmapa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb, &
- mousedf,mousefqso,nagain,nfshift,max_drift,offset,nfcal,mycall, &
- hiscall,hisgrid,nfsample,nmode,ndepth,datetime,ndop00,fselected)
+ mousedf,mousefqso,nagain,ntx30a,ntx30b,nfshift,max_drift,offset, &
+ nfcal,mycall,hiscall,hisgrid,nfsample,nBaseSubmode,ndepth, &
+ datetime,ndop00,fselected,bAlso30,nhsym,nCFOM)
! Processes timf2 data received from Linrad to find and decode Q65 signals.
@@ -10,64 +11,109 @@ subroutine qmapa(dd,ss,savg,newdat,nutc,fcenter,ntol,nfa,nfb, &
real :: snr !Relative S/N of sync detection
real :: f !Freq of sync tone, 0 to 96000 Hz
real :: xdt !DT of matching sync pattern, -1.0 to +4.0 s
+ integer :: ntrperiod !60 for Q65-60x, 30 for Q65-30x
+ integer :: iseq !0 for first half-minute, 1 for second half
end type candidate
+ type good_decode
+ real :: f !Freq of sync tone, 0 to 96000 Hz
+ integer :: ntrperiod !60 for Q65-60x, 30 for Q65-30x
+ integer :: iseq !0 for first half-minute, 1 for second half
+ end type good_decode
+
parameter (NFFT=32768) !Size of FFTs done in symspec()
parameter (MAX_CANDIDATES=50)
parameter (MAXMSG=1000) !Size of decoded message list
parameter (NSMAX=60*96000)
- complex cx(NSMAX/64) !Data at 1378.125 samples/s
real dd(2,NSMAX) !I/Q data from Linrad
- real ss(322,NFFT) !Symbol spectra
+ real ss(400,NFFT) !Symbol spectra
real savg(NFFT) !Average spectrum
- real*8 fcenter !Center RF frequency, MHz
+ real*8 fcenter !Center RF frequency, MHz
+ logical*1 bAlso30,bClickDecode
character mycall*12,hiscall*12,hisgrid*6
type(candidate) :: cand(MAX_CANDIDATES)
- character*60 result
+ type(good_decode) found(MAX_CANDIDATES)
+ character*64 result
character*20 datetime
- common/decodes/ndecodes,ncand,nQDecoderDone,nWDecoderBusy, &
- nWTransmitting,result(50)
+ common/decodes/ndecodes,ncand2,nQDecoderDone,nWDecoderBusy, &
+ nWTransmitting,kHzRequested,result(50)
save
tsec0=sec_midn()
- if(nagain.eq.1) ndepth=3 !Use full depth for click-to-decode
+ if(nagain.ge.1) ndepth=3 !Use full depth for click-to-decode
nkhz_center=nint(1000.0*(fcenter-int(fcenter)))
mfa=nfa-nkhz_center+48
mfb=nfb-nkhz_center+48
- mode_q65=nmode/10
+ mode_q65=nBaseSubmode
nts_q65=2**(mode_q65-1) !Q65 tone separation factor
f0_selected=fselected - nkhz_center + 48.0
- call timer('get_cand',0)
-! Get a list of decoding candidates
- call getcand2(ss,savg,nts_q65,nagain,ntol,f0_selected,cand,ncand)
- call timer('get_cand',1)
+ if(nagain.le.1) then
+ call timer('get_cand',0)
+ ! Get a list of decoding candidates
+ call getcand2(ss,savg,nts_q65,nagain,nhsym,ntx30a,ntx30b,ntol, &
+ f0_selected,bAlso30,cand,ncand2)
+ call timer('get_cand',1)
+ endif
nwrite_q65=0
df=96000.0/NFFT !df = 96000/NFFT = 2.930 Hz
- if(nfsample.eq.95238) df=95238.1/NFFT
ftol=0.010 !Frequency tolerance (kHz)
foffset=0.001*(1270 + nfcal) !Offset from sync tone, plus CAL
fqso=mousefqso + foffset - 0.5*(nfa+nfb) + nfshift !fqso at baseband (khz)
nqd=0
- nagain2=0
+ bClickDecode=(nagain.ge.1)
- call timer('filbig ',0)
- call filbig(dd,NSMAX,f0,newdat,nfsample,cx,n5) !Do the full-length FFT
- call timer('filbig ',1)
+ call timer('fftbig ',0)
+ call fftbig(dd,NSMAX) !Do the full-length FFT
+ call timer('fftbig ',1)
- do icand=1,ncand !Attempt to decode each candidate
+ if(nagain.ge.2) then
+ ncand2=1
+ fqso=fselected
+ endif
+
+ do icand=1,ncand2 !Attempt to decode each candidate
+ tsec=sec_midn() - tsec0
+ if(ndiskdat.eq.0) then
+ ! No more realtime decode attempts if it's nearly too late, already
+ if(nhsym.eq.130 .and. tsec.gt.6.0) exit
+ if(nhsym.eq.200 .and. tsec.gt.10.0) exit
+ if(nhsym.eq.330 .and. tsec.gt.6.0) exit
+ if(nhsym.eq.390 .and. tsec.gt.16.0) exit
+ endif
f0=cand(icand)%f
- freq=cand(icand)%f+nkhz_center-48.0-1.27046
+ ntrperiod=cand(icand)%ntrperiod
+ iseq=cand(icand)%iseq
+
+ if(nagain.eq.0) then
+ ! Skip this candidate if we already decoded it.
+ do j=1,ndecodes
+ if(abs(f0-found(j)%f).lt.0.005 .and. &
+ ntrperiod.eq.found(j)%ntrperiod .and. &
+ iseq.eq.found(j)%iseq) go to 10
+ enddo
+ endif
+
+ mode_q65_tmp=mode_q65
+ if(ntrperiod.eq.30) mode_q65_tmp=max(1,mode_q65-1)
+ freq=f0+nkhz_center-48.0-1.27046
ikhz=nint(freq)
idec=-1
call timer('q65b ',0)
- call q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
- mycall,hiscall,hisgrid,mode_q65,f0,fqso,nkhz_center,newdat, &
- nagain2,max_drift,offset,ndepth,datetime,ndop00,idec)
+ call q65b(nutc,nqd,fcenter,nfcal,nfsample,ikhz,mousedf,ntol, &
+ ntrperiod,iseq,mycall,hiscall,hisgrid,mode_q65_tmp,f0,fqso, &
+ nkhz_center,newdat,nagain,bClickDecode,max_drift,offset, &
+ ndepth,datetime,nCFOM,ndop00,nhsym,idec)
call timer('q65b ',1)
- tsec=sec_midn() - tsec0
- if(tsec.gt.30.0) exit !Don't start another decode attempt after t=30 s.
+ if(bClickDecode .and. idec.ge.0) exit
+ if(idec.ge.0) then
+ ! Save some details on good decodes, to avoid duplicated effort
+ found(ndecodes)%f=f0
+ found(ndecodes)%ntrperiod=ntrperiod
+ found(ndecodes)%iseq=iseq
+ end if
+10 continue
enddo ! icand
return
diff --git a/qmap/libqmap/read_qm.f90 b/qmap/libqmap/read_qm.f90
new file mode 100755
index 00000000..52479918
--- /dev/null
+++ b/qmap/libqmap/read_qm.f90
@@ -0,0 +1,44 @@
+subroutine read_qm(fname,iret)
+
+ include 'njunk.f90'
+ parameter(NMAX=60*96000,NFFT=32768)
+ character*(*) fname
+ character prog_id*24,mycall*12,mygrid*6
+ real*8 fcenter
+ integer nxtra(15) !For possible future additions
+ integer*1 id1(2,NMAX)
+ common/datcom/dd(2,5760000),ss(400,NFFT),savg(NFFT), &
+ fcenter,nutc,fselected,mousedf,mousefqso,nagain, &
+ ndepth,ndiskdat,ntx60,newdat,nn1,nn2,nfcal,nfshift, &
+ ntx30a,ntx30b !...
+
+ open(28,file=trim(fname),status='old',access='stream',err=900)
+ read(28,end=910) prog_id,mycall,mygrid,fcenter,nutc,ntx30a, &
+ ntx30b,ndop00,ndop58,ia,ib,fac0,nxtra
+ iret=3
+ if(ib.eq.NMAX/2) iret=1
+ if(ia.eq.NMAX/2+1) iret=2
+ fac=1.0
+ if(fac0.gt.0.0) fac=1.0/fac0
+ id1=0
+ read(28,end=910) id1(1:2,ia:ib)
+ dd=0.
+ dd(1:2,ia:ib)=fac*id1(1:2,ia:ib) !Boost back to previous level
+ go to 999
+
+900 iret=-1; go to 999
+910 iret=-2
+
+999 close(28)
+
+! sq1=0.
+! sq2=0.
+! NH=NMAX/2
+! do i=1,NMAX
+! if(i.le.NH) sq1=sq1 + dd(1,i)*dd(1,i) + dd(2,i)*dd(2,i)
+! if(i.gt.NH) sq2=sq2 + dd(1,i)*dd(1,i) + dd(2,i)*dd(2,i)
+! enddo
+! print*,'B',sqrt(sq1/NMAX),sqrt(sq2/NMAX)
+
+ return
+end subroutine read_qm
diff --git a/qmap/libqmap/recvpkt.f90 b/qmap/libqmap/recvpkt.f90
index 0addb2f0..fd5e888f 100755
--- a/qmap/libqmap/recvpkt.f90
+++ b/qmap/libqmap/recvpkt.f90
@@ -1,4 +1,4 @@
-subroutine recvpkt(nsam,nblock2,userx_no,k,buf4,buf8)
+subroutine recvpkt(nsam,nblock2,userx_no,k,buf4,buf8,ndb)
! Reformat timf2 data from Linrad and stuff data into r*4 array dd().
@@ -11,11 +11,12 @@ subroutine recvpkt(nsam,nblock2,userx_no,k,buf4,buf8)
integer*2 jd(4),kd(2),nblock2
real*4 yd(2)
real*8 fcenter
- common/datcom/dd(2,5760000),ss(322,NFFT),savg(NFFT),fcenter,nutc, &
+ common/datcom/dd(2,5760000),ss(400,NFFT),savg(NFFT),fcenter,nutc, &
junk(NJUNK)
equivalence (kd,d4)
equivalence (jd,d8,yd)
+ gain=10.0**(0.05*ndb)
if(nblock2.eq.-9999) nblock2=-9998 !Silence a compiler warning
if(nsam.eq.-1) then
! Move data from the UDP packet buffer into array dd().
@@ -23,15 +24,15 @@ subroutine recvpkt(nsam,nblock2,userx_no,k,buf4,buf8)
do i=1,174 !One RF channel, r*4 data
k=k+1
d8=buf8(i)
- dd(1,k)=yd(1)
- dd(2,k)=yd(2)
+ dd(1,k)=yd(1)*gain
+ dd(2,k)=yd(2)*gain
enddo
else if(userx_no.eq.1) then
do i=1,348 !One RF channel, i*2 data
k=k+1
d4=buf4(i)
- dd(1,k)=kd(1)
- dd(2,k)=kd(2)
+ dd(1,k)=kd(1)*gain
+ dd(2,k)=kd(2)*gain
enddo
endif
else
@@ -39,12 +40,12 @@ subroutine recvpkt(nsam,nblock2,userx_no,k,buf4,buf8)
do i=1,nsam !One RF channel, r*4 data
k=k+1
d4=buf4(i)
- dd(1,k)=kd(1)
- dd(2,k)=kd(2)
+ dd(1,k)=kd(1)*gain
+ dd(2,k)=kd(2)*gain
k=k+1
- dd(1,k)=kd(1)
- dd(2,k)=kd(2)
+ dd(1,k)=kd(1)*gain
+ dd(2,k)=kd(2)*gain
enddo
endif
endif
diff --git a/qmap/libqmap/save_qm.f90 b/qmap/libqmap/save_qm.f90
new file mode 100755
index 00000000..9d636755
--- /dev/null
+++ b/qmap/libqmap/save_qm.f90
@@ -0,0 +1,63 @@
+subroutine save_qm(fname,revision,mycall,mygrid,dd,ntx30a,ntx30b,fcenter, &
+ nutc,ndop00,ndop58)
+
+ parameter(NMAX=60*96000)
+ character*120 fname
+ character*22 revision
+ character*12 mycall
+ character*6 mygrid
+ real*4 dd(2,NMAX)
+ real*8 fcenter
+ integer nxtra(15) !For possible future additions
+ integer*1,allocatable :: id1(:,:)
+
+ ia=1
+ ib=NMAX
+ if(ntx30a.gt.5) ia=NMAX/2+1
+ if(ntx30b.gt.5) ib=NMAX/2
+
+ sq=0.
+ do i=ia,ib
+ x=dd(1,i)
+ y=dd(2,i)
+ sq=sq + x*x + y*y
+ enddo
+ nsum=2*(ib-ia+1)
+ rms=sqrt(sq/nsum)
+
+ nbad=0
+ dmax=0.
+ fac0=10.0/rms
+ allocate(id1(1:2,1:NMAX))
+
+ do i=ia,ib
+ x=fac0*dd(1,i)
+ y=fac0*dd(2,i)
+ ax=abs(x)
+ ay=abs(y)
+ dmax=max(dmax,ax,ay)
+ if(ax.gt.127.0) then
+ x=0.
+ nbad=nbad+1
+ endif
+ if(ay.gt.127.0) then
+ y=0.
+ nbad=nbad+1
+ endif
+ id1(1,i)=nint(x)
+ id1(2,i)=nint(y)
+ enddo
+ if(ia.gt.30*96000) id1(1:2,1:ia-1)=0
+ if(ib.eq.30*96000) id1(1:2,ib+1:60*96000)=0
+
+ open(29,file=trim(fname),status='unknown',access='stream')
+ nxtra=0
+ write(29) revision//' ',mycall,mygrid,fcenter,nutc,ntx30a,ntx30b, &
+ ndop00,ndop58,ia,ib,fac0,nxtra !Write header to disk
+ write(29) id1(1:2,ia:ib) !Write 8-bit data to disk
+ close(29)
+ deallocate(id1)
+
+ return
+end subroutine save_qm
+
diff --git a/qmap/libqmap/symspec.f90 b/qmap/libqmap/symspec.f90
index 9244d3b5..b07cfa5b 100755
--- a/qmap/libqmap/symspec.f90
+++ b/qmap/libqmap/symspec.f90
@@ -8,7 +8,7 @@ subroutine symspec(k,ndiskdat,nb,nbslider,nfsample, &
! pxdb power in x channel (0-60 dB)
! ssz5a polarized spectrum, for waterfall display
! nkhz integer kHz portion of center frequency, e.g., 125 for 144.125
-! ihsym index number of this half-symbol (1-322)
+! ihsym index number of this half-symbol (1-400)
! nzap number of samples zero'ed by noise blanker
include 'njunk.f90'
@@ -16,9 +16,9 @@ subroutine symspec(k,ndiskdat,nb,nbslider,nfsample, &
parameter (NFFT=32768) !Length of FFTs
real*8 ts,hsym
real*8 fcenter
- common/datcom/dd(2,5760000),ss(322,NFFT),savg(NFFT),fcenter,nutc, &
+ common/datcom/dd(2,5760000),ss(400,NFFT),savg(NFFT),fcenter,nutc, &
junk(NJUNK)
- real*4 ssz5a(NFFT),w(NFFT),w2a(NFFT),w2b(NFFT)
+ real*4 ssz5a(NFFT),w(NFFT)
complex cx(NFFT)
complex cx00(NFFT)
complex cx0(0:1023),cx1(0:1023)
@@ -26,31 +26,24 @@ subroutine symspec(k,ndiskdat,nb,nbslider,nfsample, &
data rms/999.0/,k0/99999999/,nadjx/0/,nadjy/0/
save
- nfast=1
+ hsym=0.15d0*96000.d0 !Samples per Q65-30x half-symbol
+ npts=2*hsym !Full Q65-30x symbol
if(k.gt.5751000) go to 999
- if(k.lt.NFFT) then
+ if(k.lt.npts) then
ihsym=0
go to 999 !Wait for enough samples to start
endif
if(k0.eq.99999999) then
- pi=4.0*atan(1.0)
- w2a=0.
- w2b=0.
- do i=1,NFFT
- w(i)=(sin(i*pi/NFFT))**2 !Window for nfast=1
- if(i.lt.17833) w2a(i)=(sin(i*pi/17832.925))**2 !Window a for nfast=2
- j=i-8916
- if(j.gt.0 .and. j.lt.17833) w2b(i)=(sin(j*pi/17832.925))**2 ! b
- enddo
- w2a=sqrt(2.0)*w2a
- w2b=sqrt(2.0)*w2b
+! pi=4.0*atan(1.0)
+! do i=1,NFFT
+! w(i)=(sin(i*pi/NFFT))**2 !Window
+! enddo
+ w=0.7 !Flat window
endif
- hsym=2048.d0*96000.d0/11025.d0 !Samples per JT65 half-symbol
- if(nfsample.eq.95238) hsym=2048.d0*95238.1d0/11025.d0
-
if(k.lt.k0) then
ts=1.d0 - hsym
+ ss=0.
savg=0.
ihsym=0
k1=0
@@ -85,12 +78,9 @@ subroutine symspec(k,ndiskdat,nb,nbslider,nfsample, &
k1=k1+kstep
enddo
- npts=NFFT !Samples used in each half-symbol FFT
-
ts=ts+hsym
ja=ts !Index of first sample
jb=ja+npts-1 !Last sample
-
i=0
fac=0.0002
do j=ja,jb !Copy data into cx
@@ -99,11 +89,12 @@ subroutine symspec(k,ndiskdat,nb,nbslider,nfsample, &
i=i+1
cx(i)=fac*cmplx(x1,x2)
enddo
+ cx(npts+1:)=0.
if(nzap/178.lt.50 .and. (ndiskdat.eq.0 .or. ihsym.lt.280)) then
nsum=nblks*kstep - nzap
if(nsum.le.0) nsum=1
- rmsx=sqrt(0.5*px/nsum)
+ rmsx=sqrt(px/nsum)
rms=rmsx
endif
pxdb=0.
@@ -112,31 +103,21 @@ subroutine symspec(k,ndiskdat,nb,nbslider,nfsample, &
cx00=cx
- do mm=1,nfast
- ihsym=ihsym+1
- if(nfast.eq.1) then
- cx=w*cx00 !Apply window for 2nd forward FFT
- else
- if(mm.eq.1) then
- cx=w2a*cx00
- else
- cx=w2b*cx00
- endif
- endif
-
- call four2a(cx,NFFT,1,1,1) !Second forward FFT (X)
-
- n=min(322,ihsym)
- do i=1,NFFT
- sx=real(cx(i))**2 + aimag(cx(i))**2
- ss(n,i)=sx ! Pol = 0
- savg(i)=savg(i) + sx
- ssz5a(i)=sx
- enddo
+ ihsym=ihsym+1
+ cx=w*cx00 !Apply window for 2nd forward FFT
+ call four2a(cx,NFFT,1,1,1) !Second forward FFT (X)
+ n=min(400,ihsym)
+ do i=1,NFFT
+ sx=real(cx(i))**2 + aimag(cx(i))**2
+ ss(n,i)=sx ! Pol = 0
+ savg(i)=savg(i) + sx
+ ssz5a(i)=sx
enddo
nkhz=nint(1000.d0*(fcenter-int(fcenter)))
if(fcenter.eq.0.d0) nkhz=125
+! write(*,3001) hsym,ts,ja,jb,ihsym
+!3001 format(2f12.3,3i10)
999 return
end subroutine symspec
diff --git a/qmap/libqmap/zaptx.f90 b/qmap/libqmap/zaptx.f90
new file mode 100755
index 00000000..6ddbd364
--- /dev/null
+++ b/qmap/libqmap/zaptx.f90
@@ -0,0 +1,9 @@
+subroutine zaptx(dd,k0,k)
+
+ parameter(NMAX=60*96000)
+ real dd(2,NMAX)
+
+ dd(1:2,k0+1:k)=0.
+
+ return
+end subroutine zaptx