Filter#

class sionna.phy.signal.Filter(span_in_symbols: int, samples_per_symbol: int, window: sionna.phy.signal.window.Window | str | None = None, normalize: bool = True, precision: Literal['single', 'double'] | None = None, device: str | None = None, **kwargs)[source]#

Bases: sionna.phy.block.Block

Abstract class defining a filter of length K which can be applied to an input x of length N.

The filter length K is equal to the filter span in symbols (span_in_symbols) multiplied by the oversampling factor (samples_per_symbol). If this product is even, a value of one will be added.

The filter is applied through discrete convolution.

An optional windowing function window can be applied to the filter.

Three padding modes are available for applying the filter:

  • “full” (default): Returns the convolution at each point of overlap between x and the filter. The length of the output is N + K - 1. Zero-padding of the input x is performed to compute the convolution at the borders.

  • “same”: Returns an output of the same length as the input x. The convolution is computed such that the coefficients of the input x are centered on the coefficient of the filter with index (K-1)/2. Zero-padding of the input signal is performed to compute the convolution at the borders.

  • “valid”: Returns the convolution only at points where x and the filter completely overlap. The length of the output is N - K + 1.

Parameters:
  • span_in_symbols (int) – Filter span as measured by the number of symbols

  • samples_per_symbol (int) – Number of samples per symbol, i.e., the oversampling factor

  • window (sionna.phy.signal.window.Window | str | None) – Window that is applied to the filter coefficients. Can be None, a Window instance, or one of "hann", "hamming", "blackman".

  • normalize (bool) – If True, the filter is normalized to have unit power. Defaults to True.

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

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

Inputs:
  • x – […, N], torch.complex or torch.float. Input to which the filter is applied along the last dimension.

  • padding – “full” (default) | “valid” | “same”. Padding mode for convolving x and the filter.

  • conjugatebool, (default False). If True, the complex conjugate of the filter is applied.

Outputs:

y – […, M], torch.complex or torch.float. Filtered input. The length M depends on the padding.

Examples

import torch
from sionna.phy.signal import RootRaisedCosineFilter

rrc = RootRaisedCosineFilter(span_in_symbols=8, samples_per_symbol=4, beta=0.35)
x = torch.randn(32, 100)
y = rrc(x, padding="same")
print(y.shape)
# torch.Size([32, 100])

Attributes

property span_in_symbols: int#

Filter span in symbols

property samples_per_symbol: int#

Number of samples per symbol, i.e., the oversampling factor

property length: int#

Filter length in samples

property window: sionna.phy.signal.window.Window | None#

Get/set window function applied to filter coefficients

property normalize: bool#

If True the filter is normalized to have unit power

property coefficients: torch.Tensor#

Set/get raw filter coefficients

property sampling_times: numpy.ndarray#

Sampling times in multiples of the symbol duration

Methods

show(response: Literal['impulse', 'magnitude'] = 'impulse', scale: Literal['lin', 'db'] = 'lin') None[source]#

Plot the impulse or magnitude response.

Plots the impulse response (time domain) or magnitude response (frequency domain) of the filter.

For the computation of the magnitude response, a minimum DFT size of 1024 is assumed which is obtained through zero padding of the filter coefficients in the time domain.

Parameters:
  • response (Literal['impulse', 'magnitude']) – Desired response type. Must be "impulse" (default) or "magnitude".

  • scale (Literal['lin', 'db']) – y-scale of the magnitude response. Can be "lin" (i.e., linear) or "db" (i.e., Decibel).

property aclr: torch.Tensor#

torch.float – ACLR of the filter in linear scale.

This ACLR corresponds to what one would obtain from using this filter as pulse shaping filter on an i.i.d. sequence of symbols. The in-band is assumed to range from [-0.5, 0.5] in normalized frequency.