Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid roundtrip to qcodes format when loading as xarray from netcdf #5627

Merged
merged 7 commits into from
Jan 19, 2024
Prev Previous commit
Next Next commit
directly returning a xr dataset when loading from netcdf file
  • Loading branch information
jenshnielsen committed Jan 18, 2024
commit 0c14c52eeaea304a8e8e94a67a4229fe427a162b
12 changes: 12 additions & 0 deletions src/qcodes/dataset/data_set_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,18 @@ def load_data_from_db(self) -> None:
)


def to_xarray_dataset(
self, *, use_multi_index: Literal["auto", "always", "never"] = "auto"
) -> xr.Dataset:
if use_multi_index == "always":
ds = self._xr_dataset.stack()
elif use_multi_index == "never":
ds = self._xr_dataset.unstack()
else:
ds = self._xr_dataset
return ds


class DataSetCacheWithDBBackend(DataSetCache["DataSet"]):
def load_data_from_db(self) -> None:
"""
Expand Down