summaryrefslogtreecommitdiff
path: root/lib/analytic.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/analytic.f90
parentd63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff)
New upstream version 1.8.0+repackupstream/1.8.0+repack
Diffstat (limited to 'lib/analytic.f90')
-rw-r--r--lib/analytic.f9072
1 files changed, 61 insertions, 11 deletions
diff --git a/lib/analytic.f90 b/lib/analytic.f90
index 33d5fc74..253692f5 100644
--- a/lib/analytic.f90
+++ b/lib/analytic.f90
@@ -1,25 +1,75 @@
-subroutine analytic(d,npts,nfft,s,c)
+subroutine analytic(d,npts,nfft,c,pc,beq)
! Convert real data to analytic signal
- parameter (NFFTMAX=128*1024)
- real d(npts)
- real s(npts)
- complex c(NFFTMAX)
+ parameter (NFFTMAX=1024*1024)
+ real d(npts) ! passband signal
+ real h(NFFTMAX/2) ! real BPF magnitude
+ real*8 pc(5),pclast(5) ! static phase coeffs
+ real*8 ac(5),aclast(5) ! amp coeffs
+ real*8 fp
+
+ complex corr(NFFTMAX/2) ! complex frequency-dependent correction
+ complex c(NFFTMAX) ! analytic signal
+
+ logical*1 beq ! boolean static equalizer flag
+
+ data nfft0/0/
+ data aclast/0.0,0.0,0.0,0.0,0.0/
+ data pclast/0.0,0.0,0.0,0.0,0.0/
+! data ac/1.0,0.05532,0.11438,0.12918,0.09274/ ! amp coeffs for TS2000
+ data ac/1.0,0.0,0.0,0.0,0.0/
+
+ save corr,nfft0,h,ac,aclast,pclast,pi,t,beta
+
+ df=12000.0/nfft
nh=nfft/2
+ if( nfft.ne.nfft0 ) then
+ pi=4.0*atan(1.0)
+ t=1.0/2000.0
+ beta=0.1
+ do i=1,nh+1
+ ff=(i-1)*df
+ f=ff-1500.0
+ h(i)=1.0
+ if(abs(f).gt.(1-beta)/(2*t) .and. abs(f).le.(1+beta)/(2*t)) then
+ h(i)=h(i)*0.5*(1+cos((pi*t/beta )*(abs(f)-(1-beta)/(2*t))))
+ elseif( abs(f) .gt. (1+beta)/(2*t) ) then
+ h(i)=0.0
+ endif
+ enddo
+ nfft0=nfft
+ endif
+
+ if( any(aclast .ne. ac) .or. any(pclast .ne. pc) ) then
+ aclast=ac
+ pclast=pc
+! write(*,3001) pc
+!3001 format('Phase coeffs:',5f12.6)
+ do i=1,nh+1
+ ff=(i-1)*df
+ f=ff-1500.0
+ fp=f/1000.0
+ corr(i)=ac(1)+fp*(ac(2)+fp*(ac(3)+fp*(ac(4)+fp*ac(5))))
+ pd=fp*fp*(pc(3)+fp*(pc(4)+fp*pc(5))) ! ignore 1st two terms
+ corr(i)=corr(i)*cmplx(cos(pd),sin(pd))
+ enddo
+ endif
+
fac=2.0/nfft
c(1:npts)=fac*d(1:npts)
c(npts+1:nfft)=0.
call four2a(c,nfft,1,-1,1) !Forward c2c FFT
- do i=1,nh
- s(i)=real(c(i))**2 + aimag(c(i))**2
- enddo
+ if( beq ) then
+ c(1:nh+1)=h(1:nh+1)*corr(1:nh+1)*c(1:nh+1)
+ else
+ c(1:nh+1)=h(1:nh+1)*c(1:nh+1)
+ endif
- c(1)=0.5*c(1)
- c(nh+2:nfft)=0.
+ c(1)=0.5*c(1) !Half of DC term
+ c(nh+2:nfft)=0. !Zero the negative frequencies
call four2a(c,nfft,1,1,1) !Inverse c2c FFT
-
return
end subroutine analytic