From 1e461c6b4fdb3545c22de592aafcc99709d37f43 Mon Sep 17 00:00:00 2001
From: Daniel van der Schuur <schuur@astron.nl>
Date: Fri, 13 Feb 2015 12:52:07 +0000
Subject: [PATCH] -Fiex phase shifting.

---
 .../python/gen_hex_files_composite_signals.py | 53 ++++++++++---------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/applications/apertif/apertif_unb1_correlator/src/python/gen_hex_files_composite_signals.py b/applications/apertif/apertif_unb1_correlator/src/python/gen_hex_files_composite_signals.py
index c6219c86f2..9bce1debf8 100644
--- a/applications/apertif/apertif_unb1_correlator/src/python/gen_hex_files_composite_signals.py
+++ b/applications/apertif/apertif_unb1_correlator/src/python/gen_hex_files_composite_signals.py
@@ -40,7 +40,7 @@ NOF_INPUT_SIGNALS = 24
 COMPLEX_WIDTH = 8
 NOF_WORDS_PER_BLOCK = 64
 
-PATH = "../hex"
+PATH = os.environ['RADIOHDL']+'/applications/apertif/apertif_unb1_correlator/src/hex'
 FILENAME = "composite_signals"
 
 ###############################################################################
@@ -57,54 +57,57 @@ x = np.linspace(0.0, N*T, N)
 # 8 bit signed -> WAAROM LIJKT AMPL_MAX DAN TOCH 63 te zijn IPV 127??
 # . Boven ~70 wordt de waarde aan de FFT output jusit lager...
 AMPL_MAX = 63 # 7 bits+sign #HUH?! 100->62; 63->118; 80->105; 70->123; 72->121; 75->110
-NOF_CHANNELS = 1 # Note: starting from 0 in -31..31.
+CHANNELS = [19]
+NOF_CHANNELS = len(CHANNELS)
 
 input_signals = []
 for input_signal_nr in range(NOF_INPUT_SIGNALS):
     phase_shift_deg = input_signal_nr
     channel_signals = []
-    for bin_nr in range(NOF_CHANNELS):
+    for bin_nr in CHANNELS:
         phase_shift_rad = math.radians(phase_shift_deg)
         ampl=AMPL_MAX/NOF_CHANNELS
-        signal = ampl * np.exp( (bin_nr+1) * 1.j * (2.0*np.pi*x+phase_shift_rad) )
+        signal = ampl * np.exp( (bin_nr) * 1.j * (2.0*np.pi*x+(phase_shift_rad/bin_nr)) )
+
         channel_signals.append( signal )
     composite_signal=numpy.sum(channel_signals, axis=0)
     input_signals.append(composite_signal)
 
-s=input_signals[23]
+s=input_signals[1]
+
 ###############################################################################
 # Convert the float values to n-bits
 ###############################################################################
-#s_bits = []
-#for fword in s:
-#    re_signed = to_signed(fword.real, COMPLEX_WIDTH)
-#    im_signed = to_signed(fword.imag, COMPLEX_WIDTH)
-#
-#    s_bits.append( complex(re_signed, im_signed) )
-#
-#s = numpy.array(s_bits)
-#print s
+s_bits = []
+for fword in s:
+    re_signed = to_signed(fword.real, COMPLEX_WIDTH)
+    im_signed = to_signed(fword.imag, COMPLEX_WIDTH)
+
+    s_bits.append( complex(re_signed, im_signed) )
+
+s = numpy.array(s_bits)
+print s
 
 ###############################################################################
 # Plot the signal
 ###############################################################################
-#plt.plot(t, s.real, 'b-', t, s.imag, 'r--')
-#plt.legend(('real', 'imaginary'))
-#plt.show()
+plt.plot(t, s.real, 'b-', t, s.imag, 'r--')
+plt.legend(('real', 'imaginary'))
+plt.show()
 
 
 
 ###############################################################################
 # Plot FFT
 ###############################################################################
-#yf = fft(s)
-#
-#xf = fftfreq(N, T)
-#xf = fftshift(xf)
-#yplot = fftshift(yf)
-#plt.bar(xf, 1.0/N * np.abs(yplot))
-#plt.grid()
-#plt.show()
+yf = fft(s)
+
+xf = fftfreq(N, T)
+xf = fftshift(xf)
+yplot = fftshift(yf)
+plt.bar(xf, 1.0/N * np.abs(yplot))
+plt.grid()
+plt.show()
 
 ###############################################################################
 # Convert complex floats to concatenated integers
-- 
GitLab