Hi everybody,
I have two main problem with working with HDF5, some of you may have the solution:
- I am trying to create an array of compound (the compound can contain several fields, which can also be arrays).
Example:
“tata(1).heh=[2:2:20];
tata(2).heh=[2:4:40];”
I tried to method which both didn’t work
a) "file=H5F.open(name_of_HDF5_file,‘H5F_ACC_RDWR’,‘H5P_DEFAULT’);
dataspace = H5S.create_simple(2, [1 2], []);
doubleType=H5T.copy(‘H5T_NATIVE_DOUBLE’);
member(1).datatype = H5T.array_create(doubleType, 1, length(tata(1).heh), []);
sz(1) =H5T.get_size(member(1).datatype);
% Computer the offsets of each field. The first offset is always zero
offset(1)=0;
memtype = H5T.create(‘H5T_COMPOUND’,sum(sz));
H5T.insert(memtype,‘heh’,offset(1),member(1).datatype);
base_type=H5T.copy(memtype);
datatype=H5T.array_create(base_type, 2, [1 2],[]);
dataset = H5D.create(file, dataset, datatype, dataspace,‘H5P_DEFAULT’);
H5D.write(dataset, datatype, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, tata);"
b)"file=H5F.open(name_of_HDF5_file,‘H5F_ACC_RDWR’,‘H5P_DEFAULT’);
doubleType=H5T.copy(‘H5T_NATIVE_DOUBLE’);
member(1).datatype = H5T.array_create(doubleType, 1, length(tata(1).heh), []);
sz(1) =H5T.get_size(member(1).datatype);
% Computer the offsets of each field. The first offset is always zero
offset(1)=0;
memtype = H5T.create(‘H5T_COMPOUND’,sum(sz));
H5T.insert(memtype,‘heh’,offset(1),member(1).datatype);
% Create dataspace. Setting maximum size to [] sets the maximum size to be the current size
space = H5S.create_simple(2,[1 2], []);
dset_id = H5D.create(file, dataset, memtype, space, ‘H5P_DEFAULT’);
H5D.write(dset_id, memtype, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, tata);"
has anyone any ideas of what I did bad?
- I am trying to read a part of an array which is inside a structure
“tata(1).heh=[2:2:20];
tata(2).heh=[2:4:40];”
tata(2).heh(1)=2;
I used hyperslab but the only thing I managed to get is the entire array. I am wondering whether or not this is possible.
thanks for reading
Antoine