filter_functions.plotting module

This module provides various plotting functions.

Functions

plot_bloch_vector_evolution()

Plot the evolution of the Bloch vector on a QuTiP-generated Bloch sphere

plot_filter_function()

Plot the filter function of a given PulseSequence

plot_infidelity_convergence()

Helper function called by infidelity() to plot the convergence of the infidelity

plot_pulse_correlation_filter_function()

Plot the pulse correlation filter function of a given PulseSequence

plot_pulse_train()

Plot the pulse train of a given PulseSequence

plot_cumulant_function()

Plot the cumulant function of a PulseSequence for a given spectrum as an image.

plot_bloch_vector_evolution(pulse: PulseSequence, psi0: ndarray | Qobj | None = None, b: Bloch | None = None, n_samples: int | None = None, cmap: Colormap | str = 'winter', add_cbar: bool = False, show: bool = True, return_Bloch: bool = False, cbar_kwargs: dict | None = None, **bloch_kwargs) None | Bloch[source]

Plot the evolution of the Bloch vector under the given pulse sequence.

Parameters:
pulse: PulseSequence

The PulseSequence instance whose control Hamiltonian determines the time evolution of the Bloch vector.

psi0: Qobj or array_like, optional

The initial state before the pulse is applied. Defaults to \(|0\rangle\).

b: qutip.Bloch, optional

If given, the QuTiP Bloch instance on which to plot the time evolution.

n_samples: int, optional

The number of time points to be sampled.

cmap: matplotlib colormap, optional

The colormap for the trajectory. Requires matplotlib >= 3.3.0.

add_cbar: bool, optional

Add a colorbar encoding the time evolution to the figure. Default is false.

show: bool, optional

Whether to show the sphere (by calling b.make_sphere()).

return_Bloch: bool, optional

Whether to return the qutip.bloch.Bloch instance

cbar_kwargs: dict, optional

A dictionary with keyword arguments to be fed into the colorbar constructor (if add_cbar == True).

**bloch_kwargs: optional

Keyword arguments to be fed into the qutip.Bloch constructor (if b not given).

Returns:
b: qutip.Bloch

The qutip.Bloch instance

Raises:
ValueError

If the pulse is for more than one qubit

See also

qutip.bloch.Bloch

Qutip’s Bloch sphere implementation.

plot_cumulant_function(pulse: PulseSequence | None = None, spectrum: ndarray | None = None, omega: Sequence[float] | None = None, cumulant_function: ndarray | None = None, n_oper_identifiers: Sequence[int] | None = None, second_order: bool = False, colorscale: str = 'linear', linthresh: float | None = None, basis_labels: Sequence[str] | None = None, basis_labelsize: int | None = None, cbar_label: str = 'Cumulant Function', cbar_labelsize: int | None = None, fig: Figure | None = None, grid: ImageGrid | None = None, cmap: Colormap | str | None = None, grid_kw: dict | None = None, cbar_kw: dict | None = None, imshow_kw: dict | None = None, **figure_kw) Tuple[Figure, ImageGrid][source]

Plot the cumulant function for a given noise spectrum as an image.

The cumulant function generates the error transfer matrix \(\tilde{\mathcal{U}}\) exactly for Gaussian noise and to second order for non-Gaussian noise.

The function may be called with either a PulseSequence, a spectrum, and a list of frequencies in which case the cumulant function is calculated for those parameters, or with a precomputed cumulant function.

As of now, only auto-correlated spectra are implemented.

Parameters:
pulse: PulseSequence

The pulse sequence.

spectrum: ndarray

The two-sided noise spectrum.

omega: array_like

The frequencies for which to evaluate the error transfer matrix.

cumulant_function: ndarray, shape (n_nops, d**2, d**2)

A precomputed cumulant function. If given, pulse, spectrum, omega are not required.

n_oper_identifiers: array_like, optional

The identifiers of the noise operators for which the cumulant function should be plotted. All identifiers can be accessed via pulse.n_oper_identifiers. Defaults to all.

second_order: bool, optional

Also take into account the frequency shifts \(\Delta\) that correspond to second order Magnus expansion and constitute unitary terms. Default False.

colorscale: str, optional

The scale of the color code (‘linear’ or ‘log’ (default))

linthresh: float, optional

The threshold below which the colorscale will be linear (only for ‘log’) colorscale

basis_labels: array_like (str), optional

Custom labels for the elements of the cumulant function (the basis elements). Grabbed from the basis by default.

basis_labelsize: int, optional

The size in points for the basis labels.

cbar_label: str, optional

The label for the colorbar. Default: ‘Cumulant Function’.

cbar_labelsize: int, optional

The size in points for the colorbar label.

fig: matplotlib figure, optional

A matplotlib figure instance to plot in

grid: matplotlib ImageGrid, optional

An ImageGrid instance to use for plotting.

cmap: matplotlib colormap, optional

The colormap for the matrix plot.

grid_kw: dict, optional

Dictionary with keyword arguments passed to the ImageGrid constructor.

cbar_kw: dict, optional

Dictionary with keyword arguments passed to the colorbar constructor.

imshow_kw: dict, optional

Dictionary with keyword arguments passed to imshow.

figure_kw: optional

Keyword argument dictionaries that are fed into the matplotlib.pyplot.figure() function if no fig instance is specified.

Returns:
fig: matplotlib figure

The matplotlib figure instance used for plotting.

grid: matplotlib ImageGrid

The ImageGrid instance used for plotting.

plot_filter_function(pulse: PulseSequence, omega: Sequence[float] | None = None, n_oper_identifiers: Sequence[int] | None = None, fig: Figure | None = None, axes: Axes | None = None, xscale: str = 'log', yscale: str = 'linear', omega_in_units_of_tau: bool = False, cycler: Cycler | None = None, plot_kw: dict = {}, subplot_kw: dict | None = None, gridspec_kw: dict | None = None, **figure_kw) Tuple[Figure, Axes, Legend][source]

Plot the fidelity filter function(s) of the given PulseSequence for positive frequencies. As of now only the diagonal elements of \(F_{\alpha\beta}\) are implemented, i.e. the filter functions corresponding to uncorrelated noise sources.

Parameters:
pulse: PulseSequence

The pulse sequence whose filter function to plot.

omega: array_like, optional

The frequencies at which to evaluate the filter function. If not given, the pulse sequence’s omega attribute is used (if set) or sensible values are chosen automatically (if None)

n_oper_identifiers: array_like, optional

The identifiers of the noise operators for which the filter function should be plotted. All identifiers can be accessed via pulse.n_oper_identifiers. Defaults to all.

fig: matplotlib figure, optional

A matplotlib figure instance to plot in

axes: matplotlib axes, optional

A matplotlib axes instance to use for plotting.

xscale: str, optional

x-axis scaling. One of (‘linear’, ‘log’).

yscale: str, optional

y-axis scaling. One of (‘linear’, ‘log’).

omega_in_units_of_tau: bool, optional

Plot \(\omega\tau\) or just \(\omega\) on x-axis.

cycler: cycler.Cycler, optional

A Cycler instance used to set the style cycle if multiple lines are to be drawn

plot_kw: dict, optional

Dictionary with keyword arguments passed to the plot function

subplot_kw: dict, optional

Dictionary with keyword arguments passed to the subplots constructor

gridspec_kw: dict, optional

Dictionary with keyword arguments passed to the gridspec constructor

figure_kw: optional

Keyword argument dictionaries that are fed into the matplotlib.pyplot.subplots() function if no fig instance is specified.

Returns:
fig: matplotlib figure

The matplotlib figure instance used for plotting.

axes: matplotlib axes

The matplotlib axes instance used for plotting.

legend: matplotlib legend

The matplotlib legend instance in the plot.

Raises:
ValueError

If an invalid number of n_oper_labels were given

plot_infidelity_convergence(n_samples: Sequence[int], infids: Sequence[float], axes: Axes | None = None) Tuple[Figure, Axes][source]

Plot the convergence of the infidelity integral. The function arguments are those returned by infidelity() with the test_convergence flag set to True.

Parameters:
n_samples: array_like

Array with the number of samples at which the integral was evaluated

infids: array_like, shape (n_samples, [n_oper_inds, optional])

Array with the calculated infidelities for each noise operator on the second axis or the second axis already traced out.

axes: sequence of two matplotlib axes, optional

Two axes that the result is plotted in.

Returns:
fig: matplotlib figure

The matplotlib figure instance used for plotting.

axes: matplotlib axes

The matplotlib axes instances used for plotting.

plot_pulse_correlation_filter_function(pulse: PulseSequence, n_oper_identifiers: Sequence[int] | None = None, fig: Figure | None = None, xscale: str = 'log', yscale: str = 'linear', omega_in_units_of_tau: bool = True, cycler: Cycler | None = None, plot_kw: dict = {}, subplot_kw: dict | None = None, gridspec_kw: dict | None = None, **figure_kw) Tuple[Figure, Axes, Legend][source]

Plot the fidelity pulse correlation filter functions of the given PulseSequence if they were computed during concatenation for positive frequencies.

Returns a figure with n by n subplots where n is the number of pulses that were concatenated. As of now only the diagonal elements of \(F_{\alpha\beta}\) are implemented, i.e. the filter functions corresponding to uncorrelated noise sources.

Parameters:
pulse: PulseSequence

The pulse sequence whose filter function to plot.

n_oper_identifiers: array_like, optional

The identifiers of the noise operators for which the filter function should be plotted. All identifiers can be accessed via pulse.n_oper_identifiers. Defaults to all.

fig: matplotlib figure, optional

A matplotlib figure instance to plot in

xscale: str, optional

x-axis scaling. One of (‘linear’, ‘log’).

yscale: str, optional

y-axis scaling. One of (‘linear’, ‘log’).

omega_in_units_of_tau: bool, optional

Plot \(\omega\tau\) or just \(\omega\) on x-axis.

cycler: cycler.Cycler, optional

A Cycler instance used to set the style cycle if multiple lines are to be drawn in one subplot. Used for all subplots.

plot_kw: dict, optional

Dictionary with keyword arguments passed to the plot function

subplot_kw: dict, optional

Dictionary with keyword arguments passed to the subplots constructor

gridspec_kw: dict, optional

Dictionary with keyword arguments passed to the gridspec constructor

figure_kw: optional

Keyword argument dictionaries that are fed into the matplotlib.pyplot.subplots() function if no fig instance if specified.

Returns:
fig: matplotlib figure

The matplotlib figure instance used for plotting.

axes: matplotlib axes

The matplotlib axes instances used for plotting.

legend: matplotlib legend

The matplotlib legend instance in the plot.

Raises:
CalculationError

If the pulse correlation filter function was not computed during concatenation.

plot_pulse_train(pulse: PulseSequence, c_oper_identifiers: Sequence[int] | None = None, fig: Figure | None = None, axes: Axes | None = None, cycler: Cycler | None = None, plot_kw: dict | None = {}, subplot_kw: dict | None = None, gridspec_kw: dict | None = None, **figure_kw) Tuple[Figure, Axes, Legend][source]

Plot the pulsetrain of the PulseSequence pulse.

Parameters:
pulse: PulseSequence

The pulse sequence whose pulse train to plot.

c_oper_identifiers: array_like, optional

The identifiers of the control operators for which the pulse train should be plotted. All identifiers can be accessed via pulse.c_oper_identifiers. Defaults to all.

fig: matplotlib figure, optional

A matplotlib figure instance to plot in

axes: matplotlib axes, optional

A matplotlib axes instance to use for plotting.

cycler: cycler.Cycler, optional

A Cycler instance used to set the style cycle if multiple lines are to be drawn

plot_kw: dict, optional

Dictionary with keyword arguments passed to the plot function

subplot_kw: dict, optional

Dictionary with keyword arguments passed to the subplots constructor

gridspec_kw: dict, optional

Dictionary with keyword arguments passed to the gridspec constructor

figure_kw: optional

Keyword argument dictionaries that are fed into the matplotlib.pyplot.subplots() function if no fig instance is specified.

Returns:
fig: matplotlib figure

The matplotlib figure instance used for plotting.

axes: matplotlib axes

The matplotlib axes instance used for plotting.

legend: matplotlib legend

The matplotlib legend instance in the plot.

Raises:
ValueError

If an invalid number of c_oper_labels were given