Skip to content

laboneq_applications.analysis.calibration_traces_rotation

This module contains functions for rotating raw experiment data.

The raw data needs to be translated into qubit populations. This is done either by using principal-component analysis or rotating and projecting the data along the line in the complex plane given by data obtained from calibration traces. The latter is obtained by measuring the qubit after preparing it in a known state, for instance g, e, or f.

calculate_population_1d(raw_data, sweep_points, calibration_traces=None, *, do_pca=False)

Rotate and project 1D data.

The data is projected along the line between the points in the calibration traces.

Parameters:

Name Type Description Default
raw_data ArrayLike

array of complex data corresponding to the results of an integrated average result, usually of dimension (nr_sweep_points, 1).

required
sweep_points ArrayLike

Sweep points of the acquisition.

required
calibration_traces list[ArrayLike | complex] | None

A list with two entries of the complex data corresponding to the calibration traces, from the lowest transmon state to the highest.

None
do_pca bool

whether to do principal component analysis on the data. If False, the data will be rotated along the line in the complex plane between the two calibration points and then projected onto it.

False

Returns:

Type Description
dict

dictionary with the following data: sweep_points, sweep_points extended with as many points as there are cal traces, the artificially added sweep_points for the cal traces, raw data, raw data with calibration traces appended, raw data of the calibration traces, rotated data, rotated data with the rotated calibration traces appended, rotated calibration traces data

calculate_qubit_population(qubits, result, sweep_points, options=None)

Calculates the qubit population from the raw data.

The data is processed in the following way:

  • If calibration traces were used in the experiment, the raw data is rotated based on the calibration traces. See [calibration_traces_rotation.py/rotate_data_to_cal_trace_results] for more details.
  • If no calibration traces were used in the experiment, or do_pca = True is passed in options, principal-component analysis is performed on the data. See [calibration_traces_rotation.py/principal_component_analysis] for more details.

Parameters:

Name Type Description Default
qubits Qubits

The qubits on which the amplitude-Rabi experiments was run. May be either a single qubit or a list of qubits.

required
result RunExperimentResults

the result of the experiment, returned by the run_experiment task.

required
sweep_points QubitSweepPoints

The sweep points used in the experiment for each qubit. If qubits is a single qubit, sweep_points must be an array. Otherwise, it must be a list of arrays.

required
options TuneupAnalysisOptions | None

The options for building the workflow as an instance of [TuneupAnalysisOptions]. See the docstrings of this class for more details.

None

Returns:

Type Description
dict[str, dict[str, ArrayLike]]

dict with qubit UIDs as keys and the dictionary of processed data for each qubit

dict[str, dict[str, ArrayLike]]

as values. See [calibration_traces_rotation.py/calculate_population_1d] for what

dict[str, dict[str, ArrayLike]]

this dictionary looks like.

Raises:

Type Description
TypeError

If result is not an instance of RunExperimentResults.

ValueError

If the conditions in validate_and_convert_qubits_sweeps are not met.

calculate_rotation_matrix(delta_i, delta_q)

Calculates the matrix that rotates the data to lie along the Q-axis.

Input can be either the I and Q coordinates of the zero cal_point or the difference between the 1 and 0 cal points.

Parameters:

Name Type Description Default
delta_i float | ArrayLike

difference between the real parts of the first and second cal-state data, usually of dimension (nr_sweep_points, 1).

required
delta_q float | ArrayLike

difference between the imaginary parts of the first and second cal-state data, usually of dimension (nr_sweep_points, 1).

required

Returns:

Type Description
NDArray[float64]

the 2x2 rotation matrix as a numpy array

principal_component_analysis(raw_data)

Rotates and projects 1D data using principal component analysis (PCA).

Parameters:

Name Type Description Default
raw_data ArrayLike

Array of complex data corresponding to the results of an integrated average result, usually of dimension (nr_sweep_points, 1).

required

Returns:

Type Description
ArrayLike

data array after PCA with the same dimension as raw_data.

rotate_data_to_cal_trace_results(raw_data, raw_data_cal_pt_0, raw_data_cal_pt_1)

Rotates and projects the raw data.

The raw data is projected onto the line in the IQ plane between two calibration points, then normalised to the distance in the IQ plane between the two calibration points. The calibration points are the results of preparing two transmon states.

If more than one calibration point per state (i.e. len(raw_data_cal_pt_0) > 1), the mean of the cal points will be taken.

Parameters:

Name Type Description Default
raw_data ArrayLike

array of complex data corresponding to the results of an integrated average result, usually of dimension (nr_sweep_points, 1).

required
raw_data_cal_pt_0 ArrayLike | complex

array of complex data or a single complex number corresponding to the data recorded when the qubit is prepared in the first calibration state. "First" here means the lowest transmon state. For example, g if the cal traces measured were g and e or g and f; e if the cal traces measured were e an f

required
raw_data_cal_pt_1 ArrayLike | complex

array of complex data or a single complex number corresponding to the data recorded when the qubit is prepared in the second calibration state. "Second" here means the highest transmon state. For example, e if the cal traces measured were g and e; f if the cal traces measured were g and f or e an f

required

Returns:

Type Description
ArrayLike

rotated, projected, and normalised real-data array with the same dimension as

ArrayLike

raw_data.