Source code for qiskit_experiments.library.characterization.analysis.resonator_spectroscopy_analysis
# This code is part of Qiskit.## (C) Copyright IBM 2021.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Spectroscopy analysis class for resonators."""fromtypingimportList,Optional,Tupleimportnumpyasnpfromqiskit.utils.deprecationimportdeprecate_funcimportqiskit_experiments.curve_analysisascurvefromqiskit_experiments.frameworkimportAnalysisResultData,ExperimentDatafromqiskit_experiments.framework.matplotlibimportget_non_gui_axfromqiskit_experiments.data_processing.nodesimportProjectorTypefromqiskit_experiments.database_service.device_componentimportResonator
[docs]classResonatorSpectroscopyAnalysis(curve.ResonanceAnalysis):"""Class to analysis resonator spectroscopy."""@deprecate_func(since="0.8",package_name="qiskit-experiments",additional_msg=("Due to the deprecation of Qiskit Pulse, experiments and related classses ""involving pulse gate calibrations like this one have been deprecated."),)def__init__(self,name:Optional[str]=None,):super().__init__(name=name)@classmethoddef_default_options(cls):"""Return default analysis options. Analysis Options: dimensionality_reduction (ProjectorType): Type of the data processor node that will reduce the two-dimensional data to one dimension. plot_iq_data (bool): Set True to generate IQ plot. """options=super()._default_options()options.dimensionality_reduction=ProjectorType.ABSoptions.result_parameters=[curve.ParameterRepr("freq","res_freq0","Hz"),curve.ParameterRepr("kappa","kappa","Hz"),]options.plot_iq_data=Truereturnoptionsdef_get_experiment_components(self,experiment_data:ExperimentData):"""Return resonators as experiment components."""return[Resonator(qubit)forqubitinexperiment_data.metadata["physical_qubits"]]def_run_analysis(self,experiment_data:ExperimentData)->Tuple[List[AnalysisResultData],List["pyplot.Figure"]]:"""Wrap the analysis to optionally plot the IQ data."""analysis_results,figures=super()._run_analysis(experiment_data)ifself.options.plot_iq_data:axis=get_non_gui_ax()figure=axis.get_figure()# TODO: Move plotting to a new IQPlotter class.figure.set_size_inches(*self.plotter.drawer.style["figsize"])iqs=[]fordatuminexperiment_data.data():if"memory"indatum:mem=np.array(datum["memory"])# Average single-shot data.iflen(mem.shape)==3:foridxinrange(mem.shape[1]):iqs.append(np.average(mem[:,idx,:],axis=0))else:iqs.append(mem)iflen(iqs)>0:iqs=np.vstack(iqs)axis.scatter(iqs[:,0],iqs[:,1],color="b")axis.set_xlabel("In phase [arb. units]",fontsize=self.plotter.drawer.style["axis_label_size"])axis.set_ylabel("Quadrature [arb. units]",fontsize=self.plotter.drawer.style["axis_label_size"])axis.tick_params(labelsize=self.plotter.drawer.style["tick_label_size"])axis.grid(True)figures.append(figure)returnanalysis_results,figures