您的位置:首页 > 编程语言 > C#

C#读取HDF5文件.doc

2015-11-03 11:04 871 查看

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();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: