qblox_scheduler.analysis#

Module containing analysis functionalities.

Submodules#

Classes#

Basic2DAnalysis

A basic analysis that extracts the data from the latest file matching the label

BasicAnalysis

A basic analysis that extracts the data from the latest file matching the label

CosineAnalysis

Exemplary analysis subclass that fits a cosine to a dataset.

AnalysisDataContainer

Class which represents all data related to an experiment. This allows the user to

OutputDirectoryManager

Manages output directory paths for Qblox Scheduler data storage.

InterpolationAnalysis2D

An analysis class which generates a 2D interpolating plot for each yi variable in

OptimizationAnalysis

An analysis class which extracts the optimal quantities from an N-dimensional

AllXYAnalysis

Normalizes the data from an AllXY experiment and plots against an ideal curve.

EchoAnalysis

Analysis class for a qubit spin-echo experiment,

RabiAnalysis

Fits a cosine curve to Rabi oscillation data and finds the qubit drive

RamseyAnalysis

Fits a decaying cosine curve to Ramsey data (possibly with artificial detuning)

T1Analysis

Analysis class for a qubit T1 experiment,

ResonatorSpectroscopyAnalysis

Analysis for a spectroscopy experiment of a hanger resonator.

Functions#

acq_coords_to_dims(…)

Reshapes the acquisitions dataset or dataarray

Package Contents#

class Basic2DAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: BaseAnalysis

A basic analysis that extracts the data from the latest file matching the label and plots and stores the data in the experiment container.

create_figures()[source]#

To be implemented by subclasses.

Should generate figures of interest. matplolib figures and axes objects should be added to the .figs_mpl and axs_mpl dictionaries., respectively.

class BasicAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: BaseAnalysis

A basic analysis that extracts the data from the latest file matching the label and plots and stores the data in the experiment container.

create_figures()[source]#

Creates a line plot x vs y for every data variable yi and coordinate xi in the dataset.

class CosineAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: qblox_scheduler.analysis.base_analysis.BaseAnalysis

Exemplary analysis subclass that fits a cosine to a dataset.

process_data()[source]#

In some cases, you might need to process the data, e.g., reshape, filter etc., before starting the analysis. This is the method where it should be done.

See process_data() for an implementation example.

run_fitting()[source]#

Fits a CosineModel to the data.

create_figures()[source]#

Creates a figure with the data and the fit.

analyze_fit_results()[source]#

Checks fit success and populates quantities_of_interest.

class AnalysisDataContainer(tuid: str, name: str)[source]#

Class which represents all data related to an experiment. This allows the user to run experiments and store data. The class serves as an initial interface and uses the directory paths set by OutputDirectoryManager.

DATASET_NAME: ClassVar[str] = 'dataset.hdf5'#
SNAPSHOT_FILENAME: ClassVar[str] = 'snapshot.json'#
_TUID_LENGTH: ClassVar[int] = 26#
tuid#
day_folder#
data_folder#
property experiment_name: str#

The name of the experiment.

classmethod load_dataset(tuid: quantify_core.data.types.TUID, name: str = DATASET_NAME) xarray.Dataset[source]#

Loads a dataset specified by a tuid.

Parameters:
  • tuid – A TUID string. It is also possible to specify only the first part of a tuid.

  • name – Name of the dataset.

Returns:

: The dataset.

classmethod load_dataset_from_path(path: pathlib.Path | str) xarray.Dataset[source]#

Loads a Dataset with a specific engine preference.

Before returning the dataset AdapterH5NetCDF.recover() is applied.

This function tries to load the dataset until success with the following engine preference:

Parameters:

path – Path to the dataset.

Returns:

: The loaded dataset.

write_dataset(dataset: xarray.Dataset) None[source]#

Writes the quantify dataset to the directory specified by ~.data_folder.

Parameters:

dataset – The dataset to be written to the directory

save_snapshot(snapshot: dict[str, Any] | None = None, compression: Literal['bz2', 'gzip', 'lzma'] | None = None) None[source]#

Writes the snapshot to disk as specified by ~.data_folder.

Parameters:
  • snapshot – The snapshot to be written to the directory

  • compression – The compression type to use. Can be one of ‘gzip’, ‘bz2’, ‘lzma’. Defaults to None, which means no compression.

classmethod get_latest_tuid(contains: str = '') quantify_core.data.types.TUID[source]#

Returns the most recent tuid.

Tip

This function is similar to get_tuids_containing() but is preferred if one is only interested in the most recent TUID for performance reasons.

Parameters:

contains – An optional string contained in the experiment name.

Returns:

: The latest TUID.

Raises:

FileNotFoundError – No data found.

classmethod get_tuids_containing(contains: str = '', t_start: datetime.datetime | str | None = None, t_stop: datetime.datetime | str | None = None, max_results: int = sys.maxsize, reverse: bool = False) list[quantify_core.data.types.TUID][source]#

Returns a list of tuids containing a specific label.

Tip

If one is only interested in the most recent TUID, get_latest_tuid() is preferred for performance reasons.

Parameters:
  • contains – A string contained in the experiment name.

  • t_start – datetime to search from, inclusive. If a string is specified, it will be converted to a datetime object using parse. If no value is specified, will use the year 1 as a reference t_start.

  • t_stop – datetime to search until, exclusive. If a string is specified, it will be converted to a datetime object using parse. If no value is specified, will use the current time as a reference t_stop.

  • max_results – Maximum number of results to return. Defaults to unlimited.

  • reverse – If False, sorts tuids chronologically, if True sorts by most recent.

Returns:

list A list of TUID: objects.

Raises:

FileNotFoundError – No data found.

classmethod locate_experiment_container(tuid: str) pathlib.Path[source]#

Returns the experiment container for the given tuid.

class OutputDirectoryManager[source]#

Manages output directory paths for Qblox Scheduler data storage.

The class maintains a single instance throughout the application lifecycle, ensuring consistent directory management.

_datadir#

The current data directory path. Private attribute managed through setter and getter methods.

Type:

str or Path

DATADIR: ClassVar[pathlib.Path]#
classmethod set_datadir(datadir: pathlib.Path | str | None = None) None[source]#

Sets the data directory.

Parameters:

datadir (pathlib.Path or str or None) – Path of the data directory. If set to None, resets the datadir to the default datadir (<top_level>/data).

classmethod get_datadir() pathlib.Path[source]#

Returns the current data directory.

Returns:

: The current data directory.

acq_coords_to_dims(data: xarray.Dataset, coords: list[collections.abc.Hashable], acq_channels: collections.abc.Iterable[collections.abc.Hashable] | None = None) xarray.Dataset[source]#
acq_coords_to_dims(data: xarray.DataArray, coords: list[collections.abc.Hashable], acq_channels: collections.abc.Iterable[collections.abc.Hashable] | None = None) xarray.DataArray

Reshapes the acquisitions dataset or dataarray so that the given coords become dimensions. It can also reshape from a 1 dimensional data to a multi-dimensional data along the given coords. If a dataset is given, all acquisition channels are reshaped, unless acq_channels are given.

Parameters:
  • data – The data to be converted to multi-dimensions. Can be a Dataset or a DataArray.

  • coords – The coords keys that needs to be converted to dimensions.

  • acq_channels – In case of a Dataset, these acquisition channels need to be converted.

Returns:

A DataArray or Dataset that has multi-dimensional dimensions along the specified coords.

Raises:

ValueError – If there are no coords or if the data does not contain the acquisition index dimension name.

class InterpolationAnalysis2D(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: qblox_scheduler.analysis.base_analysis.BaseAnalysis

An analysis class which generates a 2D interpolating plot for each yi variable in the dataset.

create_figures()[source]#

Create a 2D interpolating figure for each yi.

class OptimizationAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: qblox_scheduler.analysis.base_analysis.BaseAnalysis

An analysis class which extracts the optimal quantities from an N-dimensional interpolating experiment.

run(minimize: bool = True)[source]#
Parameters:

minimize – Boolean which determines whether to report the minimum or the maximum. True for minimize. False for maximize.

Returns:

OptimizationAnalysis: The instance of this analysis.

process_data()[source]#

Finds the optimal (minimum or maximum) for y0 and saves the xi and y0 values in the quantities_of_interest.

create_figures()[source]#

Plot each of the x variables against each of the y variables.

class AllXYAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: SingleQubitTimedomainAnalysis

Normalizes the data from an AllXY experiment and plots against an ideal curve.

See section 2.3.2 of :cite:t:`reed_entanglement_2013` for an explanation of the AllXY experiment and it’s applications in diagnosing errors in single-qubit control pulses.

run()[source]#

Executes the analysis using specific datapoints as calibration points.

Returns:

AllXYAnalysis: The instance of this analysis.

_rotate_to_calibrated_axis()[source]#
process_data()[source]#

Processes the data so that the analysis can make assumptions on the format.

Populates self.dataset_processed.S21 with the complex (I,Q) valued transmission, and if calibration points are present for the 0 and 1 state, populates self.dataset_processed.pop_exc with the excited state population.

create_figures()[source]#

To be implemented by subclasses.

Should generate figures of interest. matplolib figures and axes objects should be added to the .figs_mpl and axs_mpl dictionaries., respectively.

class EchoAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: SingleQubitTimedomainAnalysis, _DecayFigMixin

Analysis class for a qubit spin-echo experiment, which fits an exponential decay and extracts the T2_echo time.

run_fitting()[source]#

Fit the data to ExpDecayModel.

analyze_fit_results()[source]#

Checks fit success and populates .quantities_of_interest.

create_figures()[source]#

Create a figure showing the exponential decay and fit.

class RabiAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: SingleQubitTimedomainAnalysis

Fits a cosine curve to Rabi oscillation data and finds the qubit drive amplitude required to implement a pi-pulse.

The analysis will automatically rotate the data so that the data lies along the axis with the best SNR.

run(calibration_points: bool = True)[source]#
Parameters:

calibration_points – Specifies if the data should be rotated so that it lies along the axis with the best SNR.

Returns:

RabiAnalysis: The instance of this analysis.

_rotate_to_calibrated_axis()[source]#

If calibration points are True, automatically determine the point farthest from the 0 point to use as a reference to rotate the data.

This will ensure the data lies along the axis with the best SNR.

_choose_data_for_fit()[source]#
run_fitting()[source]#

Fits a RabiModel to the data.

analyze_fit_results()[source]#

Checks fit success and populates .quantities_of_interest.

create_figures()[source]#

Creates Rabi oscillation figure

class RamseyAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: SingleQubitTimedomainAnalysis, _DecayFigMixin

Fits a decaying cosine curve to Ramsey data (possibly with artificial detuning) and finds the true detuning, qubit frequency and T2* time.

run(artificial_detuning: float = 0, qubit_frequency: float = None, calibration_points: bool | Literal['auto'] = 'auto')[source]#
Parameters:
  • artificial_detuning – The detuning in Hz that will be emulated by adding an extra phase in software.

  • qubit_frequency – The initial recorded value of the qubit frequency (before accurate fitting is done) in Hz.

  • calibration_points – Indicates if the data analyzed includes calibration points. If set to True, will interpret the last two data points in the dataset as \(|0\rangle\) and \(|1\rangle\) respectively. If "auto", will use has_calibration_points() to determine if the data contains calibration points.

Returns:

RamseyAnalysis: The instance of this analysis.

run_fitting()[source]#

Fits a DecayOscillationModel to the data.

analyze_fit_results()[source]#

Extract the real detuning and qubit frequency based on the artificial detuning and fitted detuning.

create_figures()[source]#

Plot Ramsey decay figure.

class T1Analysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: SingleQubitTimedomainAnalysis, _DecayFigMixin

Analysis class for a qubit T1 experiment, which fits an exponential decay and extracts the T1 time.

run_fitting()[source]#

Fit the data to ExpDecayModel.

analyze_fit_results()[source]#

Checks fit success and populates .quantities_of_interest.

create_figures()[source]#

Create a figure showing the exponential decay and fit.

class ResonatorSpectroscopyAnalysis(dataset: xarray.Dataset | None = None, tuid: quantify_core.data.types.TUID | str | None = None, label: str = '', settings_overwrite: dict | None = None, plot_figures: bool = True)[source]#

Bases: qblox_scheduler.analysis.base_analysis.BaseAnalysis

Analysis for a spectroscopy experiment of a hanger resonator.

process_data()[source]#

Verifies that the data is measured as magnitude and phase and casts it to a dataset of complex valued transmission \(S_{21}\).

run_fitting()[source]#

Fits a ResonatorModel to the data.

analyze_fit_results()[source]#

Checks fit success and populates .quantities_of_interest.

create_figures()[source]#

Plots the measured and fitted transmission \(S_{21}\) as the I and Q component vs frequency, the magnitude and phase vs frequency, and on the complex I,Q plane.

_create_fig_s21_real_imag()[source]#
_create_fig_s21_magn_phase()[source]#
_create_fig_s21_complex()[source]#