diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-05-01 17:19:35 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-05-01 17:20:24 +0200 |
commit | d81d2a564752c8cf085d2cdff12c0d0fdbaba102 (patch) | |
tree | 4af9612af63eca1cb3cea9d6fe63a013e6e476b1 /autocorrelate_window.py | |
parent | 19c78a4284c80e6cdf9fc7176892ee47a092b24e (diff) | |
download | odr-dab-cir-d81d2a564752c8cf085d2cdff12c0d0fdbaba102.tar.gz odr-dab-cir-d81d2a564752c8cf085d2cdff12c0d0fdbaba102.tar.bz2 odr-dab-cir-d81d2a564752c8cf085d2cdff12c0d0fdbaba102.zip |
Add first code experiments
Diffstat (limited to 'autocorrelate_window.py')
-rwxr-xr-x | autocorrelate_window.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/autocorrelate_window.py b/autocorrelate_window.py new file mode 100755 index 0000000..c97f7fb --- /dev/null +++ b/autocorrelate_window.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# +# Do a set of autocorrelations over the test.16.14.25.iq file +# +# Licence: see LICENCE file + +import numpy as np +import matplotlib.pyplot as pp + +file_in = "test.16.14.25.iq" + +channel_out = np.fromfile(file_in, np.complex64) + +print("Autocorrelating") + +correlationlength = 50 + +def autocorrelate(x, length): + return np.array([1] + [np.abs(np.corrcoef(x[:-i], x[i:])[0,1]) for i in range(1, length)]) + + +reshape_width = correlationlength * 4 + +channel_out_truncated = channel_out[:-(channel_out.size % reshape_width)] + +channel_out_reshaped = channel_out_truncated.reshape(channel_out_truncated.size / reshape_width, reshape_width) + +channel_autocorr_image = np.zeros((channel_out_reshaped.shape[0], correlationlength)) +for i, window in enumerate(channel_out_reshaped): + if i % 100 == 0: + print("Window {}".format(i)) + channel_autocorr_image[i] = autocorrelate(window, correlationlength) + +rows, cols = channel_autocorr_image.shape + +aspect_ratio = 1.0 + +fig = pp.figure() +ax = fig.add_subplot(111) +hi = ax.imshow(channel_autocorr_image, cmap='hot', aspect=aspect_ratio*(cols/rows)) + +pp.show() + |