Skip to content

Commit

Permalink
Dynamically calc index
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Oct 4, 2023
1 parent 5c5dfaf commit e66a1c2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions qcodes/dataset/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,10 +1488,13 @@ def _export_as_netcdf(self, path: Path, file_name: str) -> Path:
"temp_dir": temp_dir,
},
)
for i in trange(len(self), desc="Writing individual files"):
num_files = len(self)
num_digits = len(str(num_files))
file_name_template = f"ds_{{:0{num_digits}d}}.nc"
for i in trange(num_files, desc="Writing individual files"):
xarray_to_h5netcdf_with_complex_numbers(
self.to_xarray_dataset(start=i + 1, end=i + 1),
temp_path / f"ds_{i:03d}.nc",
temp_path / file_name_template.format(i),
)
files = tuple(temp_path.glob("*.nc"))
data = xr.open_mfdataset(files)
Expand Down

0 comments on commit e66a1c2

Please sign in to comment.