2

I am creating an h5 files with 5 datasets ['a160'],['a1214']

How can I make it so that the datasets will be sorted by the dataset name..

For example when I do h5dump on my file I get:

HDF5 "jjjj.h5" {
GROUP "/" {
   DATASET "a1214" {
      DATATYPE  H5T_IEEE_F32BE
      DATASPACE  SIMPLE { ( 1, 19 ) / ( H5S_UNLIMITED, 19 ) }
      DATA {
      (0,0): 160, 0, 165, 4, 2.29761, 264, 4, 1.74368, 1, 0, 17, 193, 0, 0,
      (0,14): 0, 0, 0, 0, 0
      }
   }
   DATASET "a160" {
      DATATYPE  H5T_IEEE_F32BE
      DATASPACE  SIMPLE { ( 3, 19 ) / ( H5S_UNLIMITED, 19 ) }
      DATA {
      (0,0): 263, 0, 262, 7, 4.90241, 201, 34, 0.348432, 1, 0, 29, 11, 0, 0,
      (0,14): 0, 0, 0, 0, 0,
      }
   }

But I want it to be ordered by the dataset name, I need h5dump to output

HDF5 "jjjj.h5" {
GROUP "/" {
   DATASET "a160" {
      DATATYPE  H5T_IEEE_F32BE
      DATASPACE  SIMPLE { ( 3, 19 ) / ( H5S_UNLIMITED, 19 ) }
      DATA {
      (0,0): 263, 0, 262, 7, 4.90241, 201, 34, 0.348432, 1, 0, 29, 11, 0, 0,
      (0,14): 0, 0, 0, 0, 0,
      }
   }

   DATASET "a1214" {
      DATATYPE  H5T_IEEE_F32BE
      DATASPACE  SIMPLE { ( 1, 19 ) / ( H5S_UNLIMITED, 19 ) }
      DATA {
      (0,0): 160, 0, 165, 4, 2.29761, 264, 4, 1.74368, 1, 0, 17, 193, 0, 0,
      (0,14): 0, 0, 0, 0, 0
      }
   }
}
4

1 回答 1

1

默认情况下h5dump,按名称升序对 HDF5 文件的组和属性进行排序:

-q Q, --sort_by=Q    Sort groups and attributes by index Q
-z Z, --sort_order=Z Sort groups and attributes by order Z

Q - is the sort index type. It can be "creation_order" or "name" (default)
Z - is the sort order type. It can be "descending" or "ascending" (default)

这种情况下的问题是“a160”被认为大于“a1214”,因为这就是字典排序的工作原理('a12' < 'a16')。

您无法对 HDF5 文件的内部结构进行任何更改,以强制h5dump以不同的顺序对这些数据结构进行排序。但是,您可以像这样对您的姓名进行零填充:

a0040
a0160
a1214

然后标准字典排序将以您想要的方式输出文件。

于 2014-05-01T21:24:51.273 回答