how to specify a custom compression filter in h5py

落花浮王杯 提交于 2019-12-08 04:32:36

问题


According to they h5py documentation, "compression filters can be dynamically loaded by the underlying HDF5 library. This is done by passing a filter number to Group.create_dataset() as the compression parameter." I have the following code (which works fine):

import numpy as np
a = np.random.random(1e5)
with h5py.File(args.baseName + '/allubf.h5', libver='latest') as f:
    dset = f.create_dataset('myData', (1000,), dtype=np.dtype(float), chunks=(1000,), compression='lzf', shuffle=True)

I looked up compression filter IDs here and tried to replace 'lzf' with 32000, which should be the ID for lzf according to the above link. When I do that, I get the error ValueError: Compression filter "32000" is unavailable. I can't find any more documentation or examples for this. Do I need to somehow pre-load the filter in order to make it available?


回答1:


It appears the documentation is ahead of the released library. This feature is available on the GitHub repository but is not yet available in the pypi version (this is one you have if you used easy_install or pip to install h5py). If you want to use custom compression filters you will either have to use the version from GitHub, wait for the pypi version to be updated, or apply this set of changes.



来源:https://stackoverflow.com/questions/26049670/how-to-specify-a-custom-compression-filter-in-h5py

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!