Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

blosc compression in hdf5 via h5py

Tags:

python

hdf5

h5py

I'm using h5py to create hdf5 files in python, and I'd like to use blosc as a compression filter. I first installed c-blosc from source via:

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

(note I use homebrew otherwise, so my /usr/local is writable without sudo)

I then installed hdf5 v1.10.0 from source via:

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

Finally I install h5py v2.6.0 from source via:

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

However, when I fire up a python interpreter and run:

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

I get the error "ValueError: Unknown compression filter number: 32001". What have I missed in my installation stream?

like image 963
Mike Lawrence Avatar asked Oct 19 '22 08:10

Mike Lawrence


1 Answers

I found that the easiest way to get this working is to install pytables and load that at the outset of your python script. You don't need to use pytables at all afterwards, but loading it clearly calls something that registers the blosc filter.

like image 88
Mike Lawrence Avatar answered Oct 21 '22 04:10

Mike Lawrence