diff options
Diffstat (limited to 'align')
-rwxr-xr-x | align/GenerateExampleTxRxIQ.py | 47 |
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() |