data.h5py.H5Converter¶
Class ยท Source
converter = mdnc.data.h5py.H5Converter(
file_name, oformat, to_other=True
)
Conversion between HDF5 data and other formats. The "other formats" would be arranged in to form of several nested folders and files. Each data group would be mapped into a folder, and each dataset would be mapped into a file.
Warning
When the argument to_other
is True
, the data would be converted to other formats. During this process, attributes would be lost, and the links and virtual datasets would be treated as h5py.Datasets
.
Arguments¶
Requries
Argument | Type | Description |
---|---|---|
file_name | str | A path where we find the dataset. If the conversion is from h5 to other, the path should refer a folder containing several subfiles, otherwise, it should refer an HDF5 file. |
oformat | object | The format function for a single dataset, it could be provided by users, or use the default configurations (str ). (avaliable: 'txt' , 'bin' .) |
to_other | bool | The flag for conversion mode. If set True, the mode would be h52other, i.e. an HDF5 set would be converted into other formats. If set False, the conversion would be reversed. |
Tip
The argument oformat
could be a user defined custome object. It should provide two methods: read()
and write()
. An example of txt
IO is shown as below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
Methods¶
convert
¶
converter.convert()
Perform the data conversion.
Examples¶
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
data.webtools: All required datasets are available.
data.h5py: Have dumped /group1/x
data.h5py: Have dumped /group1/y
data.h5py: Have dumped /group2/group3/x
data.h5py: Have dumped /group2/group3/y
data.h5py: Have dumped /group2/x
data.h5py: Have dumped /group2/y
data.h5py: Have dumped /vds
data.h5py: Have dumped /x
data.h5py: Have dumped /y
data.h5py: Have dumped /group1/x
data.h5py: Have dumped /group1/y
data.h5py: Have dumped /group2/group3/x
data.h5py: Have dumped /group2/group3/y
data.h5py: Have dumped /group2/x
data.h5py: Have dumped /group2/y
data.h5py: Have dumped /vds
data.h5py: Have dumped /x
data.h5py: Have dumped /y
Last update: March 14, 2021