2016-02-23 14:37:38 -05:00
|
|
|
subroutine degrade_snr(d2,npts,db,bw)
|
2015-11-23 13:20:55 -05:00
|
|
|
|
2017-05-18 11:59:30 -04:00
|
|
|
! Degrade S/N by specified number of dB.
|
2015-11-23 13:20:55 -05:00
|
|
|
|
2017-05-18 11:59:30 -04:00
|
|
|
integer*2 d2(npts)
|
|
|
|
|
|
|
|
p0=0.
|
|
|
|
do i=1,npts
|
|
|
|
x=d2(i)
|
|
|
|
p0=p0 + x*x
|
|
|
|
enddo
|
|
|
|
p0=p0/npts
|
2016-02-23 14:37:38 -05:00
|
|
|
if(bw.gt.0.0) p0=p0*6000.0/bw
|
2015-11-23 13:20:55 -05:00
|
|
|
s=sqrt(p0*(10.0**(0.1*db) - 1.0))
|
2016-10-07 11:34:55 -04:00
|
|
|
fac=sqrt(p0/(p0+s*s))
|
2015-11-23 13:20:55 -05:00
|
|
|
do i=1,npts
|
2017-05-18 11:59:30 -04:00
|
|
|
d2(i)=nint(fac*(d2(i) + s*gran()))
|
2015-11-23 13:20:55 -05:00
|
|
|
enddo
|
|
|
|
|
|
|
|
return
|
|
|
|
end subroutine degrade_snr
|