comnum.Dvbs#

class comnum.Dvbs(rate='1/2')#

A DVB-S transmitter and frame-aligned receiver (ETSI EN 300 421 V1.1.2) of one inner code rate.

The transmitter takes a burst of whole MPEG-2 transport packets (188 bytes, each starting with the sync byte 0x47; see dvb_packets()): the energy dispersal (the PRBS 1 + X^14 + X^15 reset every 8 packets, the first sync byte of a group inverted to 0xB8), the outer code RS(204, 188), the convolutional interleaver I = 12, M = 17 (flushed with 11 packets of zeros, so that the whole burst decodes), the inner code of constraint length 7 (X from 171, Y from 133, octal) punctured by Table 2 of the standard, and the Gray QPSK of its Figure 5 with unit energy, at one sample per symbol. The receiver computes the exact LLRs, decodes the inner code by soft Viterbi, deinterleaves, decodes RS(204, 188) and removes the energy dispersal; it assumes the burst found and the carrier recovered.

Parameters:

rate (str) – the inner code rate, "1/2", "2/3", "3/4", "5/6" or "7/8".

Raises:

ValueError – for another rate.

Examples

>>> import comnum, numpy as np
>>> link = comnum.Dvbs("3/4")
>>> packets = comnum.dvb_packets(8, comnum.Rng(1))
>>> x = link.modulate(packets)
>>> len(x) == link.symbols_len(8)
True
>>> bool(np.array_equal(link.decode(x, 0.01)[0], packets))
True
>>> round(link.useful_bit_rate(25.776e6) / 1e6, 2)   # Table D.1: 35.631 Mbit/s
35.63
decode(rx, noise_var)#

The packets of the received symbols of a burst.

Parameters:
  • rx (array_like) – the received symbols of a burst, aligned on its first symbol.

  • noise_var (float) – complex noise variance per symbol.

Returns:

the packets (uint8), the bytes corrected by RS(204, 188) and the packets it could not correct.

Return type:

tuple[numpy.ndarray, int, int]

Raises:

ValueError – if rx is not the length of a burst.

esn0_db(ebn0_db)#

The Es/N0 (dB) of an Eb/N0 per useful bit, the abscissa of Table 3.

Parameters:

ebn0_db (float) – Eb/N0 per useful bit (dB).

Returns:

Es/N0 (dB), ebn0_db + 10 log10(2 r 188/204).

Return type:

float

inner(data)#

The QPSK symbols of the bytes of outer() (punctured inner code, Figure 5).

Parameters:

data (array_like) – the bytes of outer() (uint8).

Returns:

the unit-energy symbols (complex128).

Return type:

numpy.ndarray

Raises:

ValueError – for a value outside 0 to 255.

inner_decode(rx, noise_var)#

The bytes decided by the soft Viterbi decoder, the estimate of outer().

Parameters:
  • rx (array_like) – the received symbols of a burst.

  • noise_var (float) – complex noise variance per symbol.

Returns:

the bytes (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – if rx is not the length of a burst.

modulate(packets)#

The symbols of a burst of whole transport packets (inner() of outer()).

Parameters:

packets (array_like) – whole transport packets (uint8, 188 bytes each).

Returns:

symbols_len(n) unit-energy symbols (complex128).

Return type:

numpy.ndarray

Raises:

ValueError – for a packet that does not start with 0x47 or a partial packet.

outer(packets)#

The bytes entering the inner code: energy dispersal, RS(204, 188), interleaver.

Parameters:

packets (array_like) – whole transport packets (uint8, 188 bytes each).

Returns:

the bytes (uint8), the flush of the interleaver included.

Return type:

numpy.ndarray

Raises:

ValueError – for a packet that does not start with 0x47 or a partial packet.

symbols_len(n_packets)#

The number of QPSK symbols of a burst of n_packets packets.

Parameters:

n_packets (int) – packets of the burst.

Returns:

the symbols of modulate().

Return type:

int

useful_bit_rate(symbol_rate)#

The useful bit rate at a symbol rate, 2 Rs r 188/204 (Annexes C and D).

Parameters:

symbol_rate (float) – the symbol rate (baud).

Returns:

the useful bit rate (bit/s).

Return type:

float

constellation#

The Gray QPSK of Figure 5 (label 2 b_I + b_Q, unit energy).

Type:

Constellation

rate#

The inner code rate.

Type:

str