我可以在HDF5 Python中有属性的组吗?

发布于 2025-02-04 17:39:49 字数 1095 浏览 3 评论 0原文

我目前正在使用多个级别的数据。假设数据水平(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文