Mathematica HDF5 和复合数组
有人在 Mathematica 中有解决方法来读取 HDF5 复合数组吗?我在表中有一个简单的 2D 复合类型(int/float),但它目前被忽略。
HDF5 类型的示例可能是:
DATATYPE H5T_COMPOUND {
H5T_IEEE_F32LE "X";
H5T_IEEE_F32LE "Y";
}
Does anybody have a workaround in Mathematica for reading HDF5 compound arrays? I have a simple 2D compound type (int/float) in a table but it is currently ignored.
An example HDF5 type might be:
DATATYPE H5T_COMPOUND {
H5T_IEEE_F32LE "X";
H5T_IEEE_F32LE "Y";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一个包,显然是由 Scot Martin 此处 创建的。
据我所知,它实现了许多 HDF5 功能,包括复合类型。
以下是包中
11 HDF5HighLevel Examples.nb
的简短片段:HTH!
There is a package, apparently created by Scot Martin here.
As far as I can see, it implements a lot of the HDF5 functionality, including Compound Types.
Here is a brief snippet from
11 HDF5HighLevel Examples.nb
in the package:HTH!
似乎版本 8 仍然忽略复合数据类型。但是,从第 8 版开始,另一种方法可能是创建一个 导入转换器可以加载复合数据类型。这可能意味着您将不得不重新实现 HDF5 导入器,但我还没有尝试过。我仍在使用 7,但我长期以来一直想要这种类型的功能。
It appears that version 8 still ignores compound data types. However, as of v. 8, an alternative may be to create an Import Converter that can load in compound data types. This may mean you will have to implement the HDF5 importer all over again, but I haven't tried it. I am still using 7, but I've wanted this type of functionality for a long time.
我创建了
h5dumpImport
,这是一个开源 Mathematica 包,它提供了一种独立于平台的方式来导入具有复合数据类型的 HDF5 (.h5) 文件数据集,同时隐藏了大部分 HDF5 实现用户。包含文档、示例和单元测试的包位于此处。目前,
h5dumpImport
包不直接导入 HDF5 (.h5) 文件格式。h5dumpImport
包导入由h5dump
命令行工具生成的数据集的 ASCII 转储。HDF5 软件的源代码和预构建的二进制发行版(包括
h5dump
命令行工具)可以在 HDF Group 的 网站。基本示例
结果:
详细的安装说明、使用信息以及文档、示例和单元测试可以在此处找到。
I have created
h5dumpImport
, an open source Mathematica Package that provides a platform independent way to import HDF5 (.h5) file's datasets with compound datatypes while hiding much of the HDF5 implementation from the user. The package with documentation, examples, and unit test is located here.Currently, the
h5dumpImport
package does not directly import the HDF5 (.h5) file format. Theh5dumpImport
package imports an ASCII dump of a dataset generated by theh5dump
command line tool.Source code and pre-built binary distributions of the HDF5 Software which includes the
h5dump
command line tool can be found at the The HDF Group's website.Basic Example
Results:
Detailed installation instructions, usage information, and documentation, examples, and unit tests can be found here.
从版本 11.1 开始,HDF5 文件的导入可以处理复合类型(甚至嵌套),并将它们转换为关联。
示例文件
ExampleData/sample2.h5
包含名为/Compound
的数据集,其中包含 2x2 复合元素矩阵。您可以像这样导入数据:要了解有关特定数据集的复合数据类型的更多信息,您可以检查
DataFormat
元素:Starting from version 11.1 Import of HDF5 files can handle compound types (even nested) and they are translated to Associations.
A sample file
ExampleData/sample2.h5
contains a dataset named/Compound
with a 2x2 matrix of compound elements. You can import the data like this:To learn more about the compound datatype for specific dataset, you may examine the
DataFormat
element: