Modulation

This module contains the necessary codes to modulate and demodulate data for the different modulations used in CV-QKD.

Here are some examples of use

from qosst_core.modulation import GaussianModulation, PSKModulation, QAMModulation, PCSQAMModulation

# Create a Gaussian modulation with unit variance and 100 points
gm = GaussianModulation(variance=1)
points = gm.modulate(size=100)

# Create a 16-PSK and with variance 2 and 1000 points
pm = PSKModulation(variance=2, modulation_size=16)
points = pm.modulate(size=1000)

# Create a 256-QAM with variance 0.5 and 10000 points
qm = QAMModulation(variance=0.5, modulation_size=256)
points = qm.modulate(size=10000)

# Create a PCS-1024-QAM with variance 5 and 100000 points
pqm = PCSQAMModulation(variance=5, modulation_size=1024, nu=0.5)
points = PCSQAMModulation(size=100000)

Modulation

Generic modulation.

class qosst_core.modulation.modulation.Modulation(variance: float, **_kwargs)

Abstract class for the modulations.

Parameters:

variance (float) – variance of the modulation.

variance: float

variance of the modulation.

abstract modulate(size: int) ndarray

Modulate and return an array containing the symbols.

Parameters:

size (int) – number of points to modulate.

Returns:

the modulated points.

Return type:

np.ndarray

class qosst_core.modulation.modulation.DiscreteModulation(variance: float, constellation: ndarray, distribution: ndarray | None)

Abstract class representing a discrete modulation.

In particular it contains the constellation (i.e. an array of the possible symbols) and a distribution (i.e. the associated array of probability of those symbols).

Parameters:
  • variance (float) – variance of the modulation.

  • constellation (np.ndarray) – constellation (array of possible symbols).

  • distribution (np.ndarray) – distribution (array of probability of those symbols).

constellation: ndarray

Possible symbols of the modulation.

distribution: ndarray | None

Probabilities associated to those symbols. None should be considered the uniform distribution.

bits_to_symbols(input_bits: ndarray) ndarray

Modulate the bits according to the modulation.

Parameters:

input_bits (np.ndarray) – array of input bits.

Returns:

array of output symbols.

Return type:

np.ndarray

nearest_point(input_symbols: ndarray) ndarray

Find the nearest point in the constellation of any given point.

Parameters:

input_symbols (np.ndarray) – array of input imperfect symbols.

Returns:

array of perfect outputs symbols.

Return type:

np.ndarray

symbols_to_bits(input_symbols: ndarray) ndarray

Demodulate symbols according to the modulation.

Parameters:

input_symbols (np.ndarray) – array of input symbols.

Returns:

array of output bits.

Return type:

np.ndarray

modulate(size: int) ndarray

Generate an array of size size, containing symbols from the constellation and following the distribution of probability.

Parameters:

size (int) – number of symbols to generate.

Returns:

array of symbols, of size size.

Return type:

np.ndarray

Gaussian

Gaussian modulation.

class qosst_core.modulation.gaussian.GaussianModulation(variance: float, **_kwargs)

Gaussian modulation.

Parameters:

variance (float) – variance of the gaussian modulation.

modulate(size: int) ndarray

Modulate from the modulation.

Parameters:

size (int) – Number of symbols to output.

Returns:

size symbols from a Gaussian distribution on each quadrature.

Return type:

np.ndarray

PSK

PSK modulation.

class qosst_core.modulation.psk.PSKModulation(variance: float, modulation_size: int)

Phase Shift Keying modulation with modulation_size points.

modulation_size should be a power of 2.

Parameters:
  • variance (float) – variance of the modulation.

  • modulation_size (int) – size of the PSK.

Raises:

ValueError – if the modulation size is not a power of 2.

QAM

QAM modulation.

class qosst_core.modulation.qam.QAMModulation(variance: float, modulation_size: int)

Quadrature Amplitude Modulation with modulation_size points.

modulation_size should be a power of 2 and a square.

Parameters:
  • variance (float) – variance of the modulation.

  • modulation_size (int) – size of the QAM.

Raises:
  • ValueError – if the modulation size is not a power of 2.

  • ValueError – if the modulation size is not a perfect square.

PCS QAM

PCSQAM modulation.

class qosst_core.modulation.pcsqam.PCSQAMModulation(variance: float, modulation_size: int, nu: float)

Quadrature Amplitude Modulation with modulation_size points, using Probabilistic Constellation Shaping.

modulation_size should be a power of 2 and a square.

The distribution is choosen to be (before normalization)

p(x,y) = exp(-nu*(x**2+y**2))

Parameters:
  • variance (float) – variance of the modulation.

  • modulation_size (int) – size of the QAM.

  • nu (float) – parameter for the distribution of probability.

Raises:
  • ValueError – if the modulation size is not a power of 2.

  • ValueError – if the modulation size is not a perfect square.

nu: float

Parameter for the distribution of probbaility.

Binomial QAM

PCSQAM modulation.

class qosst_core.modulation.binomialqam.BinomialQAMModulation(variance: float, modulation_size: int)

Quadrature Amplitude Modulation with modulation_size points, using Binomial Probabilistic Constellation Shaping.

modulation_size should be a power of 2 and a square.

Parameters:
  • variance (float) – variance of the modulation.

  • modulation_size (int) – size of the QAM.

Raises:
  • ValueError – if the modulation size is not a power of 2.

  • ValueError – if the modulation size is not a perfect square.

Singlepoint

PSK modulation.

class qosst_core.modulation.singlepoint.SinglePointModulation(**kwargs)

Single point modulation.

Variance and modulation_size can be set for convenience.

Parameters:
  • real (float, optional) – value of the real part of the point. Defaults to 1.

  • imag (float, optional) – value of the imaginary part of the point. Defaults to 1.

real: float

Real value of the point.

imag: float

Imaginary value of the point.