Matlab HDF5: Read DIMENSION_LIST attribute -
i'm trying read hdf5 files matlab. created files in fortran, relevant in used h5dsattach_scale_f attached scale datasets each dimension of given primary dataset. of logic works well, i'm having trouble reading attributes of primary dataset in order @ attached scales.
i start iterating through each dataset in file. once know have primary dataset, iterate through attributes call:
[status, index_out, sd] = h5a.iterate(dset_id, 'h5_index_name', 'h5_iter_native', 0, @hdf5_sds_attr_iter, sd);
that calls function every attribute:
function [status, sd] = hdf5_sds_attr_iter(dset_id, attr_name, info, sd) status = 0; disp(attr_name); if ~strcmp(attr_name, 'dimension_list') return; end attr_id = h5a.open(dset_id, attr_name, 'h5p_default'); space = h5a.get_space (attr_id); [~, dims, ~] = h5s.get_simple_extent_dims(space); info2 = h5a.get_info(attr_id); disp(info2); rdata = h5a.read(attr_id, 'h5ml_default'); disp(rdata); = 1:dims disp(rdata{i}); end h5s.close(space); h5a.close(attr_id); end this output:
dimension_list 3 corder_valid: 1 corder: 0 cset: 0 data_size: 48 [8x1 uint8] [8x1 uint8] [8x1 uint8] 184 17 0 0 0 0 0 0 32 28 0 0 0 0 0 0 240 29 0 0 0 0 0 0 if h5dump on dataset, attribute looks like:
attribute "dimension_list" { datatype h5t_vlen { h5t_reference { h5t_std_ref_object }} dataspace simple { ( 3 ) / ( 3 ) } data { (0): (dataset 1400 /beamdata scale rank 1 ), (1): (dataset 6512 /beamdata scale rank 2 ), (2): (dataset 6976 /beamdata scale rank 3 ) } } since numbers (1400, 6512, 6976) not appear elsewhere in dump, don't know how use them or output of h5a.read (rdata) @ scale data. matlab hdf5 documentation rather silent on attribute data. know how process attribute reference data correctly?
Comments
Post a Comment