From d234986165f010ce6fa7c5d7422ec9df9cb303ae Mon Sep 17 00:00:00 2001
From: Joe Taylor <joe@princeton.edu>
Date: Mon, 19 Feb 2024 13:52:37 -0500
Subject: [PATCH] Add optional code to q65sim to confirm calkibration of
 SNR_2500.

---
 lib/qra/q65/q65sim.f90 | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/qra/q65/q65sim.f90 b/lib/qra/q65/q65sim.f90
index 51cf47954..cfe3a02d7 100644
--- a/lib/qra/q65/q65sim.f90
+++ b/lib/qra/q65/q65sim.f90
@@ -222,14 +222,20 @@ program q65sim
         fac=sqrt(1.0/avep)
         cspread=fac*cspread                   !Normalize to constant avg power
         cdat=cspread*cdat                     !Apply Rayleigh fading
-
-!        do i=0,nfft-1
-!           p=real(cspread(i))**2 + aimag(cspread(i))**2
-!           write(14,3010) i,p,cspread(i)
-!3010       format(i8,3f12.6)
-!        enddo
      endif
 
+!     psig=0.
+!     pnoise=0.
+!     do i=1,npts
+!        if(i.gt.12000 .and. i.lt.624000) then
+!           psig=psig + aimag(cdat(i))**2
+!           pnoise=pnoise + xnoise(i)*xnoise(i)
+!        endif
+!     enddo
+!     pnoise=pnoise*bandwidth_ratio
+!     snr_2500=db(psig/pnoise)                 !Calibration confirmation!
+!     print*,'SNR_2500:',snr_2500
+
      dat=aimag(cdat) + xnoise                 !Add generated AWGN noise
      fac=32767.0
      if(snrdb.ge.90.0) iwave(1:npts)=nint(fac*dat(1:npts))