Visualizers#

plot_chain_profiling(chain, input, title='Processor Timings', N_test=100, orientation='horizontal')#

Plot the profiling results of a chain of processors using a box plot to visualize the distribution of execution times.

This function runs a specified chain of processors multiple times, collects the profiling results, and visualizes them using a box plot to show the distribution of execution times for each method in the chain.

Parameters#

chainobject

An object representing the chain of processors to be profiled. It must have a method profile_execution_time that takes input as an argument and returns a dictionary of execution times for each method in the chain.

inputany

The input data to be passed to the profile_execution_time method of the chain. The type and structure of this input depend on the specific implementation of the chain.

titlestr, optional

The title of the box plot. Default is ‘Box Plot of Method Timings’.

N_testint, optional

The number of times to run the chain and collect profiling results. Default is 100.

Note

Increasing the number N_test provides a more accurate representation of the execution time distribution but takes longer to compute.

Returns#

None

This function does not return any value. It displays a box plot of the profiling results.

class TimeScope(num: int | None, fs: float = 1.0, plot_type: Literal['full', 'real', 'abs', 'pow'] = 'real', fig_indices: Tuple[int, ...] = (0,), slices: Tuple[slice, ...] = (slice(None, None, None),), marker: str = '-', is_mimo: bool = True, axis: int = 0, title: str = 'Time Scope', name: str = 'time_scope')#

A basic Time Scope for visualizing signals in the time domain.

This class provides a simple interface to plot the real and imaginary parts of a complex signal, or just the signal itself if it’s real, against time.

Attributes#

fsfloat

Sampling frequency used to calculate the time axis. Default is 1.0.

numOptional[int]

The figure number to be used for the plot. If None, a new figure is created.

complex_typestr

Determines which part of the complex signal to plot. Options are “real”, “abs”, and “pow”. Default is “abs”.

titlestr

Title of the plot. Default is “Time Scope”.

namestr

Name of the time scope instance. Default is “time_scope”.

markerstr

Marker style for the plot. Default is “-“.

axisint

The axis along which to plot the signal for MIMO. Default is -1.

fig_indicestuple

Indices of the figures to plot for MIMO signals.

class SpectrumScope(fs: float = 1.0, norm: bool = True, dB: bool = True, xlim: Tuple[float, float] | None = None, ylim: Tuple[float, float] | None = None, num: int | None = None, shift: bool = False, fig_indices: Tuple[int, ...] = (0,), slices: Tuple[slice, ...] = (slice(None, None, None),), is_mimo: bool = False, axis: int = 0, title: str = 'Spectrum Scope', name: str = 'SpectrumScope')#

A basic Spectrum Scope for visualizing the power spectral density (PSD) of a signal.

This class provides functionality to compute the Fast Fourier Transform (FFT) of a signal and plot its spectrum, optionally using decibels for the amplitude and applying a shift for zero frequency at the center.

Attributes#

fsfloat

Sampling frequency of the input signal.

normbool

If True, normalizes the spectrum to its maximum value.

dBbool

If True, converts the spectrum to decibel scale.

xlimtuple or None

Limits for the x-axis (frequency). None for no limits.

ylimtuple or None

Limits for the y-axis (amplitude). None for no limits.

numint or None

The figure number for plotting. If None, a new figure is created.

shiftbool

If True, shifts the zero frequency to the center of the spectrum.

titlestr

Title of the plot. Default is “Spectrum Scope”.

namestr

Name of the Spectrum Scope instance.

axisint

The axis along which to compute the FFT for MIMO. Default is -1.

fig_indicestuple

Indices of the figures to plot for MIMO signals.

slicestuple

Slices to apply to the input signal for selecting which parts to plot.

class IQScope(num: int | None = None, title: str = 'IQ Scope', fig_indices: Tuple[int, ...] = (0,), slices: Tuple[slice, ...] = (slice(None, None, None),), is_mimo: bool = True, axis: int = 0, name: str = 'IQScope')#

A basic IQ Scope for visualizing the In-phase (I) and Quadrature (Q) components of a complex signal.

This class provides a simple interface to plot the I and Q components of a signal on a 2D scatter plot. It allows for specification of the range of samples to plot and custom axis limits.

Attributes#

numOptional[int]

The figure number for plotting. If None, a new figure is created.

titlestr

Title of the plot. Default is “IQ Scope”.

namestr

Name of the IQ Scope instance. Default is “IQScope”.

axisint

The axis along which to plot the IQ components for MIMO. Default is -1.

fig_indicestuple

Indices of the figures to plot for MIMO signals.

slicestuple

Slices to apply to the input signal for selecting which parts to plot.

class KDEScope(bw_adjust: float = 1.0, thresh: float = 0.05, num: int | None = None, is_mimo: bool = False, name: str = 'KDE Scope')#

A basic Kernel Density Estimation (KDE) Scope for visualizing bivariate distributions.

This class provides functionality to plot the kernel density estimation of a complex signal’s In-phase (I) and Quadrature (Q) components. It uses Seaborn’s kdeplot for visualization.

Attributes#

bw_adjustfloat

Bandwidth adjustment for kernel density estimation. Larger values make the estimation smoother. Default is 1.0.

threshfloat

Threshold for the density estimate. Only regions with density above this threshold will be plotted. Default is 0.05.

numOptional[int]

The figure number for plotting. If None, a new figure is created.

namestr

Title of the KDE plot. Default is “KDE Scope”.

class Scope(scope_type: str, **kwargs)#

A generic Scope class that instantiates the appropriate visualizer based on the type attribute.

Attributes#

scope_typestr

The type of scope to instantiate. Options are “time”, “spectrum”, “iq”, and “kde”.

kwargsdict

Additional keyword arguments to pass to the specific scope class.

class WelchScope(fs=1, nperseg=None, norm=True, dB=True, xlim=None, ylim=None, num=None, title='PSD_scope', name='spectrum_scope')#

Scope for visualizing the power spectral density (PSD) of a signal using Welch’s method.

This class provides functionality to compute and plot the PSD of a signal optionally using decibels for the amplitude and applying a shift for zero frequency at the center.

Attributes#

F_sfloat

Sampling frequency of the input signal.

npersegint

The number of samples by window

normbool

If True, normalizes the spectrum to its maximum value.

dBbool

If True, converts the spectrum to decibel scale.

xlimtuple or None

Limits for the x-axis (frequency). None for no limits.

ylimtuple or None

Limits for the y-axis (amplitude). None for no limits.

numint or None

The figure number for plotting. If None, a new figure is created.

shiftbool

If True, shifts the zero frequency to the center of the spectrum.

labelstr

Label for the plot.

namestr

Name of the Spectrum Scope instance.