3.5. qupulse.plotting

This module defines plotting functionality for instantiated PulseTemplates using matplotlib.

Classes:
  • PlottingNotPossibleException.

Functions:
  • plot: Plot a pulse using matplotlib.

Functions

_(pulse_template, channels[, sample_rate, ...])

_render_loop(loop, render_measurements)

Transform program into single waveform and measurement windows.

plot(pulse[, parameters, sample_rate, axes, ...])

Plots a pulse using matplotlib.

plot_2d(program, channels[, sample_rate, ...])

Plot the pulse/program in the plane of the given channels.

render(program[, sample_rate, ...])

'Renders' a pulse program.

Exceptions

PlottingNotPossibleException(pulse[, ...])

Indicates that plotting is not possible because the sequencing process did not translate the entire given PulseTemplate structure.

exception qupulse.plotting.PlottingNotPossibleException(pulse, description=None)[source]

Bases: Exception

Indicates that plotting is not possible because the sequencing process did not translate the entire given PulseTemplate structure.

qupulse.plotting.plot(pulse: qupulse.pulses.pulse_template.PulseTemplate, parameters: Optional[Dict[str, numbers.Real]] = None, sample_rate: Optional[numbers.Real] = 10, axes: Optional[Any] = None, show: bool = True, plot_channels: Optional[Set[Union[str, int]]] = None, plot_measurements: Optional[Set[str]] = None, stepped: bool = True, maximum_points: int = 1000000, time_slice: Optional[Tuple[numbers.Real, numbers.Real]] = None, **kwargs) Any[source]

Plots a pulse using matplotlib.

The given pulse template will first be turned into a pulse program (represented by a Loop object) with the provided parameters. The render() function is then invoked to obtain voltage samples over the entire duration of the pulse which are then plotted in a matplotlib figure.

Parameters
  • pulse – The pulse to be plotted.

  • parameters – An optional mapping of parameter names to Parameter objects.

  • sample_rate – The rate with which the waveforms are sampled for the plot in samples per time unit. If None, then automatically determine the sample rate (default = 10)

  • axes – matplotlib Axes object the pulse will be drawn into if provided

  • show – If true, the figure will be shown

  • plot_channels – If specified only channels from this set will be plotted. If omitted all channels will be.

  • stepped – If true pyplot.step is used for plotting

  • plot_measurements – If specified measurements in this set will be plotted. If omitted no measurements will be.

  • maximum_points – If the sampled waveform is bigger, it is not plotted

  • time_slice – The time slice to be plotted. If None, the entire pulse will be shown.

  • kwargs – Forwarded to pyplot. Overwrites other settings.

Returns

matplotlib.pyplot.Figure instance in which the pulse is rendered

Raises
  • PlottingNotPossibleException if the sequencing is interrupted before it finishes, e.g., – because a parameter value could not be evaluated

  • all Exceptions possibly raised during sequencing

qupulse.plotting.render(program: qupulse.program.loop.Loop, sample_rate: numbers.Real = 10.0, render_measurements: bool = False, time_slice: Optional[Tuple[numbers.Real, numbers.Real]] = None, plot_channels: Optional[Set[Union[str, int]]] = None) Tuple[numpy.ndarray, Dict[Union[str, int], numpy.ndarray], List[Tuple[str, numbers.Real, numbers.Real]]][source]

‘Renders’ a pulse program.

Samples all contained waveforms into an array according to the control flow of the program.

Parameters
  • program – The pulse (sub)program to render. Can be represented either by a Loop object or the more old-fashioned InstructionBlock.

  • sample_rate – The sample rate in GHz.

  • render_measurements – If True, the third return value is a list of measurement windows.

  • time_slice – The time slice to be rendered. If None, the entire pulse will be shown.

  • plot_channels – Only channels in this set are rendered. If None, all will.

Returns

A tuple (times, values, measurements). times is a numpy.ndarray of dimensions sample_count where containing the time values. voltages is a dictionary of one numpy.ndarray of dimensions sample_count per defined channel containing corresponding sampled voltage values for that channel. measurements is a sequence of all measurements where each measurement is represented by a tuple (name, start_time, duration).