laboneq_applications.analysis.plotting_helpers
¶
This module contains helper function for experiment analyses.
PlotRawDataOptions
¶
Bases: TaskOptions
Options for the plot_raw_complex_data_1d task.
Attributes:
Name | Type | Description |
---|---|---|
use_cal_traces |
bool
|
Whether to plot the calibration traces.
Note that in the case of 2D data, the calibration traces are included
in the 2D plot together with the main data. To achieve this, the
1D sweep points are extended by num_cal_traces * [sp_1d[-2] - sp_1d[-1]].
Default: |
cal_states |
str | tuple
|
The states to prepare in the calibration traces. Can be any string or tuple made from combining the characters 'g', 'e', 'f'. Default: same as transition |
figure_size_raw_data |
Sequence | None
|
The size of the figure. |
save_figures |
bool
|
Whether to save the figures.
Default: |
close_figures |
bool
|
Whether to close the figures.
Default: |
cal_states: str | tuple = workflow.option_field('ge', description="The states to prepare in the calibration traces.Can be any string or tuple made from combining the characters 'g', 'e', 'f'.")
class-attribute
instance-attribute
¶
close_figures: bool = workflow.option_field(True, description='Whether to close the figures.')
class-attribute
instance-attribute
¶
figure_size_raw_data: Sequence | None = workflow.option_field(None, description='The size of the figure.')
class-attribute
instance-attribute
¶
save_figures: bool = workflow.option_field(True, description='Whether to save the figures.')
class-attribute
instance-attribute
¶
use_cal_traces: bool = workflow.option_field(True, description='Whether to include calibration traces in the experiment.')
class-attribute
instance-attribute
¶
PlotSignalMagnitudeAndPhase2DOptions
¶
Options for the plot_signal_magnitude_and_phase_2d task.
Attributes:
Name | Type | Description |
---|---|---|
figure_size_magnitude_phase |
Sequence | None
|
The size of the figure. |
figure_size_magnitude_phase: Sequence | None = workflow.option_field(None, description='The size of the figure.')
class-attribute
instance-attribute
¶
plot_data_2d(x_values, y_values, z_values, label_x_values='', label_y_values='', label_z_values='', scaling_x_values=1.0, scaling_y_values=1.0, fit_x_values=None, fit_y_values=None, plot_title='', figure_name='2D_Data', save_figures=False, close_figures=True, figure=None, axis=None)
¶
Create a 2D plot using pcolormesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_values |
ArrayLike
|
The 1D array to plot on the x-axis. |
required |
y_values |
ArrayLike
|
The 1D array to plot on the y-axis. |
required |
z_values |
ndarray
|
The 2D array to plot on the z-axis. The shape of z_values must be (len(y_values), len(x_values)). |
required |
label_x_values |
str
|
The label that will appear on the x-axis. Default: "" |
''
|
label_y_values |
str
|
The label that will appear on the y-axis. Default: "" |
''
|
label_z_values |
str
|
The label that will appear on the colour bar of the z-axis. Default: "" |
''
|
scaling_x_values |
float
|
The scaling factor of the x-values. Default: 1.0. |
1.0
|
scaling_y_values |
float
|
The scaling factor of the y-values. Default: 1.0. |
1.0
|
fit_x_values |
ArrayLike | None
|
The 1D array with the fit points to plot on the x-axis. Default: None. |
None
|
fit_y_values |
ArrayLike | None
|
The 1D array with the fit points to plot on the y-axis. Default: None. |
None
|
plot_title |
str
|
The plot title. Default: "" |
''
|
figure_name |
str
|
The figure name. Default: "2D_Data". |
'2D_Data'
|
save_figures |
bool
|
Whether to save the figures.
Default: |
False
|
close_figures |
bool
|
Whether to close the figures.
Default: |
True
|
figure |
Figure
|
The matplotlib figure on which to plot. Default: None. |
None
|
axis |
Axes
|
The matplotlib axis on which to plot. Default: None. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the x_values is not a 1D array. |
ValueError
|
If the y_values is not a 1D array. |
ValueError
|
If the z_values is not a 2D array. |
ValueError
|
If the z_values does not have the shape (len(y_values), len(x_values)). |
Returns:
Type | Description |
---|---|
tuple[Figure, Axes]
|
The matplotlib figure and axis. |
plot_raw_complex_data_1d(qubits, result, sweep_points, xlabel, xscaling=1.0, options=None)
¶
Creates plots of raw complex data acquired in integration mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubits |
QuantumElements
|
The qubits on which to run this task. May be either a single qubit or a list of qubits. |
required |
result |
RunExperimentResults | Results
|
the result of the experiment. Can be either an instance of
|
required |
sweep_points |
QubitSweepPoints
|
The sweep points used in the experiment for each qubit.
If |
required |
xlabel |
str
|
x-axis label |
required |
xscaling |
float
|
value by which to scale the sweep_points |
1.0
|
options |
PlotRawDataOptions | None
|
The options for processing the raw data as an instance of [PlotRawDataOptions]. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Figure]
|
dict with qubit UIDs as keys and the figures for each qubit as keys. |
plot_raw_complex_data_2d(qubits, result, sweep_points_1d, sweep_points_2d, label_sweep_points_1d, label_sweep_points_2d, scaling_sweep_points_1d=1.0, scaling_sweep_points_2d=1.0, options=None)
¶
Creates plots of two-dimensional raw complex data acquired in integration mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubits |
QuantumElements
|
The qubits on which to run this task. May be either a single qubit or a list of qubits. |
required |
result |
RunExperimentResults | Results
|
the result of the experiment. Can be either an instance of
|
required |
sweep_points_1d |
QubitSweepPoints
|
The sweep points corresponding to the innermost sweep.
If |
required |
sweep_points_2d |
QubitSweepPoints
|
The sweep points corresponding to the outermost sweep.
If |
required |
label_sweep_points_1d |
str
|
The label that will appear on the axis of the 1D sweep points.
Passed to the |
required |
label_sweep_points_2d |
str
|
The label that will appear on the axis of the 2D sweep points.
Passed to the |
required |
scaling_sweep_points_1d |
float
|
The scaling factor of the 1D sweep points.
Passed to the |
1.0
|
scaling_sweep_points_2d |
float
|
The scaling factor of the 2D sweep points.
Passed to the |
1.0
|
options |
PlotRawDataOptions | None
|
The options for this task as an instance of [PlotRawDataOptions]. See the docstring of this class for more details. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Figure]
|
dict with qubit UIDs as keys and the figures for each qubit as keys. |
plot_signal_magnitude_and_phase_2d(qubits, result, sweep_points_1d, sweep_points_2d, label_sweep_points_1d, label_sweep_points_2d, scaling_sweep_points_1d=1.0, scaling_sweep_points_2d=1.0, options=None)
¶
Create the qubit-spectroscopy plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubits |
QuantumElements
|
The qubits on which to run this task. May be either a single qubit or a list of qubits. |
required |
result |
RunExperimentResults | Results
|
the result of the experiment. Can be either an instance of
|
required |
sweep_points_1d |
QubitSweepPoints
|
The sweep points corresponding to the innermost sweep.
If |
required |
sweep_points_2d |
QubitSweepPoints
|
The sweep points corresponding to the outermost sweep.
If |
required |
label_sweep_points_1d |
str
|
The label that will appear on the axis of the 1D sweep points.
Passed to the |
required |
label_sweep_points_2d |
str
|
The label that will appear on the axis of the 2D sweep points.
Passed to the |
required |
scaling_sweep_points_1d |
float
|
The scaling factor of the 1D sweep points.
Passed to the |
1.0
|
scaling_sweep_points_2d |
float
|
The scaling factor of the 2D sweep points.
Passed to the |
1.0
|
options |
PlotSignalMagnitudeAndPhase2DOptions | None
|
The options for this task as an instance of [PlotSignalMagnitudeAndPhase2DOptions]. See the docstring of this class for more details. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Figure]
|
dict with qubit UIDs as keys and the figures for each qubit as values. |
sorted_mesh(x_values, y_values, z_values)
¶
Prepare the x, y, z arrays to be plotted with matplotlib pcolormesh.
Ensures that the z values are sorted according to the values in x_values and y_values and creates np.meshgrid from x_values and y_values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_values |
ArrayLike
|
array of the values to be plotted on the x-axis: typically the real-time sweep points. |
required |
y_values |
ArrayLike
|
array of the values to be plotted on the y-axis: typically the near-time sweep points. |
required |
z_values |
ArrayLike
|
array of the values to be plotted on the z-axis: typically the data. |
required |
Returns:
Type | Description |
---|---|
tuple[ArrayLike, ArrayLike, ArrayLike]
|
the x, y, and z values to be passed directly to pcolormesh. |
timestamped_title(title, dt=None)
¶
Return a plot title with a timestamp in the local timezone.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The title of the plot without a timestamp. |
required |
dt |
datetime | None
|
The time to use to create the timestamp. If None, the workflow start time is used. If there is no active workflow, the current time is used. |
None
|
Note
The timestamp is generated using the function local_timestamp
and thus has the same format as the timestamps used by the
FolderStore
in the logbook folders it creates.
Returns:
Type | Description |
---|---|
str
|
The title with a timestamp, formatted as "TIMESTAMP - TITLE". |