From cc005bf69bee96a3a239782b2478bcf7b910657c Mon Sep 17 00:00:00 2001 From: Joe Taylor <joe@princeton.edu> Date: Wed, 31 Jan 2024 12:58:27 -0500 Subject: [PATCH] Add gen_sfox.f90. We're now generating data as well as sync symbols. --- lib/superfox/gen_sfox.f90 | 71 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lib/superfox/gen_sfox.f90 diff --git a/lib/superfox/gen_sfox.f90 b/lib/superfox/gen_sfox.f90 new file mode 100644 index 000000000..13235c880 --- /dev/null +++ b/lib/superfox/gen_sfox.f90 @@ -0,0 +1,71 @@ +subroutine gen_sfox(idat,f0,fsample,syncwidth,cdat,clo) + + include "sfox_params.f90" + complex cdat(NMAX) !Generated complex waveform + complex clo(NMAX) !Complex Local Oscillator + complex w,wstep + integer*1 idat(ND) + + twopi=8.0*atan(1.0) + tsync=NS*NSPS/fsample + +! Generate complex LO for SuperFox sync + w=1.0 + a0=1500.0+ syncwidth/2.0 !Frequency at midpoint of LO waveform + a2=2.0*syncwidth/tsync !Frequency drift rate + x0=0.5*(nsync+1) + s=2.0/nsync + do i=1,nsync + if(i.eq.nsync/2+1) a2=-a2 !Reverse sign of drift at midpoint + x=s*(i-x0) + dphi=(a0 + x*a2)*(twopi/fsample) + wstep=cmplx(cos(dphi),sin(dphi)) + w=w*wstep + clo(i)=conjg(w) + enddo + +! Generate complex SuperFox waveform + + df=fsample/NSPS + j=0 + k=0 +! First group of data symbols: + do n=1,ND1 + k=k+1 + dphi=(f0 + (idat(k)-65)*df)*(twopi/fsample) + wstep=cmplx(cos(dphi),sin(dphi)) + do i=1,NSPS + j=j+1 + w=w*wstep + cdat(j)=w + enddo + enddo + +! Sync waveform + a1=f0 + syncwidth/2.0 !Frequency at midpoint of sync waveform + a2=2.0*syncwidth/tsync !Frequency drift rate + cdat=0. + do i=1,nsync + j=j+1 + if(i.eq.nsync/2+1) a2=-a2 !Reverse sign of drift at midpoint + x=s*(i-x0) + dphi=(a1 + x*a2) * (twopi/fsample) + wstep=cmplx(cos(dphi),sin(dphi)) + w=w*wstep + cdat(j)=w + enddo + +! Final group of data symbols: + do n=1,ND2 + k=k+1 + dphi=(f0 + (idat(k)-65)*df)*(twopi/fsample) + wstep=cmplx(cos(dphi),sin(dphi)) + do i=1,NSPS + j=j+1 + w=w*wstep + cdat(j)=w + enddo + enddo + + return +end subroutine gen_sfox