CustomFilter#

class sionna.phy.signal.CustomFilter(samples_per_symbol: int, coefficients: torch.Tensor | numpy.ndarray, 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.signal.filter.Filter

Block for applying a custom filter of length K 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.

The dtype of the output is torch.float if both x and the filter coefficients have dtype torch.float. Otherwise, the dtype of the output is torch.complex.

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:
  • samples_per_symbol (int) – Number of samples per symbol, i.e., the oversampling factor

  • coefficients (torch.Tensor | numpy.ndarray) – [K], torch.float or torch.complex – Filter coefficients. The number of coefficients must be odd.

  • 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 CustomFilter

coefficients = torch.randn(33)
filt = CustomFilter(samples_per_symbol=4, coefficients=coefficients)
x = torch.randn(32, 100)
y = filt(x, padding="same")
print(y.shape)
# torch.Size([32, 100])