Ejemplo n.º 1
0
        private void createHD5GroupObject(H5GroupId id, String name, ref HDF5GroupObject hdf5Obj)
        {
            hdf5Obj.GroupID   = id;
            hdf5Obj.GroupName = name;

            long num = H5G.getNumObjects(hdf5Obj.GroupID);

            // the items under the group
            for (ulong i = 0; i < (ulong)num; i++)
            {
                String objName = H5G.getObjectNameByIndex(hdf5Obj.GroupID, i);

                // get the link info.
                //linfo = H5L.getInfo(groupID, objName);

                ObjectInfo objInfo = H5G.getObjectInfo(hdf5Obj.GroupID, objName, true);
                if (objInfo.objectType == H5GType.GROUP)
                {
                    String pathName = "/" + name + "/" + objName;
                    if (name.CompareTo("/") == 0)
                    {
                        pathName = "/" + objName;
                    }
                    H5GroupId groupID = null;
                    try
                    {
                        groupID = H5G.open(hdf5Obj.GroupID, pathName);
                        HDF5GroupObject subObj = new HDF5GroupObject();
                        subObj.ShortName = objName;
                        createHD5GroupObject(groupID, pathName, ref subObj);
                        hdf5Obj.SubGroups.Add(subObj);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        if (groupID != null)
                        {
                            H5G.close(groupID);
                        }
                    }
                }
                else
                if (objInfo.objectType == H5GType.DATASET)
                {
                    String           pathName   = "/" + name + "/" + objName;
                    HD5DataSetObject dataObject = new HD5DataSetObject();
                    dataObject.ShortName = objName;
                    createHD5DataObject(hdf5Obj.GroupID, pathName, ref dataObject);
                    hdf5Obj.Datasets.Add(dataObject);
                }
            }
        }
Ejemplo n.º 2
0
        private void createHD5DataObject(H5GroupId h5GroupId, string pathName, ref HD5DataSetObject dataObject)
        {
            H5DataSetId   datasetid  = null;
            H5DataSpaceId spaceid    = null;
            H5DataTypeId  dataTypeid = null;

            try
            {
                dataObject.GroupId     = h5GroupId;
                datasetid              = H5D.open(h5GroupId, pathName);
                dataObject.DatasetID   = datasetid;
                dataObject.DatasetName = pathName;
                spaceid = H5D.getSpace(datasetid);
                var dims = H5S.getSimpleExtentDims(spaceid);
                dataTypeid     = H5D.getType(datasetid);
                dataObject.Dim = dims.Length;
                HDF5DotNet.H5T.H5TClass classType = H5T.getClass(dataTypeid);
                int      size = H5T.getSize(dataTypeid);
                H5T.Sign sign = H5T.Sign.TWOS_COMPLEMENT;
                if (classType == H5T.H5TClass.INTEGER)
                {
                    sign = H5T.getSign(dataTypeid);
                }
                //var rank = H5S.getSimpleExtentNDims(space);
                //var statu = H5S.getSimpleExtentDims(space);
                Boolean bString = H5T.isVariableString(dataTypeid);
                //String name = H5T.getMemberName(dataType, 0);
                // var type2 = H5T.getNativeType(dataType, H5T.Direction.DEFAULT);
                Type type = getTypeof(classType, size, sign);
                dataObject.DataType = type;
                dataObject.Data     = readData(dataObject);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally{
                if (datasetid != null)
                {
                    H5D.close(datasetid);
                }
                if (spaceid != null)
                {
                    H5S.close(spaceid);
                }
                if (dataTypeid != null)
                {
                    H5T.close(dataTypeid);
                }
            }
        }
Ejemplo n.º 3
0
        public static Object readData(HD5DataSetObject dataObject)
        {
            H5GroupId h5GroupId = dataObject.GroupId;
            string    pathName  = dataObject.DatasetName;
            int       dimension = dataObject.Dim;
            Type      type      = dataObject.DataType;

            if (dimension == 1)
            {
                if (type == typeof(UInt16))
                {
                    return(Read1DArray <UInt16>(h5GroupId, pathName));
                }
                if (type == typeof(UInt32))
                {
                    return(Read1DArray <UInt32>(h5GroupId, pathName));
                }
                if (type == typeof(UInt64))
                {
                    return(Read1DArray <UInt64>(h5GroupId, pathName));
                }
                if (type == typeof(Int16))
                {
                    return(Read1DArray <Int16>(h5GroupId, pathName));
                }
                if (type == typeof(Int32))
                {
                    return(Read1DArray <Int32>(h5GroupId, pathName));
                }
                if (type == typeof(Int64))
                {
                    return(Read1DArray <Int64>(h5GroupId, pathName));
                }
                if (type == typeof(float))
                {
                    return(Read1DArray <float>(h5GroupId, pathName));
                }
                if (type == typeof(double))
                {
                    return(Read1DArray <double>(h5GroupId, pathName));
                }
            }
            if (dimension == 2)
            {
                if (type == typeof(UInt16))
                {
                    return(Read2DArray <UInt16>(h5GroupId, pathName));
                }
                if (type == typeof(UInt32))
                {
                    return(Read2DArray <UInt32>(h5GroupId, pathName));
                }
                if (type == typeof(UInt64))
                {
                    return(Read2DArray <UInt64>(h5GroupId, pathName));
                }
                if (type == typeof(Int16))
                {
                    return(Read2DArray <Int16>(h5GroupId, pathName));
                }
                if (type == typeof(Int32))
                {
                    return(Read2DArray <Int32>(h5GroupId, pathName));
                }
                if (type == typeof(Int64))
                {
                    return(Read2DArray <Int64>(h5GroupId, pathName));
                }
                if (type == typeof(float))
                {
                    return(Read2DArray <float>(h5GroupId, pathName));
                }
                if (type == typeof(double))
                {
                    return(Read2DArray <double>(h5GroupId, pathName));
                }
            }

            if (dimension == 3)
            {
                if (type == typeof(UInt16))
                {
                    return(Read3DArray <UInt16>(h5GroupId, pathName));
                }
                if (type == typeof(UInt32))
                {
                    return(Read3DArray <UInt32>(h5GroupId, pathName));
                }
                if (type == typeof(UInt64))
                {
                    return(Read3DArray <UInt64>(h5GroupId, pathName));
                }

                if (type == typeof(Int16))
                {
                    return(Read3DArray <Int16>(h5GroupId, pathName));
                }
                if (type == typeof(Int32))
                {
                    return(Read3DArray <Int32>(h5GroupId, pathName));
                }
                if (type == typeof(Int64))
                {
                    return(Read3DArray <Int64>(h5GroupId, pathName));
                }
                if (type == typeof(float))
                {
                    return(Read3DArray <float>(h5GroupId, pathName));
                }
                if (type == typeof(double))
                {
                    return(Read3DArray <double>(h5GroupId, pathName));
                }
            }
            return(null);
        }