Commit 6ce70a7f authored by Tomas Farago's avatar Tomas Farago
Browse files

patch creating virtual datasets

parent df0bba76
......@@ -437,7 +437,7 @@ def _insert_frame_data(data, file_path, data_path, where, logger=None):
"{} should point to 2D or 3D dataset ".format(url.path())
)
if data_frm_url.ndim is 2:
new_shape = 1, data_frm_url[0], data_frm_url[1]
new_shape = 1, data_frm_url.shape[0], data_frm_url.shape[1]
if logger is not None:
logger.info(
"reshape provided data to 3D (from {} to {})"
......@@ -452,8 +452,16 @@ def _insert_frame_data(data, file_path, data_path, where, logger=None):
if os.path.dirname(vds_file) not in ('', None):
os.chdir(os.path.dirname(vds_file))
with HDF5File(vs_info.file_name, mode="r") as vs_node:
vs_shape = vs_node[vs_info.dset_name].shape
length = vs_shape[0]
vs_shape = list(vs_info.vspace.shape)
if len(vs_shape) is 2:
length = 1
vs_shape[0] = 1
else:
select_bounds = vs_info.vspace.get_select_bounds()
left_bound = select_bounds[0]
right_bound = select_bounds[1]
length = right_bound[0] - left_bound[0] + 1
vs_shape[0] = length
return (
length,
h5py.VirtualSource(
......@@ -479,14 +487,14 @@ def _insert_frame_data(data, file_path, data_path, where, logger=None):
vds_file_path = os.path.relpath(
vds_file_path, os.path.dirname(file_path)
)
new_virtual_source = h5py.VirtualSource(
path_or_dataset=vds_file_path,
name=url.data_path(),
shape=data_frm_url.shape,
)
n_frames += h5s[data_path].shape[0]
data_type = h5s[data_path].dtype
tmp_dataset = h5s[data_path]
n_frames += tmp_dataset.shape[0]
data_type = tmp_dataset.dtype
if where == "start":
virtual_sources.insert(0, new_virtual_source)
......@@ -494,7 +502,6 @@ def _insert_frame_data(data, file_path, data_path, where, logger=None):
else:
virtual_sources.append(new_virtual_source)
virtual_sources_len.append(data_frm_url.shape[0])
# create the new virtual dataset
layout = h5py.VirtualLayout(
shape=(n_frames, dim_2, dim_1), dtype=data_type
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment