Dataset

Load completed netCDF measurements and recover explicitly staged Zarr stores.

qanary.dataset.load(path)[source]

Load a qanary measurement dataset.

Wraps xarray.load_dataset() with engine selection appropriate for Qanary-generated files (automatic selection for .nc and the Zarr engine for .zarr) and clear error messages.

Parameters:

path (Union[str, Path]) – Path to a .nc file or .zarr directory created by a Qanary Measurement run.

Returns:

The fully-loaded (in-memory) xarray dataset.

Return type:

xr.Dataset

Raises:
qanary.dataset.convert(nc_path, *, overwrite=False)[source]

Convert the paired .zarr store for a measurement to netCDF.

A normal run exports its current in-memory dataset directly to netCDF and removes its temporary live checkpoint. If recovery instead leaves a .zarr directory beside the intended .nc file, this function can complete that conversion manually.

Expected layout on disk:

<stem>.nc      <- target output (may or may not exist yet)
<stem>.zarr/   <- live zarr store (must exist)
Parameters:
  • nc_path (Union[str, Path]) – Path to the (possibly missing) .nc file. The function derives the .zarr path by replacing the suffix.

  • overwrite (bool) – If True, overwrite an existing .nc file silently. Defaults to False.

Returns:

Resolved absolute path to the written .nc file.

Return type:

Path

Raises:
exception qanary.dataset.QanaryDatasetError[source]

Bases: Exception

Base class for all dataset-related errors in qanary.

exception qanary.dataset.DatasetNotFoundError[source]

Bases: QanaryDatasetError

Raised when the requested dataset file or directory does not exist.

exception qanary.dataset.ZarrStoreNotFoundError[source]

Bases: QanaryDatasetError

Raised when the expected .zarr store directory cannot be found.

exception qanary.dataset.DatasetLoadError[source]

Bases: QanaryDatasetError

Raised when xarray cannot open the dataset.

exception qanary.dataset.DatasetConvertError[source]

Bases: QanaryDatasetError

Raised when conversion from .zarr to .nc fails.