qblox_scheduler.analysis.data_handling#

Data handling utilities for Qblox Scheduler.

Classes#

OutputDirectoryManager

Manages output directory paths for Qblox Scheduler data storage.

AnalysisDataContainer

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

Functions#

_get_default_datadir(→ pathlib.Path)

Returns (and optionally print) a default datadir path.

Module Contents#

_get_default_datadir(verbose: bool = False) pathlib.Path[source]#

Returns (and optionally print) a default datadir path.

Intended for fast prototyping, tutorials, examples, etc..

Parameters:

verbose – If True prints the returned datadir.

Returns:

: The Path.home() / "qblox_data" path.

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][source]#
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.

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'[source]#
SNAPSHOT_FILENAME: ClassVar[str] = 'snapshot.json'[source]#
_TUID_LENGTH: ClassVar[int] = 26[source]#
tuid[source]#
day_folder[source]#
data_folder[source]#
property experiment_name: str[source]#

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.