3.6.10. qupulse.pulses.plotting¶
This module defines plotting functionality for instantiated PulseTemplates using matplotlib.
- Classes:
PlottingNotPossibleException.
- Functions:
plot: Plot a pulse using matplotlib.
-
qupulse.pulses.plotting.
render
(program, sample_rate=10.0, render_measurements=False, time_slice=None, plot_channels=None)[source]¶ ‘Renders’ a pulse program.
Samples all contained waveforms into an array according to the control flow of the program.
- Parameters
program (
Loop
) – The pulse (sub)program to render. Can be represented either by a Loop object or the more old-fashioned InstructionBlock.sample_rate (
Real
) – The sample rate in GHz.render_measurements (
bool
) – If True, the third return value is a list of measurement windows.time_slice (
Optional
[Tuple
[Real
,Real
]]) – The time slice to be rendered. If None, the entire pulse will be shown.plot_channels (
Optional
[Set
[Union
[str
,int
]]]) – Only channels in this set are rendered. If None, all will.
- Return type
Tuple
[ndarray
,Dict
[Union
[str
,int
],ndarray
],List
[Tuple
[str
,Real
,Real
]]]- 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).
-
qupulse.pulses.plotting.
plot
(pulse, parameters=None, sample_rate=10, axes=None, show=True, plot_channels=None, plot_measurements=None, stepped=True, maximum_points=1000000, time_slice=None, **kwargs)[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 (
PulseTemplate
) – The pulse to be plotted.parameters (
Optional
[Dict
[str
,Parameter
]]) – An optional mapping of parameter names to Parameter objects.sample_rate (
Real
) – The rate with which the waveforms are sampled for the plot in samples per time unit. (default = 10)axes (
Optional
[Any
]) – matplotlib Axes object the pulse will be drawn into if providedshow (
bool
) – If true, the figure will be shownplot_channels (
Optional
[Set
[Union
[str
,int
]]]) – If specified only channels from this set will be plotted. If omitted all channels will be.stepped (
bool
) – If true pyplot.step is used for plottingplot_measurements (
Optional
[Set
[str
]]) – If specified measurements in this set will be plotted. If omitted no measurements will be.maximum_points (
int
) – If the sampled waveform is bigger, it is not plottedtime_slice (
Optional
[Tuple
[Real
,Real
]]) – The time slice to be plotted. If None, the entire pulse will be shown.kwargs – Forwarded to pyplot. Overwrites other settings.
- Return type
- 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 –