ResourceGrid#

class sionna.phy.ofdm.ResourceGrid(num_ofdm_symbols: int, fft_size: int, subcarrier_spacing: float, num_tx: int = 1, num_streams_per_tx: int = 1, cyclic_prefix_length: int = 0, num_guard_carriers: Tuple[int, int] = (0, 0), dc_null: bool = False, pilot_pattern: str | sionna.phy.ofdm.pilot_pattern.PilotPattern | None = None, pilot_ofdm_symbol_indices: List[int] | None = None, precision: Literal['single', 'double'] | None = None, device: str | None = None)[source]#

Bases: sionna.phy.object.Object

Defines a ResourceGrid spanning multiple OFDM symbols and subcarriers.

A resource grid defines how data and pilot symbols are mapped onto a sequence of OFDM symbols with a given FFT size. The resource grid can also define guard and DC carriers which are nulled. In 4G/5G parlance, a resource grid would correspond to a slot.

Once a ResourceGrid is defined, one can use the ResourceGridMapper to map a tensor of complex-valued data symbols onto the resource grid, prior to OFDM modulation using the OFDMModulator or further processing in the frequency domain.

Subcarriers are numbered from \(0\) to \(N-1\), where \(N\) is the FFT size. The index \(0\) corresponds to the lowest frequency, which is \(-\frac{N}{2}\Delta_f\) (for \(N\) even) or \(-\frac{N-1}{2}\Delta_f\) (for \(N\) odd), where \(\Delta_f\) is the subcarrier spacing. The index \(N-1\) corresponds to the highest frequency, which is \((\frac{N}{2}-1)\Delta_f\) (for \(N\) even) or \(\frac{N-1}{2}\Delta_f\) (for \(N\) odd).

Parameters:
  • num_ofdm_symbols (int) – Number of OFDM symbols

  • fft_size (int) – FFT size (i.e., the number of subcarriers)

  • subcarrier_spacing (float) – Subcarrier spacing [Hz]

  • num_tx (int) – Number of transmitters. Defaults to 1.

  • num_streams_per_tx (int) – Number of streams per transmitter. Defaults to 1.

  • cyclic_prefix_length (int) – Length of the cyclic prefix. Defaults to 0.

  • num_guard_carriers (Tuple[int, int]) – Tuple of two integers defining the number of guard carriers at the left and right side of the resource grid. Defaults to (0, 0).

  • dc_null (bool) – If True, the DC carrier is nulled. Defaults to False.

  • pilot_pattern (str | sionna.phy.ofdm.pilot_pattern.PilotPattern | None) – An instance of PilotPattern, a string shorthand for the KroneckerPilotPattern or EmptyPilotPattern, or None. None is equivalent to "empty". Defaults to None.

  • pilot_ofdm_symbol_indices (List[int] | None) – List of indices of OFDM symbols reserved for pilot transmissions. Only needed if pilot_pattern="kronecker". Defaults to None.

  • precision (Literal['single', 'double'] | None) – Precision used for internal calculations and outputs. If set to None, precision is used.

  • device (str | None) – Device for tensor operations. If None, device is used.

Examples

The following code snippet shows how to setup and visualize an instance of ResourceGrid:

from sionna.phy.ofdm import ResourceGrid

rg = ResourceGrid(num_ofdm_symbols=14,
                  fft_size=64,
                  subcarrier_spacing=30e3,
                  num_tx=1,
                  num_streams_per_tx=1,
                  num_guard_carriers=[5, 6],
                  dc_null=True,
                  pilot_pattern="kronecker",
                  pilot_ofdm_symbol_indices=[2, 11])
rg.show()

This code creates a resource grid consisting of 14 OFDM symbols with 64 subcarriers. The first five and last six subcarriers as well as the DC subcarriers are nulled. The second and eleventh OFDM symbol are reserved for pilot transmissions.

Attributes

property cyclic_prefix_length: int#

Length of the cyclic prefix

property num_tx: int#

Number of transmitters

property num_streams_per_tx: int#

Number of streams per transmitter

property num_ofdm_symbols: int#

Number of OFDM symbols of the resource grid

property num_resource_elements: int#

Number of resource elements

property num_effective_subcarriers: int#

Number of subcarriers used for data and pilot transmissions

property effective_subcarrier_ind: numpy.ndarray#

Indices of the effective subcarriers

property num_data_symbols: int#

Number of resource elements used for data transmissions

property num_pilot_symbols: int#

Number of resource elements used for pilot symbols

property num_zero_symbols: int#

Number of empty resource elements

property num_guard_carriers: numpy.ndarray#

Number of left and right guard carriers

property dc_ind: int#

Index of the DC subcarrier.

If fft_size is odd, the index is (fft_size-1)/2. If fft_size is even, the index is fft_size/2.

property fft_size: int#

FFT size

property subcarrier_spacing: float#

Subcarrier spacing [Hz]

property ofdm_symbol_duration: float#

Duration of an OFDM symbol with cyclic prefix [s]

property bandwidth: float#

Occupied bandwidth [Hz]: fft_size*subcarrier_spacing

property num_time_samples: int#

Number of time-domain samples occupied by the resource grid

property dc_null: bool#

Indicates if the DC carrier is nulled or not

property pilot_pattern: sionna.phy.ofdm.pilot_pattern.PilotPattern#

Get/set the used PilotPattern

Methods

build_type_grid() torch.Tensor[source]#

Returns a tensor indicating the type of each resource element.

Resource elements can be one of

  • 0 : Data symbol

  • 1 : Pilot symbol

  • 2 : Guard carrier symbol

  • 3 : DC carrier symbol

Outputs:

rg_type – [num_tx, num_streams_per_tx, num_ofdm_symbols, fft_size], torch.int32. Tensor indicating for each transmitter and stream the type of the resource elements of the corresponding resource grid. The type can be one of [0, 1, 2, 3] as explained above.

show(tx_ind: int = 0, tx_stream_ind: int = 0) matplotlib.figure.Figure[source]#

Visualizes the resource grid for a specific transmitter and stream.

Parameters:
  • tx_ind (int) – Transmitter index

  • tx_stream_ind (int) – Stream index