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.
ResonatorSpectroscopyAnalysisOptions
¶
Options for the analysis of the resonator spectroscopy experiment.
Attributes:
Name | Type | Description |
---|---|---|
fit_lorentzian |
bool
|
Whether to fit a Lorentzian model to the data.
Default: |
fit_parameters_hints |
dict[str, dict[str, float | bool | str]] | None
|
Parameters hints accepted by lmfit Default: None. |
find_peaks |
bool
|
Whether to search for peaks (True) or dips (False) in the spectrum.
Default: |
save_figures |
bool
|
Whether to save the figures.
Default: |
close_figures |
bool
|
Whether to close the figures.
Default: |
close_figures: bool = workflow.option_field(True, description='Whether to close the figures.')
class-attribute
instance-attribute
¶
find_peaks: bool = workflow.option_field(False, description='Whether to search for peaks (True) or dips (False) in the spectrum.')
class-attribute
instance-attribute
¶
fit_lorentzian: bool = workflow.option_field(False, description='Whether to fit a Lorentzian model to the data.')
class-attribute
instance-attribute
¶
fit_parameters_hints: dict[str, dict[str, float | bool | str]] | None = workflow.option_field(None, description='Parameters hints accepted by lmfit')
class-attribute
instance-attribute
¶
save_figures: bool = workflow.option_field(True, description='Whether to save the figures.')
class-attribute
instance-attribute
¶
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. |
do_plotting: bool = workflow.option_field(True, description='Whether to create plots.')
class-attribute
instance-attribute
¶
do_plotting_magnitude_phase: bool = workflow.option_field(True, description='Whether to plot the magnitude and phase.')
class-attribute
instance-attribute
¶
do_plotting_real_imaginary: bool = workflow.option_field(True, description='Whether to plot the real and imaginary data.')
class-attribute
instance-attribute
¶
do_raw_data_plotting: bool = workflow.option_field(True, description='Whether to plot the raw data.')
class-attribute
instance-attribute
¶
analysis_workflow(result, qubit, frequencies, options=None)
¶
The Resonator Spectroscopy analysis Workflow.
The workflow consists of the following steps:
- calculate_signal_magnitude_and_phase
- fit_data
- extract_qubit_parameters
- plot_raw_complex_data_1d
- plot_magnitude_phase
- plot_real_imaginary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
RunExperimentResults
|
The experiment results returned by the run_experiment task. |
required |
qubit |
QuantumElement
|
The qubit on which to run the analysis. The UID of this qubit must exist in the result. |
required |
frequencies |
ArrayLike
|
The array of frequencies that were swept over in the experiment. |
required |
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
result = analysis_workflow(
results=results
qubit=q0,
frequencies=np.linspace(7.0, 7.1, 101),
options=analysis_workflow.options(),
).run()
calculate_signal_magnitude_and_phase(qubit, 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 |
qubit |
QuantumElement
|
The qubit on which to run the analysis. The UID of this qubit 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, ArrayLike]
|
dictionary with the following data: sweep_points data_raw magnitude phase |
extract_qubit_parameters(qubit, processed_data_dict, fit_result, options=None)
¶
Extract the qubit parameters from the fit results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubit |
QuantumElement
|
The qubit on which to run the analysis. |
required |
processed_data_dict |
dict[str, ArrayLike]
|
the processed data dictionary returned by calculate_signal_magnitude_and_phase. |
required |
fit_result |
ModelResult | None
|
the lmfit ModelResults returned by fit_data |
required |
options |
ResonatorSpectroscopyAnalysisOptions | None
|
The options for extracting the qubit parameters. See [ResonatorSpectroscopyAnalysisOptions] and [BaseExperimentOptions] for accepted options. |
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 |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
parameters. The dictionary has the following form: |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
```python |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
{ "new_parameter_values": { q.uid: { qb_param_name: qb_param_value }, } "old_parameter_values": { q.uid: { qb_param_name: qb_param_value }, } |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
} |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
``` |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
If the fit_results is None, the new_parameter_values entry for the qubit is |
dict[str, dict[str, dict[str, int | float | Variable | None]]]
|
left empty. |
fit_data(processed_data_dict, options=None)
¶
Perform a fit of a Lorentzian model to the data if fit_lorentzian == True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
processed_data_dict |
dict[str, ArrayLike]
|
the processed data dictionary returned by calculate_signal_magnitude_and_phase |
required |
options |
ResonatorSpectroscopyAnalysisOptions | None
|
The options for processing the raw data. See [ResonatorSpectroscopyAnalysisOptions] and [BaseExperimentOptions] for accepted options. |
None
|
Returns:
Type | Description |
---|---|
ModelResult | None
|
dict with qubit UIDs as keys and the fit results for each qubit as keys. |
plot_magnitude_phase(qubit, processed_data_dict, fit_result, qubit_parameters, options=None)
¶
Plot the magnitude and phase of the spectroscopy signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubit |
QuantumElement
|
The qubit on which to run the analysis. qubit_parameters. |
required |
processed_data_dict |
dict[str, ArrayLike]
|
the processed data dictionary returned by calculate_signal_magnitude_and_phase. |
required |
fit_result |
ModelResult | None
|
the lmfit ModelResults 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 |
ResonatorSpectroscopyAnalysisOptions | None
|
The options for extracting the qubit parameters. See [ResonatorSpectroscopyAnalysisOptions] and [BaseExperimentOptions] for accepted options. |
None
|
Returns:
Type | Description |
---|---|
Figure | None
|
the matplotlib figure |
Figure | None
|
If there are no new_parameter_values for the qubit, then fit result and the |
Figure | None
|
textbox with the extracted readout resonator frequency are not plotted. |
plot_real_imaginary(qubit, result, options=None)
¶
Create the amplitude-Rabi plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qubit |
QuantumElement
|
The qubit on which to run the analysis. |
required |
result |
RunExperimentResults
|
The experiment results returned by the run_experiment task. |
required |
options |
ResonatorSpectroscopyAnalysisOptions | None
|
The options for extracting the qubit parameters. See [ResonatorSpectroscopyAnalysisOptions] and [BaseExperimentOptions] for accepted options. |
None
|
Returns:
Type | Description |
---|---|
Figure | None
|
the matplotlib figure |