comnum.Dvbt#

class comnum.Dvbt(mode='8K', guard='1/4', constellation='QPSK', rate='1/2')#

A DVB-T transmitter and receiver (ETSI EN 300 744 V1.6.2) of one non-hierarchical configuration.

The transmitter takes a burst of whole MPEG-2 transport packets (see dvb_packets()): the energy dispersal, RS(204, 188) and the outer interleaver of DVB-S (flushed by 11 packets of zeros), the inner code (171, 133, octal) punctured by Table 2, the inner interleaver (six bit interleavers of 126 bits and the symbol interleaver of the mode), the constellation of Figure 9 normalised by Table 6, the OFDM frame with its scattered and continual pilots (boosted to 4/3) and its TPS (signalling the mode, the guard interval, the constellation and the rate, BCH-protected, differentially modulated), and the OFDM modulation with the guard interval, one sample per elementary period T (7/64 µs at 8 MHz). The burst starts with the first symbol of a super-frame. The receiver works on the cells of the symbols, given the noise variance of a carrier and, if any, the gain of every carrier (a static channel known to the receiver, as in Annex A).

The cells are arrays of shape (K, n_symbols), K = 1705 (2K) or 6817 (8K) carriers.

Parameters:
  • mode (str) – "2K" or "8K".

  • guard (str) – the guard interval, "1/4", "1/8", "1/16" or "1/32".

  • constellation (str) – "QPSK", "16-QAM" or "64-QAM".

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

Raises:

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

Examples

>>> import comnum, numpy as np
>>> link = comnum.Dvbt("2K", "1/4", "16-QAM", "2/3")
>>> link.packets_per_superframe          # Table 16
672
>>> round(link.useful_bit_rate(8e6) / 1e6, 2)   # Table 17
13.27
>>> packets = comnum.dvb_packets(30, comnum.Rng(1))
>>> cells = link.demodulate(link.modulate(packets))
>>> cells.shape == (1705, link.symbols_len(30))
True
>>> bool(np.array_equal(link.decode(cells, 30, 1e-3)[0], packets))
True
carrier_frequencies(bandwidth_hz=8000000.0)#

The baseband frequency of every carrier, k' / TU with k' = k - (K - 1)/2.

Parameters:

bandwidth_hz (float) – the channel bandwidth (Hz).

Returns:

K frequencies (Hz).

Return type:

numpy.ndarray

carrier_noise_var(cn_db)#

The noise variance of a carrier at a C/N calculated over the K carriers (Annex A): the mean power of the carriers, pilots boosted, over the C/N.

Parameters:

cn_db (float) – C/N (dB).

Returns:

the complex noise variance of a carrier.

Return type:

float

cells(data)#

The cells of the symbols of the bytes of a burst (see Dvbs.outer()).

Parameters:

data (array_like) – the bytes of the outer coding of a burst (uint8).

Returns:

the cells, shape (K, n_symbols) (complex128).

Return type:

numpy.ndarray

Raises:

ValueError – for a value outside 0 to 255.

decode(cells, n_packets, noise_var, channel=None)#

The packets of the cells of a burst.

Parameters:
  • cells (array_like) – the received cells, shape (K, n_symbols).

  • n_packets (int) – the packets of the burst.

  • noise_var (float) – complex noise variance of a carrier.

  • channel (array_like, optional) – the gain of every carrier (K values).

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 the cells are not those of a burst of n_packets packets.

decode_tps(cells, channel=None)#

The TPS of a received frame (its 68 symbols, the first one first).

Parameters:
  • cells (array_like) – the cells of the 68 symbols, shape (K, 68).

  • channel (array_like, optional) – the gain of every carrier (K values).

Returns:

frame, mode, guard, constellation, hierarchy (alpha, 0 for non-hierarchical), rate_hp, rate_lp (None when non-hierarchical) and cell_id (None if not transmitted).

Return type:

dict

Raises:
  • ValueError – for another number of symbols, a TPS that does not decode, or a

  • reserved value. –

demodulate(samples)#

The cells of the received samples of whole symbols (guard intervals removed).

Parameters:

samples (array_like) – the received samples.

Returns:

the cells, shape (K, n_symbols) (complex128).

Return type:

numpy.ndarray

Raises:

ValueError – unless the samples hold whole symbols.

inner_decode(cells, n_packets, noise_var, channel=None)#

The bytes decided by the soft Viterbi decoder from the cells of a burst.

Parameters:
  • cells (array_like) – the received cells, shape (K, n_symbols).

  • n_packets (int) – the packets of the burst.

  • noise_var (float) – complex noise variance of a carrier.

  • channel (array_like, optional) – the gain of every carrier (K values).

Returns:

the bytes (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – if the cells are not those of a burst of n_packets packets.

modulate(packets)#

The samples of a burst of whole transport packets (one sample per T, the guard intervals included).

Parameters:

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

Returns:

the samples (complex128).

Return type:

numpy.ndarray

Raises:

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

sample_noise_var(carrier_noise_var)#

The noise variance of a sample of modulate() that gives a noise variance on every carrier.

Parameters:

carrier_noise_var (float) – the noise variance of a carrier.

Returns:

the complex noise variance of a sample, carrier_noise_var N / K.

Return type:

float

symbols_len(n_packets)#

The OFDM 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(bandwidth_hz=8000000.0)#

The useful bit rate in a channel of a bandwidth (Table 17).

Parameters:

bandwidth_hz (float) – 8e6, 7e6, 6e6 or 5e6 (any value: T = 7 / (8 B)).

Returns:

the useful bit rate (bit/s).

Return type:

float

carriers#

The carriers of a symbol, K.

Type:

int

constellation#

The points of the data cells (label y0 y1 ... y(v-1), Figure 9).

Type:

Constellation

data_cells#

The data cells of a symbol (1512 in the 2K mode, 6048 in the 8K mode).

Type:

int

packets_per_superframe#

The RS packets of a super-frame of 4 frames of 68 symbols (Table 16).

Type:

int