2013-05-14 13:42:25 -04:00
|
|
|
subroutine sync9(ss,nzhsym,lag1,lag2,ia,ib,ccfred,ipkbest)
|
2012-10-01 16:37:05 -04:00
|
|
|
|
|
|
|
parameter (NSMAX=22000) !Max length of saved spectra
|
|
|
|
real ss(184,NSMAX)
|
2013-05-14 13:42:25 -04:00
|
|
|
real ss1(184)
|
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
|
|
|
sbest=0.
|
|
|
|
ccfred=0.
|
|
|
|
|
2013-04-22 11:43:02 -04:00
|
|
|
do i=ia,ib !Loop over freq range
|
2013-05-14 13:42:25 -04:00
|
|
|
ss1=ss(1:184,i)
|
2013-05-14 18:47:32 -04:00
|
|
|
call pctile(ss1,nzhsym,40,xmed)
|
2013-05-14 13:42:25 -04:00
|
|
|
ss1=ss1/xmed - 1.0
|
|
|
|
do j=1,nzhsym
|
2013-05-14 18:47:32 -04:00
|
|
|
if(ss1(j).gt.3.0) ss1(j)=3.0
|
2013-05-14 13:42:25 -04:00
|
|
|
enddo
|
|
|
|
|
2012-10-10 16:40:46 -04:00
|
|
|
smax=0.
|
2013-04-22 11:43:02 -04:00
|
|
|
do lag=lag1,lag2 !DT = 2.5 to 5.0 s
|
2012-10-01 16:37:05 -04:00
|
|
|
sum=0.
|
2013-04-22 11:43:02 -04:00
|
|
|
do j=1,16 !Sum over 16 sync symbols
|
2012-10-22 15:18:24 -04:00
|
|
|
k=ii2(j) + lag
|
2013-05-14 13:42:25 -04:00
|
|
|
if(k.ge.1 .and. k.le.nzhsym) sum=sum + ss1(k)
|
2012-10-01 16:37:05 -04:00
|
|
|
enddo
|
|
|
|
if(sum.gt.smax) then
|
|
|
|
smax=sum
|
2013-05-14 13:42:25 -04:00
|
|
|
ipk=i
|
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
|
|
|
|
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
|
2013-05-14 18:47:32 -04:00
|
|
|
ccfred=2.0*ccfred/xmed
|
2012-10-30 11:02:27 -04:00
|
|
|
|
2012-10-01 16:37:05 -04:00
|
|
|
return
|
|
|
|
end subroutine sync9
|