pulse_diagram#

Functions for drawing pulse diagrams.

Module Contents#

Classes#

SampledPulse

Class containing the necessary information to display pulses in a plot.

SampledAcquisition

Class containing the necessary information to display acquisitions in a plot.

ScheduledInfo

Class containing pulse or acquisition info, with some additional information.

Functions#

get_sampled_pulses_from_voltage_offsets(→ dict[str, ...)

Generate SampledPulse objects from VoltageOffset pulse_info dicts.

get_sampled_pulses(→ dict[str, list[SampledPulse]])

Generate SampledPulse objects from pulse_info dicts.

get_sampled_acquisitions(→ dict[str, ...)

Generate SampledAcquisition objects from acquisition_info dicts.

merge_pulses_and_offsets(→ SampledPulse)

Combine multiple SampledPulse objects by interpolating the signal at the

sample_schedule(, combine_waveforms_on_same_port, ...)

Generate SampledPulse and SampledAcquisition objects grouped by

pulse_diagram_plotly(→ plotly.graph_objects.Figure)

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

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(...)

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[source]#
class SampledPulse[source]#

Class containing the necessary information to display pulses in a plot.

time: numpy.ndarray[source]#
signal: numpy.ndarray[source]#
label: str[source]#
class SampledAcquisition[source]#

Class containing the necessary information to display acquisitions in a plot.

t0: float[source]#
duration: float[source]#
label: str[source]#
class ScheduledInfo[source]#

Class containing pulse or acquisition info, with some additional information.

This class is used in the schedule sampling process to temporarily hold pulse info or acquisition info dictionaries, together with some useful information from the operation and schedulable that they are a part of.

op_info: dict[str, Any][source]#

Pulse info or acquisition info.

time: float[source]#

The sum of the Schedulable["abs_time"] and the info["t0"].

op_name: str[source]#

The name of the operation containing the pulse or acquisition info.

get_sampled_pulses_from_voltage_offsets(schedule: quantify_scheduler.Schedule | quantify_scheduler.CompiledSchedule, offset_infos: dict[str, dict[str, list[ScheduledInfo]]], x_min: float, x_max: float, modulation: Literal['off', 'if', 'clock'] = 'off', modulation_if: float = 0.0, sampling_rate: float = 1000000000.0, sampled_pulses: dict[str, list[SampledPulse]] | None = None) dict[str, list[SampledPulse]][source]#

Generate SampledPulse objects from VoltageOffset pulse_info dicts.

This function groups all VoltageOffset operations by port-clock combination and turns each of those groups of operations into a single SampledPulse. The returned dictionary contains these SampledPulse objects grouped by port.

Parameters:
  • schedule – The schedule to render.

  • offset_infos – A nested dictionary containing lists of pulse_info dictionaries. The outer dictionary’s keys are ports, and the inner dictionary’s keys are clocks.

  • x_min – The left limit of the x-axis of the intended plot.

  • x_max – The right limit of the x-axis of the intended plot.

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

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

  • sampling_rate – Number of samples per second to draw when drawing modulated pulses.

  • sampled_pulses – An already existing dictionary (same type as the return value). If provided, this dictionary will be extended with the SampledPulse objects created in this function.

Returns:

SampledPulse objects grouped by port.

Return type:

dict[str, list[SampledPulse]]

get_sampled_pulses(schedule: quantify_scheduler.Schedule | quantify_scheduler.CompiledSchedule, pulse_infos: dict[str, list[ScheduledInfo]], x_min: float, x_max: float, modulation: Literal['off', 'if', 'clock'] = 'off', modulation_if: float = 0.0, sampling_rate: float = 1000000000.0, sampled_pulses: dict[str, list[SampledPulse]] | None = None) dict[str, list[SampledPulse]][source]#

Generate SampledPulse objects from pulse_info dicts.

This function creates a SampledPulse for each pulse_info dict. The pulse_info must contain a valid "wf_func".

Parameters:
  • schedule – The schedule to render.

  • pulse_infos – A dictionary from ports to lists of pulse_info dictionaries.

  • x_min – The left limit of the x-axis of the intended plot.

  • x_max – The right limit of the x-axis of the intended plot.

  • 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.

  • sampled_pulses – An already existing dictionary (same type as the return value). If provided, this dictionary will be extended with the SampledPulse objects created in this function.

Returns:

SampledPulse objects grouped by port.

Return type:

dict[str, list[SampledPulse]]

get_sampled_acquisitions(acq_infos: dict[str, list[ScheduledInfo]]) dict[str, list[SampledAcquisition]][source]#

Generate SampledAcquisition objects from acquisition_info dicts.

Parameters:

acq_infos – A dictionary from ports to lists of acquisition_info dictionaries.

Returns:

SampledAcquisition objects grouped by port.

Return type:

dict[str, list[SampledAcquisition]]

merge_pulses_and_offsets(operations: list[SampledPulse]) SampledPulse[source]#

Combine multiple SampledPulse objects by interpolating the signal at the time points used by all pulses together, and then summing the result. Interpolation outside of a SampledPulse.time array results in 0 for that pulse.

sample_schedule(schedule: quantify_scheduler.Schedule | quantify_scheduler.CompiledSchedule, port_list: list[str] | None = 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), combine_waveforms_on_same_port: bool = False) dict[str, tuple[list[SampledPulse], list[SampledAcquisition]]][source]#

Generate SampledPulse and SampledAcquisition objects grouped by port.

This function generates SampledPulse objects for all pulses and voltage offsets defined in the Schedule, and SampledAcquisition for all acquisitions defined in the Schedule.

Parameters:
  • schedule – The schedule to render.

  • port_list – A list of ports to show. if set to None (default), it will use all ports in the Schedule.

  • 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 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).

  • combine_waveforms_on_same_port – By default False. If True, combines all waveforms on the same port into one single waveform. The resulting waveform is the sum of all waveforms on that port (small inaccuracies may occur due to floating point approximation). If False, the waveforms are shown individually.

Returns:

SampledPulse and SampledAcquisition objects grouped by port.

Return type:

dict[str, tuple[list[SampledPulse], list[SampledAcquisition]]]

pulse_diagram_plotly(sampled_pulses_and_acqs: dict[str, tuple[list[SampledPulse], list[SampledAcquisition]]], title: str = 'Pulse diagram', fig_ch_height: float = 300, fig_width: float = 1000) plotly.graph_objects.Figure[source]#

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

Parameters:
  • sampled_pulses_and_acqs – SampledPulse and SampledAcquisition objects grouped by port.

  • title – Plot title.

  • fig_ch_height – Height for each channel subplot in px.

  • fig_width – Width for the figure in px.

Returns:

the plot

Return type:

plotly.graph_objects.Figure

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: matplotlib.axes.Axes | None = None, title: str = 'Pulse diagram') 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.

  • title – Plot title.

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]], title: str = 'Pulse diagram') 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.

  • title – Plot title.

Returns:

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

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

pulse_diagram_matplotlib(sampled_pulses_and_acqs: dict[str, tuple[list[SampledPulse], list[SampledAcquisition]]], multiple_subplots: bool = False, ax: matplotlib.axes.Axes | None = None, title: str = 'Pulse diagram') tuple[matplotlib.figure.Figure, matplotlib.axes.Axes | list[matplotlib.axes.Axes]][source]#

Plots a schedule using matplotlib.

Parameters:
  • sampled_pulses_and_acqs – SampledPulse and SampledAcquisition objects grouped by port.

  • 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 (default), this is created within the function. By default None.

  • title – Plot title.

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: matplotlib.axes.Axes | None = 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: matplotlib.axes.Axes | None = 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