2012-10-29 13:58:33 -04:00
|
|
|
subroutine sync9(ss,tstep,df3,ntol,nfqso,ccfred,ia,ib,ipkbest)
|
2012-10-01 16:37:05 -04:00
|
|
|
|
|
|
|
parameter (NSMAX=22000) !Max length of saved spectra
|
|
|
|
real ss(184,NSMAX)
|
2012-10-10 16:40:46 -04:00
|
|
|
real ccfred(NSMAX)
|
2012-10-22 15:18:24 -04:00
|
|
|
include 'jt9sync.f90'
|
2012-10-01 16:37:05 -04:00
|
|
|
|
2012-10-16 15:44:41 -04:00
|
|
|
ipk=0
|
|
|
|
ipkbest=0
|
2012-10-10 16:40:46 -04:00
|
|
|
ia=1
|
|
|
|
ib=min(1000,nint(1000.0/df3))
|
2012-10-01 16:37:05 -04:00
|
|
|
|
2012-10-10 16:40:46 -04:00
|
|
|
if(ntol.lt.1000) then
|
|
|
|
ia=nint((nfqso-1000-ntol)/df3)
|
|
|
|
ib=nint((nfqso-1000+ntol)/df3)
|
|
|
|
if(ia.lt.1) ia=1
|
|
|
|
if(ib.gt.NSMAX) ib=NSMAX
|
|
|
|
endif
|
|
|
|
|
|
|
|
sbest=0.
|
2012-10-02 11:56:18 -04:00
|
|
|
lagmax=2.5/tstep + 0.9999
|
2012-10-10 16:40:46 -04:00
|
|
|
ccfred=0.
|
|
|
|
|
|
|
|
do i=ia,ib
|
|
|
|
smax=0.
|
2012-10-01 16:37:05 -04:00
|
|
|
do lag=-lagmax,lagmax
|
|
|
|
sum=0.
|
2012-10-10 16:40:46 -04:00
|
|
|
do j=1,16
|
2012-10-22 15:18:24 -04:00
|
|
|
k=ii2(j) + lag
|
2012-10-29 13:58:33 -04:00
|
|
|
! if(k.ge.1) sum=sum + ss(k,i)
|
|
|
|
if(k.ge.1) sum=sum + ss(k,i) - 0.5*(ss(k+2,i)+ss(k+4,i))
|
2012-10-01 16:37:05 -04:00
|
|
|
enddo
|
|
|
|
if(sum.gt.smax) then
|
|
|
|
smax=sum
|
2012-10-10 16:40:46 -04:00
|
|
|
ipk=i
|
2012-10-02 11:56:18 -04:00
|
|
|
lagpk=lag
|
2012-10-01 16:37:05 -04:00
|
|
|
endif
|
|
|
|
enddo
|
2012-10-22 15:18:24 -04:00
|
|
|
ccfred(i)=smax !Best at this freq, over all lags
|
2012-10-10 16:40:46 -04:00
|
|
|
if(smax.gt.sbest) then
|
|
|
|
sbest=smax
|
|
|
|
ipkbest=ipk
|
2012-10-22 15:18:24 -04:00
|
|
|
lagpkbest=lagpk
|
2012-10-10 16:40:46 -04:00
|
|
|
endif
|
2012-10-01 16:37:05 -04:00
|
|
|
enddo
|
|
|
|
|
2012-10-30 11:02:27 -04:00
|
|
|
call pctile(ccfred(ia),ib-ia+1,50,xmed)
|
2012-10-31 15:21:46 -04:00
|
|
|
if(xmed.le.0.0) xmed=1.0
|
2012-10-30 11:02:27 -04:00
|
|
|
ccfred=ccfred/xmed
|
|
|
|
|
2012-10-01 16:37:05 -04:00
|
|
|
return
|
|
|
|
end subroutine sync9
|