Skip to content

Resolve "Stack dataset writer"

Wout De Nolf requested to merge 7-stack-dataset-writer into main

Closes #7 (closed)

Introduces StackDatasetWriter which is the same as DatasetWriter except that when adding data, you need to provide the stack index to which you add the data:

import h5py
import numpy
from ewoksdata.data.hdf5.dataset_writer import StackDatasetWriter

point_data = numpy.arange(5)

with h5py.File("test.h5", "w") as f:
    with StackDatasetWriter(f, "myname") as writer:
        writer.add_point(point_data, 0)
        writer.add_point(point_data, 2)
        writer.add_point(point_data, 1)
        writer.add_point(point_data, 2)
    print(writer.dataset.shape)

The example above results in a dataset with shape = (3, 2, 5) which is (nstack, npoints, nchannels).

Edited by Wout De Nolf

Merge request reports

Loading