How to add 'ChunkSize' in .h5 file?

3 次查看(过去 30 天)
Axel
Axel 2019-8-30
I would like to resize my dataset (as shown in the attached picture) from 2x20 to 2x3. To achieve this it is necessary to have the ChunkSize to be 2x3. I have been trying to fix this for hours now without any luck. This what I have done so far...
% Ok!, Now let's set the writable attribute of FileName
fileattrib(FileName,'+w');
fid = H5F.open(FileName,'H5F_ACC_RDWR','H5P_DEFAULT');
dset_id = H5D.open(fid,DatasetName);
dcpl = H5D.get_create_plist(dset_id);
chunk_dims = [2 3];
% set it to use the chunked dataset
h5_chunk_dims = fliplr(chunk_dims);
H5P.set_chunk(dcpl,h5_chunk_dims)
% Change size of dataset
H5D.set_extent(dset_id,[3,2]) %[THIS DOES NOT WORK and throw the messag]
=================================
Error using hdf5lib2
The HDF5 library encountered an error and produced the following stack trace information:
H5D__set_extent dataset has contiguous storage
H5Dset_extent unable to set extend dataset
Error in H5D.set_extent (line 27)
H5ML.hdf5lib2('H5Dset_extent', dset_id, h5_extents);

回答(1 个)

Manas Meena
Manas Meena 2020-9-30
The error might be because the library cannot find the file/variable that was passed in the “H5P.set_extent” command.
Refer to the below documentation links on how to use the H5P.set_chunk” and “H5P.set_extent” commands:
You can also refer to the following link to see how to replace a dataset with a smaller dataset in a HDF5 file:

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by