summaryrefslogtreecommitdiff
path: root/lib/symspec.f90
diff options
context:
space:
mode:
authorhibby <d@vehibberd.com>2018-02-16 15:17:14 +0000
committerhibby <d@vehibberd.com>2018-02-16 15:17:14 +0000
commit37f727ac0746fd85504aa46c1f023c09b3eff33a (patch)
treec8a7ce04545040a8f161ba279528730bd9a3e6ab /lib/symspec.f90
parentd63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff)
New upstream version 1.8.0+repackupstream/1.8.0+repack
Diffstat (limited to 'lib/symspec.f90')
-rw-r--r--lib/symspec.f9062
1 files changed, 32 insertions, 30 deletions
diff --git a/lib/symspec.f90 b/lib/symspec.f90
index 8a9c1d7a..8135a812 100644
--- a/lib/symspec.f90
+++ b/lib/symspec.f90
@@ -1,4 +1,5 @@
-subroutine symspec(k,ntrperiod,nsps,ingain,nflatten,pxdb,s,df3,ihsym,npts8)
+subroutine symspec(shared_data,k,ntrperiod,nsps,ingain,nminw,pxdb,s, &
+ df3,ihsym,npts8,pxdbmax)
! Input:
! k pointer to the most recent new data
@@ -9,27 +10,29 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nflatten,pxdb,s,df3,ihsym,npts8)
! nbslider NB setting, 0-100
! Output:
-! pxdb power (0-60 dB)
+! pxdb raw power (0-90 dB)
! s() current spectrum for waterfall display
-! ihsym index number of this half-symbol (1-184)
+! ihsym index number of this half-symbol (1-184) for 60 s modes
! jt9com
! ss() JT9 symbol spectra at half-symbol steps
! savg() average spectra for waterfall display
- include 'constants.f90'
+ use, intrinsic :: iso_c_binding, only: c_int, c_short, c_float, c_char
+ include 'jt9com.f90'
+
+ type(dec_data) :: shared_data
real*4 w3(MAXFFT3)
real*4 s(NSMAX)
real*4 ssum(NSMAX)
real*4 xc(0:MAXFFT3-1)
real*4 tmp(NSMAX)
complex cx(0:MAXFFT3/2)
- integer*2 id2
- common/jt9com/ss(184,NSMAX),savg(NSMAX),id2(NMAX),nutc,ndiskdat, &
- ntr,mousefqso,newdat,npts8a,nfa,nfsplit,nfb,ntol,kin,nzhsym, &
- nsave,nagain,ndepth,ntxmode,nmode,junk(5)
- common/jt9w/syellow(NSMAX)
- data rms/999.0/,k0/99999999/,nfft3z/0/
+ integer nch(7)
+
+ common/spectra/syellow(NSMAX),ref(0:3456),filter(0:3456)
+ data k0/99999999/,nfft3z/0/
+ data nch/1,2,4,9,18,36,72/
equivalence (xc,cx)
save
@@ -57,19 +60,20 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nflatten,pxdb,s,df3,ihsym,npts8)
ja=0
ssum=0.
ihsym=0
- if(ndiskdat.eq.0) id2(k+1:)=0 !Needed to prevent "ghosts". Not sure why.
+ if(.not. shared_data%params%ndiskdat) shared_data%id2(k+1:)=0 !Needed to prevent "ghosts". Not sure why.
endif
gain=10.0**(0.1*ingain)
sq=0.
+ pxmax=0.;
do i=k0+1,k
- x1=id2(i)
+ x1=shared_data%id2(i)
+ if (abs(x1).gt.pxmax) pxmax = abs(x1);
sq=sq + x1*x1
enddo
- sq=sq * gain
- rms=sqrt(sq/(k-k0))
- pxdb=0.
- if(rms.gt.0.0) pxdb=20.0*log10(rms)
- if(pxdb.gt.60.0) pxdb=60.0
+ pxdb = 0.
+ if(sq.gt.0.0) pxdb=10*log10(sq/(k-k0))
+ pxdbmax=0.
+ if(pxmax.gt.0) pxdbmax = 20*log10(pxmax)
k0=k
ja=ja+jstep !Index of first sample
@@ -78,37 +82,35 @@ subroutine symspec(k,ntrperiod,nsps,ingain,nflatten,pxdb,s,df3,ihsym,npts8)
do i=0,nfft3-1 !Copy data into cx
j=ja+i-(nfft3-1)
xc(i)=0.
- if(j.ge.1) xc(i)=fac0*id2(j)
+ if(j.ge.1 .and.j.le.NMAX) xc(i)=fac0*shared_data%id2(j)
enddo
-
- if(ihsym.lt.184) ihsym=ihsym+1
+ ihsym=ihsym+1
xc(0:nfft3-1)=w3(1:nfft3)*xc(0:nfft3-1) !Apply window w3
call four2a(xc,nfft3,1,-1,0) !Real-to-complex FFT
- n=min(184,ihsym)
df3=12000.0/nfft3 !JT9-1: 0.732 Hz = 0.42 * tone spacing
-! i0=nint(1000.0/df3)
- i0=0
iz=min(NSMAX,nint(5000.0/df3))
fac=(1.0/nfft3)**2
do i=1,iz
- j=i0+i-1
+ j=i-1
if(j.lt.0) j=j+nfft3
sx=fac*(real(cx(j))**2 + aimag(cx(j))**2)
- ss(n,i)=sx
+ if(ihsym.le.184) shared_data%ss(ihsym,i)=sx
ssum(i)=ssum(i) + sx
s(i)=1000.0*gain*sx
enddo
- savg=ssum/ihsym
+ shared_data%savg=ssum/ihsym
- if(mod(n,10).eq.0) then
- mode4=36
+ if(mod(ihsym,10).eq.0) then
+ mode4=nch(nminw+1)
nsmo=min(10*mode4,150)
nsmo=4*nsmo
- call flat1(savg,iz,nsmo,syellow)
- if(mode4.ge.9) call smo(syellow,iz,tmp,mode4)
+ call flat1(shared_data%savg,iz,nsmo,syellow)
+ if(mode4.ge.2) call smo(syellow,iz,tmp,mode4)
+ if(mode4.ge.2) call smo(syellow,iz,tmp,mode4)
+ syellow(1:250)=0.
ia=500./df3
ib=2700.0/df3
smin=minval(syellow(ia:ib))