visualize_smatrices

circuit_analyzer.all.visualize_smatrices(smatrices, smatrix_names=None, capture_errors_explicitly=False, term_pairs=None, scale='dB', title=None, xlabel=None, ylabel=None)

Visualizes one or multiple S-matrices in an interactive plot. Used for visualising results coming from Corner Analysis, Monte Carlo Analysis.

The function supports both list and dictionary inputs for the S-matrices, with optional names for labeling. It can plot data in linear or decibel (dB) scale and allows customization of plot labels and titles. If requested, errors from the underlying plotting process can be explicitly captured and printed.

Parameters:
smatriceslist of SMatrix1DSweep or dict[str, SMatrix1DSweep]

The S-matrix or S-matrices to visualize. When a dictionary is provided, keys are used as smatrix_names for the corresponding S-matrices.

smatrix_nameslist of str, optional

A list of names to use as labels for the given S-matrices. If smatrices is a dict and smatrix_names is provided, the provided smatrix_names will override the dictionary keys. If not provided: For a list input, names are automatically generated as smatrix_1, smatrix_2, …, in the order. For a dict input, keys of the smatrices are used as smatrix_names.

capture_errors_explicitlybool, default = False

If True, errors from the underlying plotting subprocess are explicitly caught and printed.

term_pairsOptional[List[Tuple[str, str]]]

List of term pairs for which to plot the default S-parameters. The order in the tuple is (“in”, “out”), i.e. to retrieve the transmission from “in” to “out” defined by s_matrix[“out”, “in”], term_pairs should be [(“in”, “out”)]. If specified together with terms, an error will be raised. If None, will plot the combinations according to the terms argument. If terms is also None, will plot every combination between all available terms.

scale{‘linear’, ‘dB’}, default = ‘dB’

The scale to use for plotting S-matrix magnitude.

titlestr, optional

Title of the plot. If None, “S-parameters” is used as default title.

xlabelstr, optional

Label for the X-axis. If None, a default label is used.

ylabelstr, optional

Label for the Y-axis. If None, a default label is used.

Returns:
None

The function displays the interactive plot directly and does not return any value.

Examples

>>> import circuit_analyzer.all as ca
>>> import numpy as np
>>> cell = MZI()
>>> cm = cell.CircuitModel()
>>> wavelengths = np.linspace(1.5, 1.6, 501)
>>>
>>> with ca.setup('/path/to/configuration'):
>>>     results = ca.corner_analysis_all_combinations(
>>>          circuit_model=cm,
>>>          wavelengths=wavelengths
>>>     )
>>> # You can display the simulation results for all corners
>>> ca.visualize_smatrices(results)
>>> # You can also provide a list of S-matrices to plot different corners.
>>> smats = [smatrix1, smatrix2, smatrix3]
>>> ca.visualize_smatrices(smats, smatrix_names=["min", "nominal", "max"])