我是否使用HDF5DotNet是在Windows 10上的HDF5文件中的组中查找数据集的正确方法?

时间:2019-01-15 02:12:05

标签: c# .net hdf5 hdf5dotnet

(我是HDF5的新手)

我的问题是,尽管找到了对象组“ XY”,但没有在组“ XY”内找到对象数据集“ xyz”。

Windows 10 64位上的

C#.NET。

代码...…………

            static ObjectInfo info;
        static H5FileId fileId;
        static long[] dims ;
        static H5GroupId groupId;

public static void test_read( string HDF5_path)
{
        const int RANK = 2;

    try
    {

         dims = new long[RANK];


        // Open everything:
            var HDF5_filename = "heatmapB.h5";
            var test_pathname = HDF5_path + HDF5_filename;
            fileId = H5F.open( test_pathname,   H5F.OpenMode.ACC_RDONLY);          // OPEN HDF5 FILE.  WORKS OK.

            // Open the group...
                groupId = H5G.open( fileId, "/XY");                     // SELECT GROUP "XY".  WORKS OK.
                // Show datasets:
                    dump_HDF5_file(  "xyz" );

                    . . .



public static void dump_HDF5_file(  string object_name )
{
    try
    {


            info = H5G.getObjectInfo( fileId, object_name, true);   // Generates ERROR :  "Failed to get info for name "xyz" in object 1000001"  <<<<<<<<<<<<<<
        Console.WriteLine("cSharpGroup header size is {0}", info.headerSize);
        Console.WriteLine("cSharpGroup nlinks is {0}", info.nHardLinks);
        Console.WriteLine("cSharpGroup fileno is {0} {1}",                  info.fileNumber[0], info.fileNumber[1]);
        Console.WriteLine("cSharpGroup objno is {0} {1}",                   info.objectNumber[0], info.objectNumber[1]);
        Console.WriteLine("cSharpGroup type is {0}", info.objectType);
        Console.WriteLine("cSharpGroup modificationTime  is {0}", info.modificationTime );
    }
    catch (HDFException e)
    {
        Console.WriteLine(e.Message);   //////////////    ERROR IS:  "Failed to get info for name "xyz" in object 1000001"  <<<<<<<<<<<<<<
    }
}       

1 个答案:

答案 0 :(得分:0)

问题是HDF5文件未正确写入。 解决方案是让使用Julia(一种编程语言)编写文件的人使用Python读回它来验证它,以确保它是预期的HDF5结构。

现在我可以用HDF5DotNot OK读取它了。