summaryrefslogtreecommitdiffstats
path: root/dpd
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-12 14:37:45 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-16 19:48:34 +0200
commit15651ab0020ba594bff02491b3d2b6472f5e4fda (patch)
tree025cef12694ea5fdfa399d7676bd1a990367f5e3 /dpd
parent2d70a92c178b4cf7460d09efd93a0e7918781a64 (diff)
downloaddabmod-15651ab0020ba594bff02491b3d2b6472f5e4fda.tar.gz
dabmod-15651ab0020ba594bff02491b3d2b6472f5e4fda.tar.bz2
dabmod-15651ab0020ba594bff02491b3d2b6472f5e4fda.zip
show_spectrum: dump image and try to get upsampled constellation to work
Diffstat (limited to 'dpd')
-rwxr-xr-xdpd/show_spectrum.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/dpd/show_spectrum.py b/dpd/show_spectrum.py
index 95dbef9..f23dba2 100755
--- a/dpd/show_spectrum.py
+++ b/dpd/show_spectrum.py
@@ -169,14 +169,26 @@ def plot_constellation_once(options):
num_syms = int(len(frame) / n)
print("frame {} has {} symbols".format(len(frame), num_syms))
spectrums = np.array([np.fft.fftshift(np.fft.fft(frame[n*i:n*(i+1)], n)) for i in range(num_syms)])
- #imsave("spectrums.png", np.abs(spectrums))
+
+ def normalise(x):
+ """Normalise a real-valued array x to the range [0,1]"""
+ y = x + np.min(x)
+ return x / np.max(x)
+
+ imsave("spectrums.png", np.concatenate([
+ normalise(np.abs(spectrums)),
+ normalise(np.angle(spectrums))]))
# Only take bins that are supposed to contain energy
- #TODO this is only valid for 2048000 sample rate!
- spectrums = np.concatenate([spectrums[...,256:1024], spectrums[...,1025:1793]], axis=1)
+ # i.e. the middle 1536 bins, excluding the bin at n/2
+ assert(n % 2 == 0)
+ n_half = int(n/2)
+ spectrums = np.concatenate(
+ [spectrums[...,n_half-768:n_half],
+ spectrums[...,n_half + 1:n_half + 769]], axis=1)
sym_indices = (np.tile(np.arange(num_syms-1).reshape(num_syms-1,1), (1,NbCarriers)) +
- np.tile(np.linspace(-0.25, 0.25, NbCarriers), (num_syms-1, 1) ) )
+ np.tile(np.linspace(-0.4, 0.4, NbCarriers), (num_syms-1, 1) ) )
sym_indices = sym_indices.reshape(-1)
diff_angles = np.mod(np.diff(np.angle(spectrums, deg=1), axis=0), 360)
#sym_points = spectrums[:-1].reshape(-1)