Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HDF5 : create 1 dimension attribute

Tags:

c

hdf5

I am able to create very complex hdf5 file with attributes. I am using the low api from hdf5 to manage my dataset and using the hdf5 lite api to manage attributes.

Problem is that hdf5 lite seems to create array for everything. It seems to be the same for low api.

Example:

Create a simple integer attribute in a dataset:

int data = 42;
H5LTset_attribute_int(my_hdf5_file, "/", "my_attribute", &data, 1);

This simple attribute is stored as a array of integer of 1 dimension. I don't want to use array. I want a simple native type. Yes everything is working but for example I am communicating with another program in python which seems to be able to store simple integer and not array for attribute.

Is is possible to not use arrays to store integer attribute with hdf5?

like image 650
ArthurLambert Avatar asked Apr 15 '26 13:04

ArthurLambert


1 Answers

Yes, but you have to use the low level API as well:

hid_t dspace = H5Screate(H5S_SCALAR);
hid_t attr = H5Acreate(my_hdf5_file, "my_attribute", H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT);
herr_t status = H5Awrite(attr, H5T_NATIVE_INT, &data);
H5Aclose(attr);
H5Sclose(dspace);
like image 120
Simon Avatar answered Apr 17 '26 04:04

Simon