Communication

Module for digital filters and Zadoff-Chu.

Filters

Digital Filters for CV-QKD.

qosst_core.comm.filters.raised_cosine_filter(length: int, roll_off: float, symbol_period: float, sampling_rate: float) Tuple[ndarray, ndarray]

This function computes a raised cosine filter given the relevant parameters and returns the times and time response.

Parameters:
  • length (int) – the length of the filter.

  • roll_off (float) – the roll-off factor. It must be between 0 and 1.

  • symbol_period (float) – the symbol period, in seconds.

  • sampling_rate (float) – the sampling rate in samples/second.

Raises:

ValueError – When the roll-off factor is not between 0 and 1.

Returns:

returns a tuple (times, h_rc) where times is the time array and h_rc the temporal response of the filter.

Return type:

Tuple[np.ndarray, np.ndarray]

qosst_core.comm.filters.root_raised_cosine_filter(length: int, roll_off: float, symbol_period: float, sampling_rate: float) Tuple[ndarray, ndarray]

This function computes a root raised cosine filter given the relevant parameters and returns the times and time response.

Parameters:
  • length (int) – the length of the filter.

  • roll_off (float) – the roll-off factor. It must be between 0 and 1.

  • symbol_period (float) – the symbol period, in seconds.

  • sampling_rate (float) – the sampling rate in samples/second.

Raises:

ValueError – When the roll-off factor is not between 0 and 1.

Returns:

returns a tuple (times, h_rc) where times is the time array and h_rc the temporal response of the filter.

Return type:

Tuple[np.ndarray, np.ndarray]

qosst_core.comm.filters.rect_filter(length: int, symbol_period: float, sampling_rate: float)

Generates a rectangular filter.

Parameters:
  • length (int) – length of filter.

  • symbol_period (float) – symbol period in seconds,

  • sampling_rate (float) – sampling rate in samples per second.

Returns:

returns a tuple (time, h) with time being the time array and h the coefficients of the filter.

Return type:

Tuple[np.ndarray, np.ndarray]

class qosst_core.comm.filters.Filter(*args, **kwargs)

Generic filter.

A filter has a times and filter attributes that are initialized by the __init__ and set_filter abstract methods.

There is a also a mehtod apply filter to directly apply the current filter.

Initialize the filter.

times: ndarray

time array.

filter: ndarray

temporal response of the filter.

abstract set_filter(*args, **kwargs) None

Generate the filter.

get_filter() ndarray

Returns the temporal response of the filter.

Returns:

the temporal response of the filter.

Return type:

np.ndarray

get_times() ndarray

Returns the time array.

Returns:

the time array.

Return type:

np.ndarray

apply_filter(data: ndarray) ndarray

Apply the filter to data and returns the filtered data.

This methods uses the fftconvolve from scipy to apply the filter.

Parameters:

data (np.ndarray) – data that needs to be filtered.

Raises:

ValueError – if the filter has not been set.

Returns:

the filtered data.

Return type:

np.ndarray

class qosst_core.comm.filters.RaisedCosineFilter(length: int, roll_off: float, symbol_period: float, sampling_rate: float, *args, **kwargs)

Filter class for a Raised cosine filter.

Parameters:
  • length (int) – length of the filter.

  • roll_off (float) – roll-off factor of the filter, between 0 and 1.

  • symbol_period (float) – symbol period, in seconds.

  • sampling_rate (float) – sampling rate, in samples/second.

Raises:

ValueError – if the roll-off factor is not between 0 and 1.

length: int

The length of the filter.

roll_off: float

The roll-off factor of the filter.

symbol_period: float

The symbol period of the filter, in seconds.

sampling_rate: float

The sampling rate, in samples/second.

bandwidth: float

The computed bandwidth of the filter.

set_filter(*args, **kwargs) None

Set the filter using the raised_cosine_filter() function.

class qosst_core.comm.filters.RootRaisedCosineFilter(length: int, roll_off: float, symbol_period: float, sampling_rate: float, *args, **kwargs)

Filter class with a Root Raised cosine filter.

Parameters:
  • length (int) – length of the filter.

  • roll_off (float) – roll-off factor of the filter, between 0 and 1.

  • symbol_period (float) – symbol period, in seconds.

  • sampling_rate (float) – sampling rate, in samples/second.

Raises:

ValueError – if the roll-off factor is not between 0 and 1.

length: int

The length of the filter.

roll_off: float

The roll-off factor of the filter.

symbol_period: float

The symbol period of the filter, in seconds.

sampling_rate: float

The sampling rate, in samples/second.

bandwidth: float

The computed bandwidth of the filter.

set_filter(*args, **kwargs) None

Set the filter using the root_raised_cosine_filter() function.

class qosst_core.comm.filters.RectFilter(length: int, symbol_period: float, sampling_rate: float, *args, **kwargs)

Filter class with a Rectangular filter.

Initialization function

length: int

The length of the filter.

symbol_period: float

The symbol period of the filter, in seconds.

sampling_rate: float

The sampling rate, in samples/second.

set_filter(*args, **kwargs) None

Set the filter using the rect_filter() function.

Zadoff-Chu

Zadoff-Chu sequence for synchronisation.

qosst_core.comm.zc.zcsequence(root: int, length: int, cyclic_shift: int = 0) ndarray

This function implements a Zadoff-Chu sequence.

It takes as input the parameters of the sequence and returns the sequence in a np array.

Parameters:
  • root (int) – the root of the Zadoff-Chu sequence. Often named u.

  • length (int) – the length of the Zadoff-Chu sequence. Often named Nzc.

  • cyclic_shift (int, optional) – the cyclic shift of the Zadoff-Chu sequence. Often named q. Defaults to 0.

Raises:
  • ValueError – when the root is not strictly between 0 and length.

  • ValueError – when the root and the length are not coprimes.

Returns:

the generated Zadoff-Chu sequence.

Return type:

np.ndarray