通过h5py在hdf5中进行blosc压缩

问题描述 投票:3回答:2

我正在使用h5py在python中创建hdf5文件,我想使用blosc作为压缩过滤器。我首先从源代码安装了c-blosc:

wget https://github.com/Blosc/c-blosc/archive/v1.9.1.tar.gz
tar -xvf c-blosc-v1.9.1.tar.gz
cd c-blosc-v1.9.1
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
cmake --build .
cmake --build . --target install

(注意我使用自制软件,所以我的/ usr / local是可写的,没有sudo)

然后我从源代码安装了hdf5 v1.10.0:

wget http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.0/src/hdf5-1.10.0.tar.gz
tar -xvf hdf5-1.10.0.tar.gz
cd hdf5-1.10.0
./configure --enable-static=yes --enable-shared=yes --prefix=/usr/local/hdf5
make && make install

最后我从源代码安装h5py v2.6.0:

wget https://github.com/h5py/h5py/archive/2.6.0.tar.gz
tar -xvf h5py-2.6.0.tar.gz
cd h5py-2.6.0
python setup.py install
python setup.py install

但是,当我启动python解释器并运行时:

import h5py
f = h5py.File('myFile.hdf5','w')
dset = f.create_dataset("myData", (100, 100), compression=32001) 
#32001 is blosc, see: https://www.hdfgroup.org/services/filters.html

我收到错误“ValueError:Unknown compression filter number:32001”。我在安装流中错过了什么?

python hdf5 h5py
2个回答
3
投票

我发现最简单的方法是安装pytables并在python脚本的开头加载它。之后您根本不需要使用pytables,但是加载它会清楚地调用注册blosc过滤器的东西。


1
投票

import h5py之前

你需要import tables

© www.soinside.com 2019 - 2024. All rights reserved.