Skip to content

laboneq_applications.analysis.resonator_spectroscopy

This module defines the analysis for a resonator-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 either extract the frequency corresponding to the min or max of the magnitude data, or we fit a Lorentzian model to the signal magnitude and extract frequency corresponding to the peak of the Lorentzian from the fit. Finally, we plot the data and the fit.

ExtractQubitParametersResSpecOptions

Options for the extract_qubit_parameters task of the resonator spec. analysis.

Attributes:

Name Type Description
find_peaks bool

Whether to search for peaks (True) or dips (False) in the spectrum. Default: False.

FitDataResSpecOptions

Options for the fit_data task of the resonator spectroscopy analysis.

Attributes:

Name Type Description
fit_lorentzian bool

Whether to fit a Lorentzian model to the data. Default: False.

fit_parameters_hints dict[str, dict[str, float | bool | str]] | None

Parameters hints accepted by lmfit Default: None.

PlotMagnitudePhaseOptions

Options for the plot_magnitude_phase task of the resonator spec. analysis.

Attributes:

Name Type Description
fit_lorentzian bool

Whether to fit a Lorentzian model to the data. Default: False.

find_peaks bool

Whether to search for peaks (True) or dips (False) in the spectrum. Default: False.

save_figures

Whether to save the figures. Default: True.

close_figures

Whether to close the figures. Default: True.

ResonatorSpectroscopyAnalysisWorkflowOptions

Option class for spectroscopy analysis workflows.

Attributes:

Name Type Description
do_plotting bool

Whether to create plots. Default: 'True'.

do_raw_data_plotting bool

Whether to plot the raw data. Default: True.

do_plotting_magnitude_phase bool

Whether to plot the magnitude and phase. Default: True.

do_plotting_real_imaginary bool

Whether to plot the real and imaginary data. Default: True.

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

The Resonator Spectroscopy analysis Workflow.

The workflow consists of the following steps:

Deprecated in version 26.10.0

The qubit argument is deprecated. Please use qubits instead.

Changed in version 26.10.0

The qubit argument was renamed to qubits and now also accepts multiple qubits, passed as a list.

Parameters:

Name Type Description Default
result RunExperimentResults

The experiment results returned by the run_experiment task.

required
qubits QuantumElements | None

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.

None
frequencies QubitSweepPoints | None

The array of frequencies that were swept over in the experiment for each qubit. 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.

None
qubit QuantumElements | None

Deprecated. The single qubit on which to run the analysis. Use qubits instead.

None
options ResonatorSpectroscopyAnalysisWorkflowOptions | None

The options for building the workflow, passed as an instance of ResonatorSpectroscopyAnalysisWorkflowOptions. See the docstring of ResonatorSpectroscopyAnalysisWorkflowOptions 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(7.0, 7.1, 101),
        np.linspace(7.2, 7.3, 101),
    ],
).run()

calculate_signal_magnitude_and_phase(qubits, result, frequencies)

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

Changed in version 26.10.0

The qubit argument was renamed to qubits and now also accepts multiple qubits. The returned dictionary has the qubit UIDs as keys.

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 for each qubit.

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, processed_data_dict, fit_results, options=None)

Extract the qubit parameters from the fit results.

Changed in version 26.10.0

The qubit argument was renamed to qubits and now also accepts multiple qubits.

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
fit_results dict[str, ModelResult]

the fit-results dictionary returned by fit_data

required
options ExtractQubitParametersResSpecOptions | None

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

fit_data(qubits, processed_data_dict, options=None)

Perform a fit of a Lorentzian model to the data if fit_lorentzian == True.

Changed in version 26.10.0

The qubits argument was added and the task now fits the data of multiple qubits. The returned dictionary has the qubit UIDs as keys.

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 FitDataResSpecOptions | None

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

None

Returns:

Type Description
dict[str, ModelResult]

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

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

Plot the magnitude and phase of the spectroscopy signal.

Changed in version 26.10.0

The qubit argument was renamed to qubits and now also accepts multiple qubits. The task creates one figure per qubit and returns them in a dictionary with the qubit UIDs as keys.

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]

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 PlotMagnitudePhaseOptions | None

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

If there are no new_parameter_values for a qubit, then the fit result and the textbox with the extracted readout resonator frequency are not plotted.

plot_real_imaginary(qubits, result, options=None)

Plot the real and imaginary parts of the spectroscopy signal.

Changed in version 26.10.0

The qubit argument was renamed to qubits and now also accepts multiple qubits. The task creates one figure per qubit and returns them in a dictionary with the qubit UIDs as keys.

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 result.

required
result RunExperimentResults

The experiment results returned by the run_experiment task.

required
options BasePlottingOptions | None

The options for this task as an instance of BasePlottingOptions. See the docstring for this class for more information.

None

Returns:

Type Description
dict[str, Figure]

dict with qubit UIDs as keys and the figures for each qubit as values.