aboutsummaryrefslogtreecommitdiffstats
path: root/align
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-02-04 22:00:10 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-02-04 22:00:10 +0100
commit8ecda350fbde0d544ba284f0441859e2a52b4ce3 (patch)
tree1321366d38d399d2842e853616b3179b7988b596 /align
parent5ecde2c1ae68431248eb1b49b3bffb74304efd19 (diff)
downloadodr-dpd-8ecda350fbde0d544ba284f0441859e2a52b4ce3.tar.gz
odr-dpd-8ecda350fbde0d544ba284f0441859e2a52b4ce3.tar.bz2
odr-dpd-8ecda350fbde0d544ba284f0441859e2a52b4ce3.zip
Add subsample delay compensation (untested)
Diffstat (limited to 'align')
-rwxr-xr-xalign/GenerateExampleTxRxIQ.py47
1 files changed, 25 insertions, 22 deletions
diff --git a/align/GenerateExampleTxRxIQ.py b/align/GenerateExampleTxRxIQ.py
index fc105fd..03c79b6 100755
--- a/align/GenerateExampleTxRxIQ.py
+++ b/align/GenerateExampleTxRxIQ.py
@@ -30,19 +30,6 @@ import scipy
import scipy.signal
import numpy as np
-## Configuration
-# whether to correct for delays larger than one sample
-# Not necessary unless you have delay larger than oversample/2
-do_integer_compensation = 0
-
-# by how much to oversample the signal before applying the delay
-oversample = 8
-
-# Add a delay of delay/oversample samples to the input signal
-#delay = 7
-
-do_plot = False
-
def gen_omega(length):
if not length % 2 == 0:
raise ValueError('Needs an even length array.')
@@ -53,8 +40,9 @@ def gen_omega(length):
omega[halflength+1:] = 2*np.pi*( np.arange(halflength+1, length)-length )
return omega / length
-def gen_signals(delay):
- ## Generate signal
+def gen_signals(oversample, delay):
+ """Generate a signal that is delayed and a bit noisy. Returns a tuple
+ (original signal, shifted signal)"""
iq_file = "/home/bram/dab/aux/odr-dab-cir/phasereference.2048000.fc64.iq"
@@ -137,13 +125,28 @@ def delay_signal(sig, delay):
return np.fft.ifft(sig_fft * rotate_vec)
-for d in [2, 5, 9, 15, 34, 120]:
- a, b = gen_signals(d)
- delay = arg_max_corr(a,b)
- print("{} {}".format(d / oversample, delay))
+def fftplot(sig):
+ plt.plot(np.abs(np.fft.fftshift(np.fft.fft(sig))))
+
+if __name__ == '__main__':
+ # Add a delay of d/oversample samples to the input signal
+
+ # by how much to oversample the signal before applying the delay
+ oversample = 8
+
+ do_plot = False
+
+ for d in [2, 7]:
+ a, b = gen_signals(d, oversample)
+ delay = arg_max_corr(a,b)
+ print("{} {}".format(d / oversample, delay))
- print("{} {}".format(d / oversample, arg_max_corr(a, delay_signal(b, delay))))
+ print("{} {}".format(d / oversample, arg_max_corr(a, delay_signal(b, delay))))
+ if do_plot:
+ plt.figure()
+ fftplot(a)
+ fftplot(a-b)
-if do_plot:
- plt.show()
+ if do_plot:
+ plt.show()