kaira.utils.PlottingUtils

Inheritance diagram of PlottingUtils

Inheritance diagram for PlottingUtils

class kaira.utils.PlottingUtils[source]

Bases: object

A comprehensive plotting utility class with static methods for visualization.

This class provides a centralized collection of plotting functions for various communication system analysis tasks including LDPC codes, modulation schemes, error rate analysis, signal processing, and more.

All methods are static to allow easy access without instantiation:

Example

fig = PlottingUtils.plot_ber_performance(snr_range, ber_values, labels)

Methods

__init__

close_all_figures

Close all matplotlib figures to free memory.

plot_belief_propagation_iteration

Plot belief propagation iteration state.

plot_ber_performance

Plot BER vs SNR performance curves.

plot_bit_error_visualization

Visualize bit errors in transmission.

plot_bler_vs_snr_analysis

Plot BLER vs SNR analysis.

plot_block_error_visualization

Visualize block errors.

plot_blockwise_operation

Plot blockwise operation visualization.

plot_capacity_analysis

Plot channel capacity analysis for different channel types.

plot_channel_effects

Plot the effects of a channel on transmitted signals.

plot_code_structure_comparison

Plot comparison of different code structures.

plot_coding_gain

Plot coding gain vs SNR.

plot_complexity_comparison

Plot complexity comparison charts.

plot_constellation

Plot constellation diagram with optional received symbols.

plot_error_rate_comparison

Compare different error rate metrics.

plot_hamming_code_visualization

Plot Hamming code structure visualization.

plot_latency_distribution

Plot latency distribution and statistics.

plot_ldpc_matrix_comparison

Plot comparison of LDPC code matrix structures.

plot_multi_qam_ber_performance

Plot BER performance for multiple QAM orders.

plot_multiple_metrics_comparison

Plot comparison of multiple error rate metrics.

plot_parity_check_visualization

Plot parity check syndrome and error pattern visualization.

plot_qam_constellation_with_errors

Plot QAM constellation showing transmitted and received symbols.

plot_signal_analysis

Plot comprehensive signal analysis including time and frequency domain.

plot_spectral_efficiency

Plot spectral efficiency vs SNR for different modulation schemes.

plot_symbol_error_analysis

Analyze symbol errors.

plot_tanner_graph

Create enhanced Tanner graph visualization.

plot_throughput_comparison

Plot throughput comparison across different configurations.

setup_plotting_style

Set up consistent plotting style for all examples.

Attributes

BELIEF_CMAP

MATRIX_CMAP

MODERN_PALETTE

BELIEF_CMAP = <matplotlib.colors.LinearSegmentedColormap object>
MODERN_PALETTE = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd']
MATRIX_CMAP = <matplotlib.colors.LinearSegmentedColormap object>
static setup_plotting_style()[source]

Set up consistent plotting style for all examples.

static close_all_figures()[source]

Close all matplotlib figures to free memory.

static plot_ldpc_matrix_comparison(H_matrices: List[Tensor], titles: List[str], main_title: str = 'LDPC Matrix Comparison') Figure[source]

Plot comparison of LDPC code matrix structures.

Parameters:
  • H_matrices (List[torch.Tensor]) – List of parity check matrices to compare

  • titles (List[str]) – Titles for each matrix

  • main_title (str) – Overall plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_ber_performance(snr_range: ndarray, ber_values: List[ndarray], labels: List[str], title: str = 'BER vs SNR Performance', ylabel: str = 'Bit Error Rate') Figure[source]

Plot BER vs SNR performance curves.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • ber_values (List[np.ndarray]) – BER values for each configuration

  • labels (List[str]) – Labels for each curve

  • title (str) – Plot title

  • ylabel (str) – Y-axis label

Returns:

The created figure

Return type:

plt.Figure

static plot_complexity_comparison(code_types: List[str], metrics: Dict[str, List[float]], title: str = 'Complexity Comparison') Figure[source]

Plot complexity comparison charts.

Parameters:
  • code_types (List[str]) – Names of different code types

  • metrics (Dict[str, List[float]]) – Dictionary mapping metric names to values for each code type

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_tanner_graph(H: Tensor, title: str = 'LDPC Tanner Graph') Figure[source]

Create enhanced Tanner graph visualization.

Parameters:
Returns:

The created figure

Return type:

plt.Figure

static plot_constellation(constellation: Tensor, received_symbols: Tensor | None = None, title: str = 'Constellation Diagram') Figure[source]

Plot constellation diagram with optional received symbols.

Parameters:
  • constellation (torch.Tensor) – Ideal constellation points

  • received_symbols (Optional[torch.Tensor]) – Optional received symbols to overlay

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_throughput_comparison(throughput_data: Dict[str, Any], title: str = 'Throughput Comparison') Figure[source]

Plot throughput comparison across different configurations.

Parameters:
  • throughput_data (Dict[str, Any]) – Dictionary containing throughput data

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_latency_distribution(latency_data: Dict[str, Any], title: str = 'Latency Distribution') Figure[source]

Plot latency distribution and statistics.

Parameters:
  • latency_data (Dict[str, Any]) – Dictionary containing latency statistics

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_coding_gain(snr_range: ndarray, coding_gain: ndarray, code_type: str = 'Unknown', title: str = 'Coding Gain') Figure[source]

Plot coding gain vs SNR.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • coding_gain (np.ndarray) – Coding gain values in dB

  • code_type (str) – Type of error correction code

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_spectral_efficiency(snr_range: ndarray, spectral_efficiency: ndarray, modulation_types: List[str], title: str = 'Spectral Efficiency') Figure[source]

Plot spectral efficiency vs SNR for different modulation schemes.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • spectral_efficiency (np.ndarray) – Spectral efficiency values (bits/s/Hz)

  • modulation_types (List[str]) – Names of modulation schemes

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_channel_effects(original_signal: Tensor, received_signal: Tensor, channel_name: str = 'Channel', title: str = 'Channel Effects') Figure[source]

Plot the effects of a channel on transmitted signals.

Parameters:
  • original_signal (torch.Tensor) – Original transmitted signal

  • received_signal (torch.Tensor) – Signal after passing through channel

  • channel_name (str) – Name of the channel

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_signal_analysis(signal: Tensor, signal_name: str = 'Signal', title: str = 'Signal Analysis') Figure[source]

Plot comprehensive signal analysis including time and frequency domain.

Parameters:
  • signal (torch.Tensor) – Input signal to analyze

  • signal_name (str) – Name of the signal

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_capacity_analysis(snr_range: ndarray, capacity_data: Dict[str, ndarray], title: str = 'Channel Capacity Analysis') Figure[source]

Plot channel capacity analysis for different channel types.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • capacity_data (Dict[str, np.ndarray]) – Dictionary mapping channel names to capacity values

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_belief_propagation_iteration(H: Tensor, beliefs: Tensor, iteration: int, title: str = 'Belief Propagation Iteration') Figure[source]

Plot belief propagation iteration state.

Parameters:
  • H (torch.Tensor) – Parity check matrix

  • beliefs (torch.Tensor) – Current belief values

  • iteration (int) – Current iteration number

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_blockwise_operation(input_blocks: List[Tensor], output_blocks: List[Tensor], operation_name: str = 'Blockwise Operation') Figure[source]

Plot blockwise operation visualization.

Parameters:
  • input_blocks (List[torch.Tensor]) – Input blocks

  • output_blocks (List[torch.Tensor]) – Output blocks after operation

  • operation_name (str) – Name of the operation

Returns:

The created figure

Return type:

plt.Figure

static plot_hamming_code_visualization(generator_matrix: Tensor, parity_check_matrix: Tensor, title: str = 'Hamming Code Structure') Figure[source]

Plot Hamming code structure visualization.

Parameters:
  • generator_matrix (torch.Tensor) – Generator matrix

  • parity_check_matrix (torch.Tensor) – Parity check matrix

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_parity_check_visualization(syndrome: Tensor, error_pattern: Tensor, title: str = 'Parity Check Analysis') Figure[source]

Plot parity check syndrome and error pattern visualization.

Parameters:
Returns:

The created figure

Return type:

plt.Figure

static plot_code_structure_comparison(codes_data: Dict[str, Dict[str, Any]], title: str = 'Code Structure Comparison') Figure[source]

Plot comparison of different code structures.

Parameters:
  • codes_data (Dict[str, Dict[str, Any]]) – Dictionary containing code data for comparison

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_bit_error_visualization(original_bits: Tensor, errors: Tensor, received_bits: Tensor, title: str = 'Bit Error Analysis') Figure[source]

Visualize bit errors in transmission.

Parameters:
Returns:

The created figure

Return type:

plt.Figure

static plot_error_rate_comparison(metrics: Dict[str, float], title: str = 'Error Rate Comparison') Figure[source]

Compare different error rate metrics.

Parameters:
  • metrics (Dict[str, float]) – Dictionary of metric names and values

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_block_error_visualization(blocks_with_errors: Tensor, block_error_rate: float, title: str = 'Block Error Visualization') Figure[source]

Visualize block errors.

Parameters:
  • blocks_with_errors (torch.Tensor) – Indicator of which blocks have errors

  • block_error_rate (float) – Overall block error rate

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_qam_constellation_with_errors(transmitted: Tensor, received: Tensor, title: str = 'QAM Constellation with Errors') Figure[source]

Plot QAM constellation showing transmitted and received symbols.

Parameters:
  • transmitted (torch.Tensor) – Transmitted constellation points

  • received (torch.Tensor) – Received constellation points

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_symbol_error_analysis(error_mask: Tensor, ber: float, ser: float, title: str = 'Symbol Error Analysis') Figure[source]

Analyze symbol errors.

Parameters:
  • error_mask (torch.Tensor) – Mask indicating which symbols have errors

  • ber (float) – Bit error rate

  • ser (float) – Symbol error rate

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

static plot_multi_qam_ber_performance(snr_range: ndarray, ber_results: Dict[str, ndarray], ser_results: Dict[str, ndarray], qam_orders: Sequence[int]) Figure[source]

Plot BER performance for multiple QAM orders.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • ber_results (Dict[str, np.ndarray]) – BER results for each QAM order

  • ser_results (Dict[str, np.ndarray]) – SER results for each QAM order

  • qam_orders (Sequence[int]) – Sequence of QAM orders

Returns:

The created figure

Return type:

plt.Figure

static plot_bler_vs_snr_analysis(snr_range: ndarray, bler_data: Dict[str, ndarray], block_sizes: List[int]) Figure[source]

Plot BLER vs SNR analysis.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • bler_data (Dict[str, np.ndarray]) – BLER data for different block sizes

  • block_sizes (List[int]) – List of block sizes

Returns:

The created figure

Return type:

plt.Figure

static plot_multiple_metrics_comparison(snr_range: ndarray, metrics: Dict[str, ndarray], title: str = 'Multiple Metrics Comparison') Figure[source]

Plot comparison of multiple error rate metrics.

Parameters:
  • snr_range (np.ndarray) – SNR values in dB

  • metrics (Dict[str, np.ndarray]) – Dictionary of metric names and values

  • title (str) – Plot title

Returns:

The created figure

Return type:

plt.Figure

__init__()