“Hdf5”的版本间差异
跳到导航
跳到搜索
无编辑摘要 |
无编辑摘要 |
||
第12行: | 第12行: | ||
:http://www.exelisvis.com/docs/HDF5_Overview.html |
:http://www.exelisvis.com/docs/HDF5_Overview.html |
||
:http://hdfeos.org/examples/idl_local_mls_swath.php |
:http://hdfeos.org/examples/idl_local_mls_swath.php |
||
==python== |
|||
===h5py=== |
|||
import h5py |
|||
#打开HDF5文件: |
|||
file = h5py.File('example.h5', 'r') |
|||
#查看文件中的组和数据集: |
|||
groups = list(file. Keys()) |
|||
datasets = [name for name in file if isinstance(file[name], h5py.Dataset)] |
|||
print('Groups:', groups) |
|||
print('Datasets:', datasets) |
|||
#读取数据集: |
|||
dataset = file['data'] |
|||
data = dataset[:] |
|||
print('Data shape:', data. Shape) |
|||
print('Data:', data) |
|||
#关闭文件: |
|||
file. Close() |
|||
===pandas=== |
|||
import pandas as pd |
|||
data = pd.read_hdf('example.h5', key='data') |
|||
print(data) |
2025年9月11日 (四) 00:44的最新版本
The Hierarchical Data Format (HDF) version 5 file format was designed for scientific data consisting of a hierarchy of datasets and attributes (or metadata). HDF is a product of the National Center for Supercomputing Applications (NCSA), which supplies the underlying C-language library;
IDL
- IDL provides access to this library via a set of procedures and functions contained in a dynamically loadable module (DLM).
IDL>HELP, 'hdf5', /DLM
- 查看Hdf5的文件结构,并直接读取
IDL>file=h5_parse(filename,/read_data) ;IDL 7.1 IDL>file=h5_browser(filename) ;可视化界面
- pro: H5F_open,H5D_open,H5D_read,H5D_CLOSE
python
h5py
import h5py #打开HDF5文件: file = h5py.File('example.h5', 'r') #查看文件中的组和数据集: groups = list(file. Keys()) datasets = [name for name in file if isinstance(file[name], h5py.Dataset)] print('Groups:', groups) print('Datasets:', datasets) #读取数据集: dataset = file['data'] data = dataset[:] print('Data shape:', data. Shape) print('Data:', data) #关闭文件: file. Close()
pandas
import pandas as pd data = pd.read_hdf('example.h5', key='data') print(data)