Skip to content

laboneq_applications.analysis.qubit_spectroscopy

This module defines the analysis for a qubit-spectroscopy experiment.

The experiment is defined in laboneq_applications.experiments.

In this analysis, we first interpret the raw data into the signal magnitude and phase. Then we fit a Lorentzian model to the signal magnitude and extract the frequency corresponding to the peak of the Lorentzian from the fit. This is the new qubit frequency. Finally, we plot the data and the fit.

FitDataQubitSpecOptions

Options for the fit_data task of the qubit spectroscopy analysis.

Attributes:

Name Type Description
frequency_filters dict[str, tuple[float | None]] | None

Information on how to filter the first-dimensional sweep points (the frequency) for each qubit before performing the Lorentzian fit; for example, to fit the data only in the range f < 6.8 GHz. See the description in the options field for more details.

spectral_feature Literal['peak', 'dip', 'auto']

Whether to perform the fit assuming the Lorentzian is pointing upwards ("peak") or downwards ("dip"). By default, this parameter is "auto", in which case, the lorentzian_fit routine in fitting_helpers.py tries to work out the orientation of the Lorentzian feature. Default: None

fit_parameters_hints dict | None

Parameters hints accepted by lmfit Default: None.

do_fitting

Whether to perform the fit. Default: True.

PlotQubitSpectroscopyOptions

Bases: ExtractQubitParametersTransitionOptions, BasePlottingOptions

Options for the plot_qubit_spectroscopy task of the qubit spec. analysis.

Attributes:

Name Type Description
transition Literal['ge', 'ef']

Transition to perform the experiment on. Default: "ge".

do_fitting bool

Whether to perform the fit. Default: True.

save_figures bool

Whether to save the figures. Default: True.

close_figures bool

Whether to close the figures. Default: True.

QubitSpectroscopyAnalysisWorkflowOptions

Option class for qubit spectroscopy analysis workflows.

Attributes:

Name Type Description
do_plotting bool

Whether to make plots. Default: 'True'.

do_raw_data_plotting bool

Whether to plot the raw data. Default: True.

do_plotting_qubit_spectroscopy bool

Whether to plot the final qubit spectroscopy plot. Default: True.

analysis_workflow(result, qubits, frequencies, options=None)

The Qubit Spectroscopy analysis Workflow.

The workflow consists of the following steps:

Parameters:

Name Type Description Default
result RunExperimentResults

The experiment results returned by the run_experiment task.

required
qubits QuantumElements

The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the result.

required
frequencies QubitSweepPoints

The array of frequencies that were swept over in the experiment. If qubits is a single qubit, frequencies must be a list of numbers or an array. Otherwise, it must be a list of lists of numbers or arrays.

required
options QubitSpectroscopyAnalysisWorkflowOptions | None

The options for building the workflow, passed as an instance of QubitSpectroscopyAnalysisWorkflowOptions. In addition to options from WorkflowOptions, the following custom options are supported: do_plotting, do_raw_data_plotting, do_plotting_qubit_spectroscopy and the options of the QubitSpectroscopyAnalysisWorkflowOptions class. See the docstring of QubitSpectroscopyAnalysisWorkflowOptions for more details.

None

Returns:

Name Type Description
WorkflowBuilder None

The builder for the analysis workflow.

Example
analysis_result = analysis_workflow(
    result=result,
    qubits=[q0, q1],
    frequencies=[np.linspace(6.0, 6.3, 301), np.linspace(5.8, 6.1, 301)],
).run()

calculate_signal_magnitude_and_phase(qubits, result, frequencies)

Calculates the magnitude and phase of the spectroscopy signal in result.

Parameters:

Name Type Description Default
result RunExperimentResults

The experiment results returned by the run_experiment task.

required
qubits QuantumElements

The qubits on which to run the task. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the result.

required
frequencies ArrayLike

The array of frequencies that were swept over in the experiment.

required

Returns:

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

A dictionary with the qubit UIDs as keys and a processed data dict as values, containing the following keys:

  • sweep_points
  • data_raw
  • magnitude
  • phase

extract_qubit_parameters(qubits, fit_results, options=None)

Extract the qubit parameters from the fit results.

Parameters:

Name Type Description Default
qubits QuantumElements

The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the processed_data_dict.

required
fit_results dict[str, ModelResult] | None

the fit-results dictionary returned by fit_data

required
options ExtractQubitParametersTransitionOptions | None

The options for this task as an instance of ExtractQubitParametersTransitionOptions. See the docstring of this class for more details.

None

Returns:

Type Description
dict[str, dict[str, dict[str, int | float | Variable | None]]]

dict with extracted qubit parameters and the previous values for those qubit parameters. The dictionary has the following form:

{
    "new_parameter_values": {
        q.uid: {qb_param_name: qb_param_value},
    },
    "old_parameter_values": {
        q.uid: {qb_param_name: qb_param_value},
    },
}

If the do_fitting option is False, the new_parameter_values are not extracted and the function only returns the old_parameter_values. If a qubit uid is not found in fit_results, the new_parameter_values entry for that qubit is left empty.

fit_data(qubits, processed_data_dict, options=None)

Perform a fit of a Lorentzian model to the data.

Parameters:

Name Type Description Default
qubits QuantumElements

The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the processed_data_dict.

required
processed_data_dict dict[str, dict[str, ArrayLike]]

the processed data dictionary returned by calculate_signal_magnitude_and_phase

required
options FitDataQubitSpecOptions | None

The options class for this task as an instance of FitDataQubitSpecOptions. See the docstring of this class for accepted options.

None

Returns:

Type Description
dict[str, ModelResult] | None

dict with qubit UIDs as keys and the fit results for each qubit as keys.

plot_qubit_spectroscopy(qubits, processed_data_dict, fit_results, qubit_parameters, options=None)

Create the qubit-spectroscopy plots.

Parameters:

Name Type Description Default
qubits QuantumElements

The qubits on which to run the analysis. May be either a single qubit or a list of qubits. The UIDs of these qubits must exist in the processed_data_dict and qubit_parameters.

required
processed_data_dict dict[str, dict[str, ArrayLike]]

the processed data dictionary returned by calculate_signal_magnitude_and_phase.

required
fit_results dict[str, ModelResult] | None

the fit-results dictionary returned by fit_data

required
qubit_parameters dict[str, dict[str, dict[str, int | float | Variable | None]]]

the qubit-parameters dictionary returned by extract_qubit_parameters

required
options PlotQubitSpectroscopyOptions | None

The options for this task as an instance of PlotQubitSpectroscopyOptions. 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.