From dfceef366248de3585ba21a28a9c41ee0a83f1df Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Fri, 7 Dec 2018 11:10:25 -0600 Subject: [PATCH] Fix up ft8sim so that it prints a warning when SNR is set too high so that data will be clipped. --- lib/ft8/ft8sim.f90 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ft8/ft8sim.f90 b/lib/ft8/ft8sim.f90 index e43850daf..bbec600d4 100644 --- a/lib/ft8/ft8sim.f90 +++ b/lib/ft8/ft8sim.f90 @@ -108,7 +108,6 @@ program ft8sim ib=k wave=real(c) peak=maxval(abs(wave(ia:ib))) - rms=sqrt(dot_product(wave(ia:ib),wave(ia:ib))/NWAVE) nslots=1 if(width.gt.0.0) call filt8(f0,nslots,width,wave) @@ -119,10 +118,16 @@ program ft8sim enddo endif - fac=32767.0 - rms=100.0 - if(snrdb.ge.90.0) iwave(1:NMAX)=nint(fac*wave) - if(snrdb.lt.90.0) iwave(1:NMAX)=nint(rms*wave) + gain=100.0 + if(snrdb.lt.90.0) then + wave=gain*wave + else + datpk=maxval(abs(wave)) + fac=32766.9/datpk + wave=fac*wave + endif + if(any(abs(wave).gt.32767.0)) print*,"Warning - data will be clipped." + iwave=nint(wave) h=default_header(12000,NMAX) write(fname,1102) ifile