comnum.ResourceGrid#

class comnum.ResourceGrid(n_subcarriers, n_symbols, *, pattern='lattice', period=4, spacing=4, freq=3, time=4, seed=0)#

An OFDM resource grid of n_subcarriers × n_symbols with pilots (Coleri et al. 2002). A grid is a (n_subcarriers, n_symbols) array, a column per OFDM symbol, so that Ofdm.modulate(grid.map(data)) sends it; the methods that read a grid also take the symbols of Ofdm.demodulate (1-D, symbol after symbol).

Parameters:
  • n_subcarriers (int) – subcarriers of the grid.

  • n_symbols (int) – OFDM symbols of the grid.

  • pattern (str) – "block" (every subcarrier of one symbol in period), "comb" (one subcarrier in spacing, every symbol) or "lattice" (one subcarrier in freq of one symbol in time).

  • period (int) – symbol period of the block pattern.

  • spacing (int) – subcarrier spacing of the comb pattern.

  • freq (int) – subcarrier spacing of the lattice pattern.

  • time (int) – symbol spacing of the lattice pattern.

  • seed (int) – seed of the pilot symbols.

Raises:

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

Examples

>>> import comnum
>>> grid = comnum.ResourceGrid(12, 4, pattern="comb", spacing=4)
>>> grid.n_data, grid.pilot_positions().shape
(36, (12, 2))
extract(grid)#

The data resource elements of a grid.

Parameters:

grid (array_like) – a whole grid (n_subcarriers, n_symbols), or its symbols as Ofdm.demodulate gives them (symbol after symbol).

Returns:

the n_data data symbols (complex128).

Return type:

numpy.ndarray

Raises:

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

is_pilot(k, l)#

Whether a resource element carries a pilot.

Parameters:
  • k (int) – the subcarrier.

  • l (int) – the OFDM symbol.

Returns:

whether (k, l) is a pilot.

Return type:

bool

map(data)#

The grid with data and the pilots.

Parameters:

data (array_like) – n_data data symbols.

Returns:

the grid (n_subcarriers, n_symbols) (complex128).

Return type:

numpy.ndarray

Raises:

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

pilot_positions()#

The pilot resource elements.

Returns:

(n_pilots, 2) (int64), the subcarrier k and the symbol l of every pilot.

Return type:

numpy.ndarray

Raises:

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

n_data#

Data REs per grid.

Type:

int

n_subcarriers#

Subcarriers of the grid.

Type:

int

n_symbols#

OFDM symbols of the grid.

Type:

int