Apollo3zehn / PureHDF

A pure .NET library that makes reading and writing of HDF5 files (groups, datasets, attributes, ...) very easy.
MIT License
47 stars 16 forks source link

how to traverse the attributes of a group or a dataset? #15

Closed Fokatu closed 1 year ago

Fokatu commented 2 years ago

traverse the attributes and show the corresponding contents. Thanks

Apollo3zehn commented 2 years ago

Groups and datasets have the property public IEnumerable<H5Attribute> Attributes

You can iterate using the IEnumerable and then read the contents of each attribute using the Read<T>() method.

Fokatu commented 2 years ago

Thanks for your reply. My question is how to get the type of the attribute, i.e., the T for the function Read?

Fokatu commented 2 years ago

image How to implement the above table?

Apollo3zehn commented 2 years ago

To read a structure / compound, you could create a type that maps to the one in the HDF file: https://github.com/Apollo3zehn/HDF5.NET#structs-with-nullable-fields

To get the data type of an attribute, there is the Type property. This gives you the type class but currently no further information. I have to expose more details to make that property useful. That's why its still an alpha stage project :-)

Fokatu commented 2 years ago

Do you mean that I cannot implement the function shown in the above image for arbitrary hdf5 file?

Apollo3zehn commented 2 years ago

Yes, that is currently not possible. As a workaround you could clone the repo, make the DataTypeMessage property public and then implement your routine to read arbitrary structs. Here is a PR witch tries to solve the same problem: https://github.com/Apollo3zehn/HDF5.NET/pull/15

I will need some time to implement a proper solution to read arbitrary HDF5 structs. Until then the only way is follow the approach of Apollo3zehn/HDF5.NET#15 .

Apollo3zehn commented 1 year ago

Reading unknown structs is now possible: https://github.com/Apollo3zehn/HDF5.NET#63-unknown-structs

Apollo3zehn commented 1 year ago

This is a message I post to all recent issues: I have just renamed the project from HDF5.NET to PureHDF for my preparations of a soon to come beta release. Please note that the Nuget package name has also changed and can be found here now: https://www.nuget.org/packages/PureHDF.