DC4_lab1_py
DC4_lab1_py
School of Engineering
import numpy as np
from PIL import Image
from matplotlib import pyplot as plt
import komm
tx_data = psk.modulate(tx_bin)
rx_data = awgn(tx_data)
rx_bin = psk.demodulate_hard(rx_data)
In Spyder, use the variable explorer and write down the value of Npixels, and the data type
and sizes of tx_bin, tx_data, rx_data and rx_bin. Check that the data types are correct,
and the comparison of the sizes of tx_data, rx_data to tx_bin, rx_bin corresponds to the
number of bits per symbol for the modulation scheme used.
psk = komm.PSKModulation(4,phase_offset=np.pi/4)
Check that psk.bits_per_symbol is commensurate with your data array sizes. Note also that
the komm implementation uses gray coding by default (so that symbol errors will give rise to
mostly single-bit errors), which you can verify by inspecting psk.labeling.
qam = komm.QAModulation(4,base_amplitudes=1./np.sqrt(2.))
print(qam.energy_per_symbol) # this should be unity
tx_data = qam.modulate(...)
Check that qam.bits_per_symbol is commensurate with your data array sizes. base_amplitudes
is unity by default and correspondingly the closest points to the origin of the I-Q constellation
are (±1, ±1). However, to draw appropriate comparisons with PSK we should be consis-
tent with the average power per symbol (unity by default with PSK). Therefore the value for
base_amplitudes needs to be renormalised, as shown above for 4-QAM. One method you can
use to do this is to inspect the value qam.energy_per_symbol and then set base_amplitudes
to a value such that qam.energy_per_symbol becomes unity.
Repeat the exercise for 16-QAM.
1.7 Higher order QAM - Mandatory for ENG5336/ Optional for ENG4052
Adapt your code to extend your study to 64-QAM (you may need to add dummy bits so that the
total bits is a multiple of 6) and 256-QAM, remembering to appropriately renormalise the value
for base_amplitudes in each case. You will need to use significantly higher signal-to-noise
ratios than previously. Identify the approximate increase in signal-to-noise ratio to achieve
equivalent 𝑏𝑒𝑟 compared to 4-QAM and 16-QAM. Examine the constellation plots and note any
significant pattern; what is your explanation for this pattern?
1.8 Documentation
Python 3 https://docs.python.org/3/
komm https://komm.readthedocs.io/en/latest/
matplotlib https://matplotlib.org/contents.html
pillow https://pillow.readthedocs.io
spyder https://docs.spyder-ide.org/