12-01-2012 02:10 PM
I'm having a problem figuring out how to to a partial read of an HDF5 dataset using LVHDF5 by Jason S. I can save a dataset in a file, and I can read it out whole, but I can't figure out how to read a portion of it. For example
:
I save a 235x235x1024 dataset in a file. I want to read a 5x5x1024 array from this dataset. I am trying the following:
- use H5Dopen.vi to open the dataset
- use H5Dget_space.vi to get a reference to a dataspace that I assume (guess) is the dataspace associated w/ the dataset
- use H5Sselect_hyperslab.vi to select my 5x5x1024 portion using the "block" input. My starting location is 0,0,0 and stride and count are 1,1,1
- use Create Matching DataSpace.vi to create a dataspace that is 5x5x1024 in size, with the same datatype as my dataset (float).
- read the data in the "hyperslab" into an array using H5Dread.vi followed by the Variant to Data function.
If I don't wire the file space input, H5Dread.vi reads the whole dataset. However, if I try to use the reference obtained w/ H5Dget_space.vi as the file space, I get an error from Variant to Data that says "The data type of the variant is not compatible with the data type wired to the type input.".
I would appreciate any help in getting this to work.
Solved! Go to Solution.
12-01-2012 02:29 PM
Aha. I found my problem. I have to use H5Dselect_hyperslab in my memory space as well as my file space.