pulse_diagram#

Functions for drawing pulse diagrams

Module Contents#

Classes#

SampledPulse

Functions#

_populate_port_mapping(→ None)

Dynamically add up to 8 ports to the port_map dictionary.

validate_operation_data(operation_data, port_map, ...)

Validates if the pulse/acquisition information is valid for visualization.

pulse_diagram_plotly(→ plotly.graph_objects.Figure)

Produce a plotly visualization of the pulses used in the schedule.

sample_schedule() → Dict[str, List[SampledPulse]])

Sample a schedule at discrete points in time.

deduplicate_legend_handles_labels(→ None)

Remove duplicate legend entries.

plot_single_subplot_mpl(...)

Plot all pulses for all ports in the schedule in the same subplot.

plot_multiple_subplots_mpl(...)

Plot pulses in a different subplot for each port in the sampled schedule.

pulse_diagram_matplotlib(, multiple_subplots, ax, ...)

Plots a schedule using matplotlib.

get_window_operations(→ List[Tuple[float, float, ...)

Return a list of all WindowOperations with start and end time.

plot_window_operations(...)

Plot the window operations in a schedule.

plot_acquisition_operations(→ List[Any])

Plot the acquisition operations in a schedule.

Attributes#

logger

logger[source]#
_populate_port_mapping(schedule, portmap: Dict[str, int], ports_length) None[source]#

Dynamically add up to 8 ports to the port_map dictionary.

validate_operation_data(operation_data, port_map, schedulable, operation)[source]#

Validates if the pulse/acquisition information is valid for visualization.

pulse_diagram_plotly(schedule: quantify_scheduler.Schedule | quantify_scheduler.CompiledSchedule, port_list: Optional[List[str]] = None, fig_ch_height: float = 300, fig_width: float = 1000, modulation: Literal[off, if, clock] = 'off', modulation_if: float = 0.0, sampling_rate: float = 1000000000.0) plotly.graph_objects.Figure[source]#

Produce a plotly visualization of the pulses used in the schedule.

Parameters
  • schedule – The schedule to render.

  • port_list – A list of ports to show. if set to None will use the first 8 ports it encounters in the sequence.

  • fig_ch_height – Height for each channel subplot in px.

  • fig_width – Width for the figure in px.

  • modulation – Determines if modulation is included in the visualization.

  • modulation_if – Modulation frequency used when modulation is set to “if”.

  • sampling_rate – The time resolution used to sample the schedule in Hz.

Returns

the plot

Return type

plotly.graph_objects.Figure

class SampledPulse[source]#
time: numpy.ndarray[source]#
signal: numpy.ndarray[source]#
label: str[source]#
sample_schedule(schedule: quantify_scheduler.Schedule | quantify_scheduler.CompiledSchedule, port_list: Optional[List[str]] = None, modulation: Literal[off, if, clock] = 'off', modulation_if: float = 0.0, sampling_rate: float = 1000000000.0, x_range: Tuple[float, float] = (-np.inf, np.inf)) Dict[str, List[SampledPulse]][source]#

Sample a schedule at discrete points in time.

Parameters
  • schedule – The schedule to render.

  • port_list – A list of ports to show. if set to None will use the first 8 ports it encounters in the sequence.

  • modulation – Determines if modulation is included in the visualization.

  • modulation_if – Modulation frequency used when modulation is set to “if”.

  • sampling_rate – The time resolution used to sample the schedule in Hz.

  • x_range – The minimum and maximum time values at which to sample the waveforms.

Returns

Dictionary that maps each used port to the sampled pulses played on that port.

deduplicate_legend_handles_labels(ax: matplotlib.axes.Axes) None[source]#

Remove duplicate legend entries.

See also: https://stackoverflow.com/a/13589144

plot_single_subplot_mpl(sampled_schedule: Dict[str, List[SampledPulse]], ax: Optional[matplotlib.axes.Axes] = None) Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes][source]#

Plot all pulses for all ports in the schedule in the same subplot.

Pulses in the same port have the same color and legend entry, and each port has its own legend entry.

Parameters
  • sampled_schedule – Dictionary that maps each used port to the sampled pulses played on that port.

  • ax – A pre-existing Axes object to plot the pulses in. If None (default), this object is created within the function.

Returns

  • fig – A matplotlib matplotlib.figure.Figure containing the subplot.

  • ax – The Axes of the subplot belonging to the Figure.

plot_multiple_subplots_mpl(sampled_schedule: Dict[str, List[SampledPulse]]) Tuple[matplotlib.figure.Figure, List[matplotlib.axes.Axes]][source]#

Plot pulses in a different subplot for each port in the sampled schedule.

For each subplot, each different type of pulse gets its own color and legend entry.

Parameters

sampled_schedule – Dictionary that maps each used port to the sampled pulses played on that port.

Returns

  • fig – A matplotlib matplotlib.figure.Figure containing the subplots.

  • axs – An array of Axes objects belonging to the Figure.

pulse_diagram_matplotlib(schedule: quantify_scheduler.Schedule | quantify_scheduler.CompiledSchedule, port_list: Optional[List[str]] = None, sampling_rate: float = 1000000000.0, modulation: Literal[off, if, clock] = 'off', modulation_if: float = 0.0, x_range: Tuple[float, float] = (-np.inf, np.inf), multiple_subplots: bool = False, ax: Optional[matplotlib.axes.Axes] = None) Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes | List[matplotlib.axes.Axes]][source]#

Plots a schedule using matplotlib.

Parameters
  • schedule – The schedule to plot.

  • port_list – A list of ports to show. If None (default) the first 8 ports encountered in the sequence are used.

  • sampling_rate – The time resolution used to sample the schedule in Hz. By default 1e9.

  • modulation – Determines if modulation is included in the visualization. By default “off”.

  • modulation_if – Modulation frequency used when modulation is set to “if”. By default 0.0.

  • x_range – The range of the x-axis that is plotted, given as a tuple (left limit, right limit). This can be used to reduce memory usage when plotting a small section of a long pulse sequence. By default (-np.inf, np.inf).

  • multiple_subplots – Plot the pulses for each port on a different subplot if True, else plot everything in one subplot. By default False. When using just one subplot, the pulses are colored according to the port on which they play. For multiple subplots, each pulse has its own color and legend entry.

  • ax – Axis onto which to plot. If None, this is created within the function. By default None.

Returns

  • fig – A matplotlib matplotlib.figure.Figure containing the subplot(s).

  • ax – The Axes object belonging to the Figure, or an array of Axes if multiple_subplots=True.

get_window_operations(schedule: quantify_scheduler.Schedule) List[Tuple[float, float, quantify_scheduler.Operation]][source]#

Return a list of all WindowOperations with start and end time.

Parameters

schedule – Schedule to use.

Returns

List of all window operations in the schedule.

plot_window_operations(schedule: quantify_scheduler.Schedule, ax: Optional[matplotlib.axes.Axes] = None, time_scale_factor: float = 1) Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes][source]#

Plot the window operations in a schedule.

Parameters
  • schedule – Schedule from which to plot window operations.

  • ax – Axis handle to use for plotting.

  • time_scale_factor – Used to scale the independent data before using as data for the x-axis of the plot.

Returns

  • fig – The matplotlib figure.

  • ax – The matplotlib ax.

plot_acquisition_operations(schedule: quantify_scheduler.Schedule, ax: Optional[matplotlib.axes.Axes] = None, **kwargs) List[Any][source]#

Plot the acquisition operations in a schedule.

Parameters
  • schedule – Schedule from which to plot window operations.

  • ax – Axis handle to use for plotting.

  • kwargs – Passed to matplotlib plotting routine

Returns

List of handles