aboutsummaryrefslogtreecommitdiffstats
path: root/autocorrelate.py
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-05-01 17:19:35 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-05-01 17:20:24 +0200
commitd81d2a564752c8cf085d2cdff12c0d0fdbaba102 (patch)
tree4af9612af63eca1cb3cea9d6fe63a013e6e476b1 /autocorrelate.py
parent19c78a4284c80e6cdf9fc7176892ee47a092b24e (diff)
downloadodr-dab-cir-d81d2a564752c8cf085d2cdff12c0d0fdbaba102.tar.gz
odr-dab-cir-d81d2a564752c8cf085d2cdff12c0d0fdbaba102.tar.bz2
odr-dab-cir-d81d2a564752c8cf085d2cdff12c0d0fdbaba102.zip
Add first code experiments
Diffstat (limited to 'autocorrelate.py')
-rwxr-xr-xautocorrelate.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/autocorrelate.py b/autocorrelate.py
new file mode 100755
index 0000000..9a66917
--- /dev/null
+++ b/autocorrelate.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+#
+# Do a single autocorrelation over the whole 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)])
+
+autocorr = autocorrelate(channel_out, correlationlength)
+
+print("Done")
+
+numpeaks = 6
+print("The first {} highest peaks are at".format(numpeaks))
+print(" index: amplitude")
+for ind in autocorr.argsort()[-numpeaks:][::-1]:
+ print(" {:4}: {}".format(ind, autocorr[ind]))
+
+fig = pp.figure()
+ax = fig.add_subplot(111)
+hi = ax.semilogy(autocorr)
+
+
+pp.show()
+
+