aboutsummaryrefslogtreecommitdiffstats
path: root/simulate_channel.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 /simulate_channel.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 'simulate_channel.py')
-rwxr-xr-xsimulate_channel.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/simulate_channel.py b/simulate_channel.py
new file mode 100755
index 0000000..893d74b
--- /dev/null
+++ b/simulate_channel.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# Adds additional components to the test.16.iq file, which is
+# an array of complex floats, and save it as
+# test.16.14.25.iq
+#
+# Licence: see LICENCE file
+
+import numpy as np
+import matplotlib.pyplot as pp
+
+file_in = "test.16.iq"
+
+
+# Simulate the channel with several components,
+# shifted by some number of samples and multiplied by
+# the amplitude
+#
+# The (0, 1.0) component is always present
+CIR = [(14, 0.4), (25, 0.3)]
+
+print("Simulate channel {}".format(CIR))
+
+maxdelay = max(delay for delay, ampl in CIR)
+
+
+original_iq = np.fromfile(file_in, np.complex64)
+
+original_iq_extended = np.append(original_iq, np.zeros(maxdelay, dtype=np.complex64))
+
+channel_out = original_iq_extended
+
+for delay, ampl in CIR:
+ print("Add component {}".format(delay))
+ channel_out += np.append(np.zeros(delay, dtype=np.complex64), ampl * original_iq_extended[:-delay])
+
+
+# The simulated channel output is in channel_out
+
+channel_out.tofile("test.16.14.25.iq")
+