2013-05-23 09:33:29 -04:00
|
|
|
subroutine symspec(k,ntrperiod,nsps,ingain,pxdb,s,red,df3,ihsym,npts8)
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-10-01 15:05:22 -04:00
|
|
|
! Input:
|
|
|
|
! k pointer to the most recent new data
|
|
|
|
! ntrperiod T/R sequence length, minutes
|
2013-04-22 11:43:02 -04:00
|
|
|
! nsps samples per symbol, at 12000 Hz
|
2012-10-01 15:05:22 -04:00
|
|
|
! ndiskdat 0/1 to indicate if data from disk
|
|
|
|
! nb 0/1 status of noise blanker (off/on)
|
|
|
|
! nbslider NB setting, 0-100
|
|
|
|
|
|
|
|
! Output:
|
|
|
|
! pxdb power (0-60 dB)
|
2013-04-22 11:43:02 -04:00
|
|
|
! s() spectrum for waterfall display
|
|
|
|
! red() first cut at JT9 sync amplitude
|
|
|
|
! ihsym index number of this half-symbol (1-184)
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-05-20 10:09:02 -04:00
|
|
|
parameter (NTMAX=120)
|
|
|
|
parameter (NMAX=NTMAX*12000) !Total sample intervals per 30 minutes
|
|
|
|
parameter (NDMAX=NTMAX*1500) !Sample intervals at 1500 Hz rate
|
|
|
|
parameter (NSMAX=1365) !Max length of saved spectra
|
2012-10-01 15:05:22 -04:00
|
|
|
parameter (NFFT1=1024)
|
|
|
|
parameter (NFFT2=1024,NFFT2A=NFFT2/8)
|
|
|
|
parameter (MAXFFT3=32768)
|
2012-10-15 13:43:49 -04:00
|
|
|
real*4 s(NSMAX),w3(MAXFFT3)
|
2013-05-16 12:02:00 -04:00
|
|
|
real*4 x1(NFFT1)
|
2012-10-04 15:03:39 -04:00
|
|
|
real*4 x2(NFFT1+105)
|
2012-10-11 14:33:50 -04:00
|
|
|
real*4 ssum(NSMAX)
|
2012-10-15 13:43:49 -04:00
|
|
|
real*4 red(NSMAX)
|
2012-10-04 15:03:39 -04:00
|
|
|
complex cx(0:MAXFFT3-1)
|
2012-10-01 15:05:22 -04:00
|
|
|
integer*2 id2
|
2012-11-21 12:42:53 -05:00
|
|
|
complex c0
|
|
|
|
common/jt9com/ss(184,NSMAX),savg(NSMAX),c0(NDMAX),id2(NMAX),nutc,ndiskdat, &
|
2012-11-19 13:23:39 -05:00
|
|
|
ntr,mousefqso,newdat,nfa,nfb,ntol,kin,nzhsym,nsynced,ndecoded
|
2012-10-01 15:05:22 -04:00
|
|
|
data rms/999.0/,k0/99999999/,ntrperiod0/0/,nfft3z/0/
|
2012-05-22 13:09:48 -04:00
|
|
|
save
|
|
|
|
|
2012-10-19 15:26:07 -04:00
|
|
|
if(ntrperiod.eq.1) nfft3=2048
|
2012-10-01 15:05:22 -04:00
|
|
|
if(ntrperiod.eq.2) nfft3=2048
|
|
|
|
if(ntrperiod.eq.5) nfft3=6144
|
|
|
|
if(ntrperiod.eq.10) nfft3=12288
|
|
|
|
if(ntrperiod.eq.30) nfft3=32768
|
|
|
|
|
2013-04-22 11:43:02 -04:00
|
|
|
jstep=nsps/16 !Step size = half-symbol in c0()
|
2012-09-30 20:02:36 -04:00
|
|
|
if(k.gt.NMAX) go to 999
|
|
|
|
if(k.lt.nfft3) then
|
2012-05-22 13:09:48 -04:00
|
|
|
ihsym=0
|
2012-10-01 15:05:22 -04:00
|
|
|
go to 999 !Wait for enough samples to start
|
2012-05-22 13:09:48 -04:00
|
|
|
endif
|
2013-04-22 11:43:02 -04:00
|
|
|
if(nfft3.ne.nfft3z) then !New nfft3, compute window
|
2012-05-22 13:09:48 -04:00
|
|
|
pi=4.0*atan(1.0)
|
2013-05-08 14:38:31 -04:00
|
|
|
if(ntrperiod.eq.1) then !Compute window for nfft3 spectrun
|
|
|
|
do i=1,nfft3
|
|
|
|
xx=float(i-1)/(nfft3-1)
|
|
|
|
w3(i)=0.40897 -0.5*cos(2.0*pi*xx) + 0.09103*cos(4.0*pi*xx)
|
2013-05-08 15:08:05 -04:00
|
|
|
! w3(i)=0.355768 - 0.487306*cos(2.0*pi*xx) + 0.144232*cos(4.0*pi*xx) &
|
|
|
|
! - 0.012604*cos(6.0*pi*xx)
|
2013-05-08 14:38:31 -04:00
|
|
|
enddo
|
|
|
|
else
|
|
|
|
do i=1,nfft3
|
|
|
|
w3(i)=2.0*(sin(i*pi/nfft3))**2 !Window for nfft3 spectrum
|
|
|
|
enddo
|
|
|
|
endif
|
2012-10-01 15:05:22 -04:00
|
|
|
nfft3z=nfft3
|
2012-05-22 13:09:48 -04:00
|
|
|
endif
|
2012-09-30 20:02:36 -04:00
|
|
|
|
2013-04-22 11:43:02 -04:00
|
|
|
if(k.lt.k0) then !Start a new data block
|
2012-11-12 16:06:31 -05:00
|
|
|
ja=0
|
2012-10-11 14:33:50 -04:00
|
|
|
ssum=0.
|
2012-06-04 13:02:50 -04:00
|
|
|
ihsym=0
|
|
|
|
k1=0
|
2012-10-01 15:05:22 -04:00
|
|
|
k8=0
|
2012-10-04 15:03:39 -04:00
|
|
|
x2=0.
|
2012-10-30 11:02:27 -04:00
|
|
|
if(ndiskdat.eq.0) then
|
|
|
|
id2(k+1:)=0
|
|
|
|
c0=0. !This is necessary to prevent "ghosts". Not sure why.
|
|
|
|
endif
|
2012-06-04 13:02:50 -04:00
|
|
|
endif
|
|
|
|
k0=k
|
2012-10-01 15:05:22 -04:00
|
|
|
kstep1=NFFT1
|
2012-10-04 15:03:39 -04:00
|
|
|
fac=2.0/NFFT1
|
2012-10-01 15:05:22 -04:00
|
|
|
nblks=(k-k1)/kstep1
|
2012-11-01 15:54:40 -04:00
|
|
|
gain=10.0**(0.05*ingain)
|
2013-05-16 19:52:04 -04:00
|
|
|
sq=0.
|
2012-05-22 13:09:48 -04:00
|
|
|
do nblk=1,nblks
|
2012-10-01 15:05:22 -04:00
|
|
|
do i=1,NFFT1
|
2013-05-16 12:02:00 -04:00
|
|
|
x1(i)=gain*id2(k1+i)
|
2012-05-22 13:09:48 -04:00
|
|
|
enddo
|
2013-05-16 19:52:04 -04:00
|
|
|
sq=sq + dot_product(x1,x1)
|
2012-10-04 15:03:39 -04:00
|
|
|
! Mix at 1500 Hz, lowpass at +/-750 Hz, and downsample to 1500 Hz complex.
|
2013-05-15 15:45:55 -04:00
|
|
|
x2(106:105+kstep1)=x1(1:kstep1)
|
2012-10-04 15:03:39 -04:00
|
|
|
call fil3(x2,kstep1+105,c0(k8+1),n2)
|
|
|
|
x2(1:105)=x1(kstep1-104:kstep1) !Save 105 trailing samples
|
2012-10-01 15:05:22 -04:00
|
|
|
k1=k1+kstep1
|
|
|
|
k8=k8+kstep1/8
|
|
|
|
enddo
|
|
|
|
|
2012-10-04 15:03:39 -04:00
|
|
|
npts8=k8
|
2012-10-01 15:05:22 -04:00
|
|
|
ja=ja+jstep !Index of first sample
|
2013-05-16 19:52:04 -04:00
|
|
|
rms=sqrt(sq/(nblks*NFFT1))
|
2012-05-22 13:09:48 -04:00
|
|
|
pxdb=0.
|
2012-10-04 15:03:39 -04:00
|
|
|
if(rms.gt.0.0) pxdb=20.0*log10(rms)
|
2012-05-22 13:09:48 -04:00
|
|
|
if(pxdb.gt.60.0) pxdb=60.0
|
2012-10-03 22:05:14 -04:00
|
|
|
|
2012-11-12 16:09:32 -05:00
|
|
|
do i=0,nfft3-1 !Copy data into cx
|
|
|
|
j=ja+i-(nfft3-1)
|
2012-11-13 10:55:03 -05:00
|
|
|
cx(i)=0.
|
|
|
|
if(j.ge.1 .and. j.le.NDMAX) cx(i)=c0(j)
|
2012-11-12 16:09:32 -05:00
|
|
|
enddo
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-11-12 16:09:32 -05:00
|
|
|
if(ihsym.lt.184) ihsym=ihsym+1
|
|
|
|
cx(0:nfft3-1)=w3(1:nfft3)*cx(0:nfft3-1) !Apply window w3
|
2013-04-22 11:43:02 -04:00
|
|
|
call four2a(cx,nfft3,1,1,1) !Third FFT (forward)
|
2012-11-12 16:09:32 -05:00
|
|
|
|
|
|
|
n=min(184,ihsym)
|
2013-04-22 11:43:02 -04:00
|
|
|
df3=1500.0/nfft3 !JT9-a: 0.732 Hz = 0.42 * tone spacing
|
2012-11-12 16:09:32 -05:00
|
|
|
i0=nint(-500.0/df3)
|
|
|
|
iz=min(NSMAX,nint(1000.0/df3))
|
|
|
|
fac=(1.0/nfft3)**2
|
|
|
|
do i=1,iz
|
|
|
|
j=i0+i-1
|
|
|
|
if(j.lt.0) j=j+nfft3
|
|
|
|
sx=fac*(real(cx(j))**2 + aimag(cx(j))**2)
|
|
|
|
ss(n,i)=sx
|
|
|
|
ssum(i)=ssum(i) + sx
|
|
|
|
s(i)=sx
|
|
|
|
enddo
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2012-10-04 15:03:39 -04:00
|
|
|
999 continue
|
2012-10-11 14:33:50 -04:00
|
|
|
|
2013-04-18 16:12:04 -04:00
|
|
|
fac00=0.35
|
|
|
|
npct=20
|
|
|
|
call pctile(s,iz,npct,xmed0)
|
|
|
|
fac0=fac00/max(xmed0,0.006)
|
2012-10-26 12:01:57 -04:00
|
|
|
s(1:iz)=fac0*s(1:iz)
|
2013-04-18 16:12:04 -04:00
|
|
|
call pctile(ssum,iz,npct,xmed1)
|
|
|
|
fac1=fac00/max(xmed1,0.006*ihsym)
|
2012-10-26 12:01:57 -04:00
|
|
|
savg(1:iz)=fac1*ssum(1:iz)
|
2013-05-20 10:09:02 -04:00
|
|
|
! savg(iz+1:iz+20)=savg(iz)
|
2012-10-15 13:43:49 -04:00
|
|
|
call redsync(ss,ntrperiod,ihsym,iz,red)
|
|
|
|
|
2012-10-04 15:03:39 -04:00
|
|
|
return
|
2012-10-03 11:22:49 -04:00
|
|
|
end subroutine symspec
|