You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alexander edited this page Feb 11, 2019
·
3 revisions
Reading a dataset of any type and dimensions
This snippet reads a dataset from the specified file.
PrivateFunctionRead_dataset(ByValhdf5fileAsLong,ByValdsnameAsString)DimdsID=H5D.open(hdf5file,dsname,H5P.DEFAULT)DimspaceID=H5D.get_space(dsID)DimtypeID=H5D.get_type(dsID)Dimrank=H5S.get_simple_extent_ndims(spaceID)Dimdims(rank-1)AsULongDimmaxDims(rank-1)AsULongH5S.get_simple_extent_dims(spaceID,dims,maxDims)DimsizeData=H5T.get_size(typeID)Dimsize=sizeData.ToInt32()Dimbytearray_elements=1Fori=0Todims.Length-1bytearray_elements*=dims(i)NextDimdataBytes(bytearray_elements*CULng(size))AsByteDimpinnedArrayAsGCHandle=GCHandle.Alloc(dataBytes,GCHandleType.Pinned)H5D.read(dsID,typeID,H5S.ALL,H5S.ALL,H5P.DEFAULT,pinnedArray.AddrOfPinnedObject())pinnedArray.Free()Fori=0tobytearray_elements-1:Dimslice=dataBytes.Skip(i*size).Take(size).ToArray()Dimval=BitConverter.ToInt32(slice,0)' This line depends on the type of your datasetNextEndFunction