- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试向数据集中添加 unsigned long long 属性时,会添加该属性,但不会添加值。对整数使用类似的方法似乎可以工作文件。
我使用 HDF View 来查看属性。显示属性名称,但对于 unsigned long long 属性,值不可见
代码如下:
herr_t Result;
//Open the file
hid_t DataFile = H5Fopen(FileName, H5F_ACC_RDWR, H5P_DEFAULT);
//Open the dataset
hid_t DataSet = H5Dopen2(DataFile, "/Summary", H5P_DEFAULT);
//Create the data space for the attribute.
hsize_t AttributeDims = 1;
hid_t AttributeDataSpace = H5Screate_simple(1, &AttributeDims , NULL);
hid_t Attribute;
//Attribute 1: Fail to write a long long attribute
Attribute = H5Acreate2 (DataSet, "LongAttribute", H5T_STD_U64BE, AttributeDataSpace, H5P_DEFAULT, H5P_DEFAULT);
if (Attribute < 0) {
fprintf(stdout, "Failed to add the unsigned long long attribute to the file %s.", FileName);
return false;
}
//Write the attribute data
unsigned long long* ULLAttribute = (unsigned long long*) malloc(sizeof(unsigned long long) * 1);
ULLAttribute[0] = (unsigned long long) 4;
Result = H5Awrite(Attribute, H5T_NATIVE_ULLONG, ULLAttribute);
if (Result < 0) {
fprintf(stdout, "Failed to write the unsigned long long attribute to the file %s.", FileName);
return false;
}
//Attribute 2: Succesfully Write a integer attribute
Attribute = H5Acreate2 (DataSet, "IntAttribute", H5T_STD_I32BE, AttributeDataSpace, H5P_DEFAULT, H5P_DEFAULT);
if (Attribute < 0) {
fprintf(stdout, "Failed to create the attribute for the file %s.", FileName);
return false;
}
//Write the attribute data
int32_t* IAttribute = (int32_t*) malloc(sizeof(int32_t) * 1);
IAttribute[0] = (int32_t) 4;
Result = H5Awrite(Attribute, H5T_NATIVE_INT, IAttribute);
if (Result < 0) {
fprintf(stdout, "Failed to add the integer attribute to the file %s.", FileName);
return false;
}
//Close the attribute, Dataset and DataFile
Result = H5Aclose(Attribute);
Result = H5Dclose(DataSet);
Result = H5Fclose(DataFile);
执行代码时没有显示错误消息,但查看HDF5文件时,“IntAttribute”和“LongAttribute”属性均可见,但LongAttribute没有值。
Intel 64 上的 HFView 2.9、Fedora 20。
挑选蒂莫西的一些问题写: 您为什么要为属性创建一个简单的数据空间?我正在考虑将模型参数存储为属性,有点像键值对。许多模型参数都是简单的标量值。
写: 按照同样的思路,你为什么要为属性编写一个数组?我编辑了一个示例,它在数组中存储了 2 个值。我从你的例子中看到,你已经对空间进行了 malloc() 处理,从现在开始我将使用它,因为它看起来更清楚。
写: 您使用的是 Intel 64,但您想编写大端字节序吗?是的:这仍然让我困惑:H5T_STD_I32BE 和 H5T_STD_I32LE 都成功工作,但 H5T_STD_U64BE 和 H5T_STD_U64LE 在 HDFView 中都没有显示值。我猜想 HDF5 库中的某个地方会检查大端和小端,并相应地处理该值,而不管参数如何。稍后我会尽量避免使用 Postgresql 二进制数来绊倒这个“功能”,这些二进制数始终是大端值。
问题似乎出在 HDFView 中,它仍然没有显示 Timothy 代码生成的 ull.h5 文件中的 unsigned long long,或者来 self 的代码:
我正在使用适用于 Linux 的 HDFView 2.9。正如 Timothy 提到的,这在 HDFView 2.10 中有效,同时我将使用 h5dump。
最佳答案
几个问题,应该没问题,但我只是好奇。
这是使用标量数据空间编写属性的简单示例:
#include <stdio.h>
#include <stdlib.h>
#include <hdf5.h>
int
main(int argc, char **argv)
{
unsigned long long *ull = NULL;
hid_t f_id = {0};
hid_t d_id = {0};
hid_t s_id = {0};
hid_t a_id = {0};
hid_t as_id = {0};
hsize_t dims[2] = {2, 2};
herr_t status = {0};
f_id = H5Fcreate("ull.h5",H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
s_id = H5Screate_simple(2, dims, NULL);
d_id = H5Dcreate(f_id, "/data", H5T_STD_I32BE, s_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
as_id = H5Screate(H5S_SCALAR);
a_id = H5Acreate(d_id, "unsigned long long", H5T_STD_U64LE,
as_id, H5P_DEFAULT, H5P_DEFAULT);
ull = malloc(sizeof(unsigned long long));
*ull = 123;
status = H5Awrite(a_id, H5T_NATIVE_ULLONG, ull);
status = H5Aclose(a_id);
status = H5Dclose(d_id);
status = H5Sclose(s_id);
status = H5Fclose(f_id);
return(EXIT_SUCCESS);
}
编译并运行时:
h5pcc -o test test.c && ./test && h5dump ull.h5
我觉得很好:
HDF5 "ull.h5" {
GROUP "/" {
DATASET "data" {
DATATYPE H5T_STD_I32BE
DATASPACE SIMPLE { ( 2, 2 ) / ( 2, 2 ) }
DATA {
(0,0): 0, 0,
(1,0): 0, 0
}
ATTRIBUTE "unsigned long long" {
DATATYPE H5T_STD_U64LE
DATASPACE SCALAR
DATA {
(0): 1234
}
}
}
}
}
当然,如果我将标量属性数据空间更改为简单数据空间,它仍然有效:
as_id = H5Screate_simple(1, adims, NULL);
a_id = H5Acreate(d_id, "unsigned long long", H5T_STD_U64LE,
as_id, H5P_DEFAULT, H5P_DEFAULT);
ull = malloc(sizeof(unsigned long long));
*ull = 123;
我们得到:
ATTRIBUTE "unsigned long long" {
DATATYPE H5T_STD_U64LE
DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
DATA {
(0): 123
}
在一个冗长的示例说明如何完成之后。看了你的代码,实在找不到你的错误。事实上,在空 HDF5 文件上使用您的代码是可行的:
localhost ~$ h5dump ull.h5
HDF5 "ull.h5" {
GROUP "/" {
DATASET "Summary" {
DATATYPE H5T_STD_I32BE
DATASPACE SIMPLE { ( 2, 2 ) / ( 2, 2 ) }
DATA {
(0,0): 0, 0,
(1,0): 0, 0
}
}
}
}
localhost ~$ ./foo
localhost ~$ h5dump ull.h5
HDF5 "ull.h5" {
GROUP "/" {
DATASET "Summary" {
DATATYPE H5T_STD_I32BE
DATASPACE SIMPLE { ( 2, 2 ) / ( 2, 2 ) }
DATA {
(0,0): 0, 0,
(1,0): 0, 0
}
ATTRIBUTE "IntAttribute" {
DATATYPE H5T_STD_I32BE
DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
DATA {
(0): 4
}
}
ATTRIBUTE "LongAttribute" {
DATATYPE H5T_STD_U64BE
DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
DATA {
(0): 4
}
}
}
}
}
你能检查(并发布)h5dump
给你的内容吗?也许这只是使用 HDFView 的问题?
更新
我刚刚用 HDFView(版本 2.10)查看了该文件,看起来没问题。
您能确认/重现您的错误吗?
关于c - HDF5 属性 unsigned long long 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27243947/
只是想知道我对组/数据集名称的自由程度如何,或者是否需要使名称简短(因此可读性较差)。这适用于包含许多具有许多重复名称的组和数据集的 HDF5 文件。一些 XML API 做 string inter
简短问题 当 Pandas 在 HDFStore 上工作时(例如: .mean() 或 .apply() ),它是否将内存中的完整数据作为 DataFrame 加载,还是将记录作为 Serie 进行处
我有几个不同的相关数据框(如果需要,可以使用 id 加入它们)。但是,我并不总是同时需要它们。 由于它们非常大,将它们存储在单独的 HDF 存储中是否有意义?或者当我处理同一文件中的其他帧时,携带“未
我似乎无法让它发挥作用。所有示例和线程都让人创建新的数据集。我只想更新已创建的数据集中的一个字段。 这是我所拥有的: h5_file = h5py.File(event_file_path, "r+"
我在 hadoop 上写入小文件时遇到一个奇怪的问题。下面是示例程序 public void writeFile(Configuration conf, String message, String
当我运行 hdf namenode -format 时,它想要删除目录 /home/hadoop/hadooptmpdata/dfs/name/current 但它没有权限执行此操作。如何授予它权限?
有没有办法使用 pandas HDF 存储获取 HDF 表的信息? 例如在 SQL 中有: SELECT COUNT(*) 我想阅读基本表格大小而不必自己加载表格。 最佳答案 试试这个: In [4]
在 pandas 下,每次我使用表格格式而不是固定格式时,我的内存消耗都会爆炸。 import numpy as np np.random.seed(seed=10) df = pd.DataFram
我正在处理大量数据集,每个数据集都是一个 pandas DataFrame,由于它们的大小,我需要从磁盘访问它们。从我读到的内容来看,HDF 似乎是与它们一起工作的好方法,但我对构建数据的最佳方法有点
我正在开发云服务器,我需要使用 blob 存储来存储 HDF 文件 ( http://www.hdfgroup.org/HDF5/ )。 与文件中的创建、读取、写入和修改数据元素相关的函数来自 HDF
我正在尝试将数据存储为 hdf 格式,并希望将默认数据类型设置为表,以便稍后查询。 我正在使用基本代码: import pandas as pd from numpy import random as
我最近在 Lubuntu 上安装了 Anacondas Python。 我正在尝试加载可在 Windows PC 上运行的 HDF 文件: In [14]: import pandas as pd I
我写了下面的脚本,但是我有一个内存消耗的问题,pandas 分配了超过 30 G 的内存,其中数据文件的总和大约是 18 G import pandas as pd import numpy as n
您好,我看到了一些以 HDF5 格式存储的科学数据,我想知道是否有任何 NoSQl 解决方案可以达到与 HDF5 相同的读/写性能。 我的示例的数据使用树结构(/root 然后/root/key 然后
我想知道如何获取 hdf 文件的列名(似乎存储在 hdf header 中);例如,一个文件可能有名为 [a,b,c,d] 的列,而另一个文件有 [a,b,c] 列,而另一个文件有 [b,e,r,z]
我想做什么? pd.read_csv(... nrows=###) 可以读取文件的前 n 行。我想在使用 pd.read_hdf(...) 时做同样的事情。 问题是什么? 我对 documentati
我想将数千张动物图像加载到 pandas df 中,添加特征并可能转换为 HDF。 我使用 cv2.imread() 尝试了以下方法 import cv2 import os import numpy
我想知道 HDF 套件中嵌入的 kafka 和 Confluence 套件中嵌入的 kafka 之间的差异,特别是模式注册工具。 最佳答案 https://registry-project.readt
我想知道 HDF 套件中嵌入的 kafka 和 Confluence 套件中嵌入的 kafka 之间的差异,特别是模式注册工具。 最佳答案 https://registry-project.readt
我使用 pandas 和 hdf5 文件来处理大量数据(例如 10GB 或更多)。我想使用表格格式,以便在读取数据时能够有效地查询数据。但是,当我想将数据写入 hdf 存储时(使用 DataFrame
我是一名优秀的程序员,十分优秀!