C#读取HDF5文件.doc

来源:互联网 发布:ubuntu全中文包 编辑:程序博客网 时间:2024/05/16 12:52

C#读取HDF5文件

1 访问HDF NET 官方网站:http://hdf5.net/default.aspx

2 下载DotNet版本,以64位的操作系统为例,下载对应的64位的程序集。

 

得到以下五个程序集:

hdf5_hldll.dll

hdf5dll.dll

HDF5DotNet.dll

szip.dll

zlib.dll

 

3 安装HDF5-1.8.15-win64.msi,安装编译获取编译好的DLL(也可以官网直接下载编译好的),如下图:

一共7个DLL

 

其中,HDF5DotNet.dll需要添加引用到项目中,其余放入项目debug目录下即可

 

示例:直接调用就可以了。。。

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using HDF5DotNet;

 

namespace Rhdf5test

{

    class GetHdf5DataSet

    {

        //获取文件中的群

        public string[] hdf5_getDataSet(stringfileName)

        {

            H5FileIdfileId = H5F.open(fileName, H5F.OpenMode.ACC_RDONLY);

            H5GroupIdgroupId =H5G.open(fileId, "/");

            ulongnum_objs = (ulong)H5G.getNumObjects(groupId);

            intnum = Convert.ToInt32(num_objs);

            string[]dataNames = new string[num];

 

            ulongidxi = 0;

            for(int i = 0; i < num; i++)

            {

                idxi = (ulong)i;

                stringname = H5G.getObjectNameByIndex(groupId,idxi);

                dataNames[i] = name;

            }

 

            H5G.close(groupId);

            H5F.close(fileId);

            returndataNames;

        }

        static void Main(string[] args)

        {

            Console.Write("begin..." +"\n");

            GetHdf5DataSetgetData =new GetHdf5DataSet();

            string[]groupNames = getData.hdf5_getDataSet("NOAA18_AVHRR_20060501_OLR.HDF");

 

            for(int i = 0; i < groupNames.Length; i++)

            {

                Console.Write(groupNames[i]+"\n");

            }

 

            Console.Write("finish...");

            Console.ReadLine();

        }

    }

}

 

0 0