从v7.3*.mat文件加载数据。
hdf5matfile的Python项目详细描述
从v7.3*.mat文件加载数据。只支持阅读,不支持写作。在
使用
提供一个类Hdf5Matfile和一个方便函数load_hdf5mat。在
要从文件加载所有变量,请使用Hdf5Matfile.load_file:
withHdf5Matfile(filename)asfile:data=file.load_file()
要加载特定变量,请使用Hdf5Matfile.load_variable:
^{pr2}$如果不使用上下文管理器,请确保在 你完成了:
file=Hdf5Matfile(filename)data=file.load_file()file.close()
默认情况下,数组不会被压缩;因为MATLAB表示偶数标量 作为二维数组,这意味着你期望的标量将 事实是一一对应的np.ndarray公司. 您可以通过传递^{tt5}来更改此设置$ 致施工单位:
withHdf5Matfile(filename,squeeze=True)asfile:data=file.load_file()
支持的数据类型
数据类型的支持非常有限;这不是一个非常花哨的类。 支持的MATLAB数据类型,以及它们映射的Python对象或NumPy数据类型 收件人:
MATLAB type | Python object | NumPy dtype |
---|---|---|
cell | np.ndarray | object |
char | str | n/a |
double | np.ndarray | np.double |
int8 | np.ndarray | np.byte |
int16 | np.ndarray | np.short |
int32 | np.ndarray | np.intc |
int64 | np.ndarray | np.int_ |
logical | np.ndarray | bool8 |
single | np.ndarray | single |
struct (scalar) | dict | n/a |
struct (array) | np.ndarray | object (dict) |
uint8 | np.ndarray | np.ubyte |
uint16 | np.ndarray | np.ushort |
uint32 | np.ndarray | np.uintc |
uint64 | np.ndarray | np.uint |
- 项目
标签: