comnum.Css#

class comnum.Css(sf, *, oversampling=1, waveform='lora')#

Chirp spread spectrum, the frequency-shift chirp modulation of LoRa (Chiani and Elzanaty 2019; Afisiadis et al. 2020): M = 2^SF chirps of M chips, a noncoherent DFT receiver. LoRa is a trademark of Semtech; this models the published descriptions for research.

Parameters:
  • sf (int) – spreading factor.

  • oversampling (int) – samples per chip.

  • waveform (str) – "lora", or for comparison "vangelista" (the discrete chirp of Vangelista 2017) and "fsk" (one sample per chip).

Raises:

ValueError – for an invalid parameter (the message names it).

Examples

>>> import comnum
>>> css = comnum.Css(7)
>>> s = css.modulate([0, 5, 127])
>>> s.size, css.demodulate(s).tolist()
(384, [0, 5, 127])
demodulate(samples)#

The noncoherent decisions.

Parameters:

samples (array_like) – a multiple of J M samples.

Returns:

one symbol per J M samples.

Return type:

numpy.ndarray

Raises:

ValueError – for an invalid parameter or input (the message names it).

energies(samples)#

The energy of the M candidates of every received symbol (squared magnitudes of the DFT of the dechirped samples).

Parameters:

samples (array_like) – a multiple of J M samples.

Returns:

M energies per symbol.

Return type:

numpy.ndarray

Raises:

ValueError – for an invalid parameter or input (the message names it).

interferer(s1, s2, tau)#

One symbol of a same-SF interferer offset by tau chips: the end of its symbol s1, then its symbol s2 (Afisiadis et al. 2020, eq. (21)).

Parameters:
  • s1 (int) – the symbol that ends in the window.

  • s2 (int) – the symbol that starts tau chips in.

  • tau (float) – offset in chips, 0 ≤ tau < M.

Returns:

M samples.

Return type:

numpy.ndarray

Raises:

ValueError – for an invalid parameter (the message names it).

modulate(symbols)#

The samples of a sequence of symbols.

Parameters:

symbols (array_like) – integers in [0, M).

Returns:

J M samples per symbol.

Return type:

numpy.ndarray

Raises:

ValueError – for an invalid parameter or input (the message names it).

symbol(a)#

The samples of one symbol.

Parameters:

a (int) – the symbol, 0 ≤ a < M.

Returns:

J M unit-envelope samples.

Return type:

numpy.ndarray

Raises:

ValueError – for an invalid parameter (the message names it).

m#

The number of symbols and of chips per symbol, M = 2^SF.

Type:

int

sf#

The spreading factor.

Type:

int

symbol_len#

Samples per symbol, J M.

Type:

int