HDFGroup / hdfview

Other
59 stars 14 forks source link

Viewing column-major data in HDFView #174

Open darcamo opened 6 months ago

darcamo commented 6 months ago

I understand that HDF5 is row-major only. Whenever the original data is column-major in memory, the usual approach is to save it transposed. Thus, a "5 x 3" matrix is saved as a "3 x 5" dataset and when it is read back it is seen as a "5 x 3" matrix again.

HDFView has a nice feature where I can right-click in the dataset, choose "Open as", and then change which dimensions corresponds to the height, width and depth in the visualization. The only problem is that I need to do this everytime I open the HDF5 file and I want to view that dataset. Is there a way to save this as metadata (an attribute in the dataset) to make HDFView automatically visualize the dataset with transposed dimensions? This could work similarly to how HDFView handle images, where the presence of some attributes is used to tell HDFView to visualize the data as an image, instead of just numbers.

The easiest way, in my opinion, would be for HDFView to simply revert the default dimensions corresponding to height, width and depth if a "DATA_LAYOUT" attribute with value "TRANSPOSED" was set in the dataset. In order words, for a 3D dataset with dimensions "5 x 3 x 8", for instance, it would use dimension 2 as height, dimension 1 as width, and dimension 0 as depth if the attribute is set.

byrnHDF commented 3 months ago

One feature of HDView is the use of User Options. Seems like a worthwhile addition to the general options would be the setting for TRANSPOSE. Of course these User Options are global settings affecting operations with HDFView.