2005-12-22 11:40:53 -05:00
|
|
|
subroutine flat2(ss,n,nsum)
|
|
|
|
|
2006-08-18 15:25:52 -04:00
|
|
|
real ss(2048)
|
|
|
|
real ref(2048)
|
|
|
|
real tmp(2048)
|
2005-12-22 11:40:53 -05:00
|
|
|
|
|
|
|
nsmo=20
|
|
|
|
base=50*(float(nsum)**1.5)
|
|
|
|
ia=nsmo+1
|
|
|
|
ib=n-nsmo-1
|
|
|
|
do i=ia,ib
|
|
|
|
call pctile(ss(i-nsmo),tmp,2*nsmo+1,50,ref(i))
|
|
|
|
enddo
|
2006-08-18 15:25:52 -04:00
|
|
|
call pctile(ref(ia),tmp,ib-ia+1,68,base2)
|
2005-12-22 11:40:53 -05:00
|
|
|
|
2006-08-18 15:25:52 -04:00
|
|
|
C Don't flatten if signal is extremely low (e.g., RX is off).
|
|
|
|
if(base2.gt.0.05*base) then
|
2005-12-22 11:40:53 -05:00
|
|
|
do i=ia,ib
|
|
|
|
ss(i)=base*ss(i)/ref(i)
|
|
|
|
enddo
|
2006-08-18 15:25:52 -04:00
|
|
|
else
|
|
|
|
do i=1,n
|
|
|
|
ss(i)=0.
|
|
|
|
enddo
|
2005-12-22 11:40:53 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
return
|
|
|
|
end
|