我可以在HDF5 Python中有属性的组吗?
我目前正在使用多个级别的数据。假设数据水平(DL) DL1 - > dl2-> DL3。
对于每个数据处理,每个处理步骤都有不同的属性(这些属性在根级别)。这些属性可能是git版本,处理代码版本等。
当我在DL2处时,我想从DL1保存属性,然后将其分组在下面,然后说['dl1_attribute'],然后在此上添加dl2属性。由于我有多个处理步骤,因此分组将是有益的。我可以在根级上嵌套分组的属性吗? 我看过几个示例,其中属性未嵌套,但是为HDF5中已经存在的定义嵌套数据集设置了属性。
例如,对于DL1,我的H5结构为
lvl1_file['Data/dataset1'] = somedataset
lvl1_file['Data/dataset2'] = someotherdataset
和属性为
lvl1_file.attrs['lvl1_git_branch'] ='temp_testing'
lvl1_file.attrs['l1tol2_version'] = '2.1a'
lvl1_fiel.attrs['aux_file_version'] = '10.1'
现在在lvl2上,我想将属性存储为
lvl2_file.attrs['l1attrs/lvl1_git_branch']='temp_testing'
lvl2_file.attrs['l1attrs/l1tol2_version']='2.1a'
lvl2_file.attrs['l1attrs/aux_file_version'] = '10.1'
并另外添加来自lvl2的新属性。
lvl2_file.attrs['l2attrs/lvl2_git_branch']='dev'
lvl2_file.attrs['l2attrs/l2tol3_version']='3.0a'
或者,如果我可以做一个很棒的嵌套词典。
I am currently working with multiple levels of data. Lets say Data levels (DL)
DL1 -> DL2 -> DL3.
For each of the data processing, There are different attributes (these are at root levels) for each of the processing steps. These attributes might be git versions, the processing code version, etc etc.
When i am at DL2, i want to save the attributes from DL1 and group it under lets say ['DL1_attribute'] and then add the DL2 attribute on top of this. Since i have multiple processing steps, grouping would be beneficial. Can i have nested grouped attributes at root level?
I have seen few examples where the attributes are not nested but attributes are set for the defined nested datasets that are already present in the hdf5.
For example, for DL1 i have the h5 structure as
lvl1_file['Data/dataset1'] = somedataset
lvl1_file['Data/dataset2'] = someotherdataset
and attributes as
lvl1_file.attrs['lvl1_git_branch'] ='temp_testing'
lvl1_file.attrs['l1tol2_version'] = '2.1a'
lvl1_fiel.attrs['aux_file_version'] = '10.1'
Now at lvl2 i want to store the attributes as
lvl2_file.attrs['l1attrs/lvl1_git_branch']='temp_testing'
lvl2_file.attrs['l1attrs/l1tol2_version']='2.1a'
lvl2_file.attrs['l1attrs/aux_file_version'] = '10.1'
and additionally add new attributes from lvl2.
lvl2_file.attrs['l2attrs/lvl2_git_branch']='dev'
lvl2_file.attrs['l2attrs/l2tol3_version']='3.0a'
Or if i could do a nested dictionary that would be great too,.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论