PlotBER#
- class sionna.phy.utils.PlotBER(title: str = 'Bit/Block Error Rate')[source]#
Bases:
objectProvides a plotting object to simulate and store BER/BLER curves.
- Parameters:
title (str) – Figure title.
- Inputs:
snr_db – numpy.ndarray or list of numpy.ndarray. SNR values.
ber – numpy.ndarray or list of numpy.ndarray. BER values corresponding to
snr_db.legend – str or list of str. Legend entries.
is_bler – bool or list of bool. If True,
berwill be interpreted as BLER.show_ber – bool. If True, BER curves will be plotted.
show_bler – bool. If True, BLER curves will be plotted.
xlim – None | (float, float). x-axis limits.
ylim – None | (float, float). y-axis limits.
save_fig – bool. If True, the figure is saved as .png.
path – str. Path to save the figure if
save_figis True.
Examples
import numpy as np from sionna.phy.utils import PlotBER ber_plot = PlotBER(title="My BER Plot") snr = np.array([0, 2, 4, 6, 8]) ber = np.array([0.1, 0.05, 0.01, 0.001, 0.0001]) ber_plot.add(snr, ber, legend="Curve 1") ber_plot() # Display the plot
Attributes
- property ber: List[numpy.ndarray]#
Stored BER/BLER values.
- property snr: List[numpy.ndarray]#
Stored SNR values.
Methods
- simulate(mc_fun: Callable, ebno_dbs: torch.Tensor, batch_size: int, max_mc_iter: int, legend: str = '', add_ber: bool = True, add_bler: bool = False, soft_estimates: bool = False, num_target_bit_errors: int | None = None, num_target_block_errors: int | None = None, target_ber: float | None = None, target_bler: float | None = None, early_stop: bool = True, compile_mode: str | None = None, add_results: bool = True, forward_keyboard_interrupt: bool = True, show_fig: bool = True, verbose: bool = True) Tuple[torch.Tensor, torch.Tensor][source]#
Simulate BER/BLER curves for a given model and saves the results.
Internally calls
sionna.phy.utils.sim_ber().- Parameters:
mc_fun (Callable) – Callable that yields the transmitted bits b and the receiver’s estimate b_hat for a given
batch_sizeandebno_db. Ifsoft_estimatesis True, b_hat is interpreted as logit.ebno_dbs (torch.Tensor) – SNR points to be evaluated.
batch_size (int) – Batch-size for evaluation.
max_mc_iter (int) – Max. number of Monte-Carlo iterations per SNR point.
legend (str) – Name to appear in legend.
add_ber (bool) – If True, BER will be added to plot.
add_bler (bool) – If True, BLER will be added to plot.
soft_estimates (bool) – If True,
b_hatis interpreted as logit and additional hard-decision is applied internally.num_target_bit_errors (int | None) – Target number of bit errors per SNR point until the simulation stops.
num_target_block_errors (int | None) – Target number of block errors per SNR point until the simulation stops.
target_ber (float | None) – The simulation stops after the first SNR point which achieves a lower bit error rate as specified by
target_ber. This requiresearly_stopto be True.target_bler (float | None) – The simulation stops after the first SNR point which achieves a lower block error rate as specified by
target_bler. This requiresearly_stopto be True.early_stop (bool) – If True, the simulation stops after the first error-free SNR point (i.e., no error occurred after
max_mc_iterMonte-Carlo iterations).compile_mode (str | None) – Compilation mode for
mc_fun. If None,mc_funis executed as is. Options: None,"default","reduce-overhead","max-autotune".add_results (bool) – If True, the simulation results will be appended to the internal list of results.
forward_keyboard_interrupt (bool) – If False, KeyboardInterrupts will be caught internally and not forwarded (e.g., will not stop outer loops). If True, the simulation ends and returns the intermediate simulation results.
show_fig (bool) – If True, a BER figure will be plotted.
verbose (bool) – If True, the current progress will be printed.
- Outputs:
ber – torch.float. Simulated bit-error rates.
bler – torch.float. Simulated block-error rates.
- add(ebno_db: numpy.ndarray, ber: numpy.ndarray, is_bler: bool = False, legend: str = '') None[source]#
Add static reference curves.
- Parameters:
ebno_db (numpy.ndarray) – SNR points.
ber (numpy.ndarray) – BER corresponding to each SNR point.
is_bler (bool) – If True,
beris interpreted as BLER.legend (str) – Legend entry.