Hdf5

来自Shiyin's note
Shen讨论 | 贡献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
http://www.exelisvis.com/docs/HDF5_Overview.html
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)