diff options
author | andreas128 <Andreas> | 2017-08-17 16:28:35 +0200 |
---|---|---|
committer | andreas128 <Andreas> | 2017-08-17 16:28:35 +0200 |
commit | a8b1aa0b60a1f5bf884069091d0f43b12c521bb8 (patch) | |
tree | c1a670f026215797f97c1acc7298c5ad7e05f85e /dpd/show_spectrum.py | |
parent | 4fe5b4cacad22c84110061cb1cce4c0cf29b79fa (diff) | |
parent | fe62dff97924c045affe10da2e896e29e10e6aed (diff) | |
download | dabmod-a8b1aa0b60a1f5bf884069091d0f43b12c521bb8.tar.gz dabmod-a8b1aa0b60a1f5bf884069091d0f43b12c521bb8.tar.bz2 dabmod-a8b1aa0b60a1f5bf884069091d0f43b12c521bb8.zip |
Merge branch 'next_memless' of github.com:Opendigitalradio/ODR-DabMod into next_memless
Diffstat (limited to 'dpd/show_spectrum.py')
-rwxr-xr-x | dpd/show_spectrum.py | 20 |
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) |