Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am looking to Import HDF5 data with compound data. It appears, at least from what I read, that Mathematica 8.0.4 (and previous versions) does not support reading HDF5 with compound data.

file = "someData.h5";
Import[file, "Data"]
Import[file, {"Datasets", 1}]

Returns:

{{"Unsupported Datatype Class", "Compound"}, ... }
Import::h5type: "The datatype of the dataset "\foobar" is not currently supported. "

It has been a while, since Oct 2011 when Mathematica HDF5 and compound arrays was last updated. It was update with info about Scot Martin's HDF5 package. Unfortunately that package appears be a solution for Windows which uses two .Net dlls (hdf5dll.dll and HDF5DotNet.dll) and I have a Mac. Just wondering if there has been any progress?

I have looked at using h5dump to create an ASCII file and writing an importer. However there is the overhead of writing the file, reading it, and then parsing it.

share|improve this question
    
Could you upload a simple, example HDF5 file with compound data to experiment with? –  Markus Roellig Apr 9 '12 at 10:44
    
I will see what I can do. There are some h5 files available in Scot Martin's HDF5 package in the HDF5HighLevel ExampleFiles directory. h5ex_t_cmpd.h5 has compound data. –  mmorris Apr 9 '12 at 15:00

3 Answers 3

I have created h5dumpImport, an open source Mathematica Package that provides a platform independent way to import HDF5 (.h5) file's datasets with compound datatypes while hiding much of the HDF5 implementation from the user. The package with documentation, examples, and unit test is located here.

Currently, the h5dumpImport package does not directly import the HDF5 (.h5) file format. The h5dumpImport package imports an ASCII dump of a dataset generated by the h5dump command line tool.

Source code and pre-built binary distributions of the HDF5 Software which includes the h5dump command line tool can be found at the The HDF Group's website.

Basic Example

Needs["h5dumpImport`"]
datasets = Import["testData.h5", {"Datasets"}];
dumpFile = h5dump["/usr/bin/h5dump", "testData.h5", datasets[[1]]];
dumpImport = h5dumpImportNew[h5dumpImport[], dumpFile];
dumpImport.h5dumpImportData[All]
dumpImport.h5dumpImportClose[];

Results:

{{1, 11, 111, 1111, 11111, 111111, 1111111, 1.1, 11.11, "one"},
 {2, 22, 222, 2222, 22222, 222222, 2222222, 2.2, 22.22, "two"},
 {3, 33, 333, 3333, 33333, 333333, 3333333, 3.3, 33.33, "three"}}

Detailed installation instructions, usage information, and documentation, examples, and unit tests can be found here.

share|improve this answer

We have written a C++ MathLink HDF5 importer for Mathematica to replace the built-in one. We found the built-in importer to crash or leak memory when dealing with large HDF5 files (with many datasets). Our importer is free software available at

http://sourceforge.net/p/h5mma/home/h5mma/

We don't use compound data ourselves, but it should be possible to enhance this reader to add import of compound data.

share|improve this answer

For HDF4 I used a combination of BinaryRead and BinaryReadList to directly access the HDF4 file in order to read VData sets, which are also not yet supported in V8. The HDF5 file data format is relatively welll documented and together with h5dump and some peeks into the source code of the C or fortran interface files you might be able to figure out how to do it on the binary file level. Check out the HDF4 package as a (very crude) example/reference.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.