### Create HDF5 Dataset with ZFP Compression Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Example of creating an HDF5 file and a dataset using the ZFP compression filter. This is a basic setup before applying specific ZFP modes. ```python f = h5py.File('test.h5', 'w') f.create_dataset( 'zfp', data=numpy.random.random(100), compression=hdf5plugin.Zfp()) f.close() ``` -------------------------------- ### Install hdf5plugin from source directory Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/install.rst.txt Install hdf5plugin from the source directory, allowing for custom build options. ```bash pip install . --no-binary hdf5plugin ``` -------------------------------- ### Install hdf5plugin from source Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/install.rst.txt Install hdf5plugin from source to enable compilation optimizations specific to your host machine. The [--user] flag is optional. ```bash pip install hdf5plugin --no-binary hdf5plugin [--user] ``` -------------------------------- ### Install hdf5plugin using pip Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/install.rst.txt Use this command to install the pre-built hdf5plugin package from PyPI. The [--user] flag is optional. ```bash pip install hdf5plugin [--user] ``` -------------------------------- ### Example of creating a Blosc compressed dataset with byte shuffle Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html This example, found within the help documentation for hdf5plugin.Blosc, shows how to create an HDF5 dataset compressed with Blosc using 'blosclz' codec, level 9, and byte-wise shuffle. ```python f = h5py.File('test.h5', 'w') f.create_dataset( 'blosc_byte_shuffle_blosclz', data=numpy.arange(100), **hdf5plugin.Blosc(cname='blosclz', clevel=9, shuffle=hdf5plugin.Blosc.SHUFFLE)) f.close() ``` -------------------------------- ### Read and display compressed data Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html This example demonstrates how to read data from a compressed HDF5 dataset and display it. ```APIDOC ## Read and display compressed data h5file = h5py.File("new_file_blosc_bitshuffle_lz4.h5", mode="r") imshow(h5file["/compressed_data"][()]) h5file.close() ``` -------------------------------- ### Compare file sizes Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html This command-line example shows how to compare the file sizes of a compressed HDF5 file created with hdf5plugin and an uncompressed version. ```APIDOC ## Compare file sizes !ls -sh new_file*.h5 ``` -------------------------------- ### Install hdf5plugin Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/presentation.html Install the hdf5plugin package using pip or conda. For Debian/Ubuntu, use the system package manager. ```bash pip3 install hdf5plugin # Or: conda install -c conda-forge hdf5plugin ``` ```bash apt-get install python3-hdf5plugin ``` -------------------------------- ### Build Documentation with Sphinx Source: https://hdf5plugin.readthedocs.io/en/latest/contribute.html Build the project's documentation using Sphinx. This involves running a setup script and then invoking Sphinx to generate HTML output. Ensure you are in the project root directory. ```bash python setup.py build PYTHONPATH=build/lib.--/ sphinx-build -b html doc/ build/html ``` -------------------------------- ### Write and Read Compressed Dataset with LZ4 Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html This example demonstrates writing a dataset compressed with LZ4 and then reading it back. Ensure hdf5plugin is imported to enable the LZ4 filter. ```python import numpy import h5py import hdf5plugin # Compression f = h5py.File('test.h5', 'w') f.create_dataset('data', data=numpy.arange(100), compression=hdf5plugin.LZ4()) f.close() # Decompression f = h5py.File('test.h5', 'r') data = f['data'][()] f.close() ``` -------------------------------- ### Install hdf5plugin Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html Install the hdf5plugin package using pip or conda. This is required to enable support for HDF5 compression filters not natively supported by libHDF5. ```bash %%bash pip3 install hdf5plugin ``` -------------------------------- ### Create a compressed dataset using Blosc Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html This example demonstrates how to create a compressed HDF5 dataset using the hdf5plugin library with Blosc compression, specifying the compression codec, level, and shuffle option. ```APIDOC ## Create a compressed dataset h5file = h5py.File("new_file_blosc_bitshuffle_lz4.h5", mode="w") h5file.create_dataset( "/compressed_data", data=data, **hdf5plugin.Blosc( cname='lz4', clevel=5, shuffle=hdf5plugin.Blosc.BITSHUFFLE), ) h5file.close() ``` -------------------------------- ### Browse HDF5 files with H5Glance Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Use H5Glance to browse HDF5 files. Ensure H5Glance is installed. ```python from h5glance import H5Glance # Browsing HDF5 files H5Glance("data.h5") ``` -------------------------------- ### Create HDF5 Dataset with Zstd Compression Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Example of creating an HDF5 file and a dataset using the Zstd compression filter with a specified compression level. Ensure the file is closed after creation. ```python f = h5py.File('test.h5', 'w') f.create_dataset( 'zstd', data=numpy.arange(100), compression=hdf5plugin.Zstd(clevel=22)) f.close() ``` -------------------------------- ### Write Compressed Dataset with LZ4 Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Example of writing a compressed dataset using h5py.Group.create_dataset with the hdf5plugin.LZ4 filter. ```APIDOC import numpy import h5py import hdf5plugin f = h5py.File('test.h5', 'w') f.create_dataset('data', data=numpy.arange(100), compression=hdf5plugin.LZ4()) f.close() f = h5py.File('test.h5', 'r') data = f['data'][()] f.close() ``` -------------------------------- ### Inspect HDF5 file content Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html This example shows how to use H5Glance to inspect the contents of an HDF5 file, including dataset information. ```APIDOC ## Inspect HDF5 file content H5Glance("new_file_blosc_bitshuffle_lz4.h5") ``` -------------------------------- ### Display hdf5plugin Build Configuration Source: https://hdf5plugin.readthedocs.io/en/latest/_downloads/594fcc4a4f6d40f9213ff2f85f815f91/benchmark.ipynb Prints the Python version and detailed build configuration of the hdf5plugin library. This is useful for verifying the installed version and its features. ```python import os import sys print('Python:', sys.version) config = hdf5plugin.get_config() print(f"""hdf5plugin: * Version: {hdf5plugin.version} * Build config: {''' '''.join(f' - {k}: {v}' for k, v in config.build_config._asdict().items())} """) ``` -------------------------------- ### Get HDF5 Plugin Build Configuration Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Provides information about the build configuration and filters registered by the hdf5plugin library. ```python import hdf5plugin config = hdf5plugin.get_config() print(config) ``` -------------------------------- ### Display HDF5Plugin Information Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/benchmark.html Use this snippet to print the Python version, HDF5Plugin version, and its build configuration details. Ensure hdf5plugin is installed. ```python import os import sys print('Python:', sys.version) config = hdf5plugin.get_config() print(f"""hdf5plugin: * Version: {hdf5plugin.version} * Build config: {''' '''.join(f' - {k}: {v}' for k, v in config.build_config._asdict().items())} """) ``` -------------------------------- ### Install hdf5plugin with OpenMP disabled Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/install.rst.txt Disable OpenMP compilation when installing hdf5plugin by setting the HDF5PLUGIN_OPENMP environment variable to False. This can be done either globally before the pip install command or when installing from the source directory. ```bash HDF5PLUGIN_OPENMP=False pip install hdf5plugin --no-binary hdf5plugin ``` ```bash HDF5PLUGIN_OPENMP=False pip install . ``` -------------------------------- ### Install hdf5plugin using pip Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Install the hdf5plugin package using pip. Alternatively, use 'conda install -c conda-forge hdf5plugin'. ```bash pip3 install hdf5plugin ``` -------------------------------- ### Install hdf5plugin using conda Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/install.rst.txt Use this command to install the hdf5plugin package from the conda-forge channel. ```bash conda install -c conda-forge hdf5plugin ``` -------------------------------- ### Get Filter Information Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Retrieve information about available HDF5 filters. You can get all filters by default or specify a subset by name or ID. ```APIDOC ## Get information about hdf5plugin ### Constants `hdf5plugin.PLUGIN_PATH` Directory where the provided HDF5 filter plugins are stored. ### Functions `hdf5plugin.get_filters(_filters =('bshuf', 'blosc', 'blosc2', 'bzip2', 'fcidecomp', 'lz4', 'sperr', 'sz', 'sz3', 'zfp', 'zstd')_)` Returns selected filter classes. By default it returns all filter classes. Parameters: **filters** (`int` | `str` | `tuple`[`int` | `str`, `...`]) – Filter name or ID or sequence of filter names or IDs (default: all filters). It also supports the value “registered” which selects currently available filters. Return type: `tuple`[`type`[`FilterRefBase`], `...`] Returns: Tuple of filter classes `hdf5plugin.get_config()` Provides information about build configuration and filters registered by hdf5plugin. Return type: `HDF5PluginConfig` ``` -------------------------------- ### Create Compressed Dataset with Shuffle and Gzip Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Demonstrates creating an HDF5 dataset with both byte-shuffling enabled and gzip compression. This uses standard h5py arguments. ```python h5file = h5py.File("new_file_shuffle_gzip.h5", mode="w") h5file.create_dataset( "/compressed_data_shuffle_gzip", data=data, shuffle=True, compression="gzip") h5file.close() ``` -------------------------------- ### Create HDF5 dataset with Bitshuffle and LZ4 compression using hdf5plugin Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html Shows how to create an HDF5 file and write a dataset using Bitshuffle and LZ4 compression by passing an hdf5plugin.Bitshuffle() object to the compression argument. ```python h5file = h5py.File("new_file_bitshuffle_lz4.h5", mode="w") h5file.create_dataset( "/compressed_data_bitshuffle_lz4", data=data, **hdf5plugin.Bitshuffle() ) h5file.close() ``` -------------------------------- ### Install hdf5plugin from source with pip and disable OpenMP Source: https://hdf5plugin.readthedocs.io/en/latest/install.html Install hdf5plugin from source using pip, disabling OpenMP compilation by setting the HDF5PLUGIN_OPENMP environment variable to False. ```bash HDF5PLUGIN_OPENMP=False pip install hdf5plugin --no-binary hdf5plugin ``` -------------------------------- ### Install hdf5plugin from local source directory with pip and disable OpenMP Source: https://hdf5plugin.readthedocs.io/en/latest/install.html Install hdf5plugin from the local source directory using pip, disabling OpenMP compilation by setting the HDF5PLUGIN_OPENMP environment variable to False. ```bash HDF5PLUGIN_OPENMP=False pip install . ``` -------------------------------- ### Download Demo Data Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/hdf5_compressed_chunk_direct_read.html Downloads a sample HDF5 file containing kevlar data, which will be used for demonstrating compressed chunk reading. ```bash # Download dataset !wget -O /dev/shm/kevlar.h5 http://www.silx.org/pub/pyFAI/pyFAI_UM_2020/data_ID13/kevlar.h5 ``` -------------------------------- ### Create HDF5 dataset with shuffle and gzip compression using h5py Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html Demonstrates creating an HDF5 file and writing a dataset with byte-shuffle and gzip compression enabled via h5py parameters. ```python h5file = h5py.File("new_file_shuffle_gzip.h5", mode="w") h5file.create_dataset( "/compressed_data_shuffle_gzip", data=data, shuffle=True, compression="gzip") h5file.close() ``` -------------------------------- ### Prepare Compressed Datasets Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/hdf5_compressed_chunk_direct_read.html Creates two new HDF5 files, one with Blosc2 compression and another with Bitshuffle compression, using a specific data slice from the downloaded file. ```python import h5py import hdf5plugin with h5py.File("/dev/shm/kevlar.h5", "r") as h: data_ref = h["/entry/data/data"][500] with h5py.File("/dev/shm/kevlar_blosc2.h5", "w") as h: h.create_dataset( "data", data=data_ref, chunks=data_ref.shape, compression=hdf5plugin.Blosc2( cname='lz4', clevel=5, filters=hdf5plugin.Blosc2.BITSHUFFLE, ), ) with h5py.File("/dev/shm/kevlar_bitshuffle.h5", "w") as h: h.create_dataset( "data", data=data_ref, chunks=data_ref.shape, compression=hdf5plugin.Bitshuffle(), ) ``` -------------------------------- ### Write Compressed Datasets Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/usage.rst.txt Demonstrates how to create a compressed dataset using h5py and hdf5plugin, specifying compression filters and options. ```APIDOC ## Write Compressed Datasets ### Description To write compressed datasets, `import hdf5plugin` is required to enable the supported compression filters. You can then use `h5py.Group.create_dataset` with the `compression` and `compression_opts` arguments. `hdf5plugin` provides helper classes for preparing these options. ### Example ```python import numpy import h5py import hdf5plugin # Create a compressed dataset using LZ4 compression f = h5py.File('test.h5', 'w') f.create_dataset('data', data=numpy.arange(100), compression=hdf5plugin.LZ4()) f.close() # Read the compressed dataset (decompression is handled automatically) f = h5py.File('test.h5', 'r') data = f['data'][()] f.close() ``` ### Compression Filters `hdf5plugin` provides helper classes for various compression filters, including: - `Bitshuffle` - `Blosc` - `Blosc2` - `BZip2` - `FciDecomp` - `LZ4` - `Sperr` - `SZ` - `SZ3` - `Zfp` - `Zstd` Each of these can be instantiated and passed to the `compression` argument of `create_dataset`. ``` -------------------------------- ### Download Benchmark Dataset Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/benchmark.html Use wget to download the benchmark dataset. The dataset is saved to /dev/shm/kevlar.h5. ```bash !wget -O /dev/shm/kevlar.h5 http://www.silx.org/pub/pyFAI/pyFAI_UM_2020/data_ID13/kevlar.h5 ``` -------------------------------- ### Get Information about hdf5plugin Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/usage.rst.txt Provides information on accessing constants and functions related to hdf5plugin's configuration and filters. ```APIDOC ## Get Information about hdf5plugin ### Description `hdf5plugin` provides access to constants and functions that can help you understand its configuration and available filters. ### Constants - `hdf5plugin.PLUGIN_PATH`: Directory where the provided HDF5 filter plugins are stored. ### Functions - `hdf5plugin.get_filters()`: Retrieves information about the available filters. - `hdf5plugin.get_config()`: Gets the current configuration of the plugin. ### Usage These can be imported and called to inspect the plugin's state and capabilities. ``` -------------------------------- ### Instantiate Compression Filter Configuration Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Creates a compression filter configuration instance from an HDF5 filter ID and its options. Raises ValueError or NotImplementedError for unsupported combinations. ```python import h5py import hdf5plugin create_plist = dataset.id.get_create_plist() compression_filters = [] for index in range(create_plist.get_nfilters()): filter_id, _, filter_options, _ = create_plist.get_filter(index) if filter_id in hdf5plugin.FILTERS.values(): compression_filters.append(hdf5plugin.from_filter_options(filter_id, filter_options)) ``` -------------------------------- ### Read and Display Compressed Data Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/presentation.html Read a compressed dataset and display it using Matplotlib. This step requires hdf5plugin to be installed and imported. ```python data = h5file["/compressed_data"][()] # Access datset plt.imshow(data, cmap="gray") # Display data ``` -------------------------------- ### Configure HDF5 Plugin and Environment Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/hdf5_compressed_chunk_direct_read.html Sets CPU affinity and environment variables for multithreading before importing libraries. Displays hdf5plugin version and build configuration details. ```python import os os.sched_setaffinity(0, [0]) AFFINITY = os.sched_getaffinity(0) NCPU = len(AFFINITY) print(f"Number of CPU: {NCPU}; Affinity: {AFFINITY}") os.environ["OPENMP_NUM_THREADS"] = str(NCPU) os.environ["BLOSC_NTHREADS"] = str(NCPU) print(f"""env: OPENMP_NUM_THREADS: {os.environ.get("OPENMP_NUM_THREADS", "unset")} BLOSC_NTHREADS: {os.environ.get("BLOSC_NTHREADS", "unset")} """) import h5py import hdf5plugin config = hdf5plugin.get_config() print(f"""hdf5plugin: Version: {hdf5plugin.version} Build config: {''' '''.join(f' {k}: {v}' for k, v in config.build_config._asdict().items())} """) ``` -------------------------------- ### List available compression libraries Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Lists the dynamic libraries for compression filters found at the hdf5plugin.PLUGINS_PATH. ```bash ls `python3 -c "import hdf5plugin; print(hdf5plugin.PLUGINS_PATH)"` ``` -------------------------------- ### Use ZFP Compression in Expert Mode Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Utilize ZFP compression in expert mode for fine-grained control over compression parameters like minbits, maxbits, maxprec, and minexp. ```python f.create_dataset( 'zfp_expert', data=numpy.random.random(100), compression=hdf5plugin.Zfp(minbits=1, maxbits=16657, maxprec=64, minexp=-1074)) ``` -------------------------------- ### Use SZ Compression with h5py Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Demonstrates creating an HDF5 dataset with SZ2 compression. This is the default configuration. ```python f = h5py.File('test.h5', 'w') f.create_dataset( 'sz', data=numpy.random.random(100), compression=hdf5plugin.SZ()) f.close() ``` -------------------------------- ### Run Self-Contained Tests in Python Source: https://hdf5plugin.readthedocs.io/en/latest/contribute.html Execute the project's self-contained tests directly from a Python interpreter. Ensure the 'hdf5plugin' library is installed. ```python import hdf5plugin.test hdf5plugin.test.run_tests() ``` -------------------------------- ### Get HDF5 Filter Classes Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Retrieves specific HDF5 filter classes by name or ID. Defaults to all available filters if no arguments are provided. ```python import hdf5plugin # Get all filter classes all_filters = hdf5plugin.get_filters() # Get specific filter classes blosc_filters = hdf5plugin.get_filters(['blosc', 'blosc2']) ``` -------------------------------- ### Get hdf5plugin Path in Python Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/usage.rst.txt Retrieve the plugin path for hdf5plugin. This path is used to set the HDF5_PLUGIN_PATH environment variable for non-Python applications. ```python import hdf5plugin; print(hdf5plugin.PLUGIN_PATH) ``` -------------------------------- ### Create Compressed Dataset with Blosc2 Filter (Raw) Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/presentation.html Demonstrates creating a compressed dataset using the Blosc2 filter with its raw HDF5 filter identifier and options tuple. ```python h5file = h5py.File("new_file_blosc2_bitshuffle_lz4.h5", mode="w") h5file.create_dataset( "/compressed_data", data=data, compression=32026, # Blosc2 HDF5 filter identifier # options: 0, 0, 0, 0, level, filter, compression compression_opts=(0, 0, 0, 0, 5, 2, 1) ) h5file.close() ``` -------------------------------- ### Blosc Class Documentation Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2022.html This section provides the help documentation for the hdf5plugin.Blosc class, detailing its constructor parameters and available options for Blosc compression. ```APIDOC ## Blosc Class Help help(hdf5plugin.Blosc) ``` -------------------------------- ### Get HDF5 Plugin Path Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Retrieves the path where HDF5 compression filter plugins are stored by hdf5plugin. This path can be set as the HDF5_PLUGIN_PATH environment variable. ```python # Directory where HDF5 compression filters are stored hdf5plugin.PLUGINS_PATH ``` -------------------------------- ### Create Compressed Dataset with hdf5plugin.Bitshuffle Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Shows how to create a compressed HDF5 dataset using the hdf5plugin.Bitshuffle helper. This is a more Pythonic way to apply the filter. ```python h5file = h5py.File("new_file_bitshuffle_lz4.h5", mode="w") h5file.create_dataset( "/compressed_data_bitshuffle_lz4", data=data, **hdf5plugin.Bitshuffle() # Or: **hdf5plugin.BitShuffle(lz4=True) ) h5file.close() ``` -------------------------------- ### Set HDF5 Plugin Path (Command Line) Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Prints the HDF5 plugin path to the console, which can be used to set the HDF5_PLUGIN_PATH environment variable for non-Python applications. ```bash python -c "import hdf5plugin; print(hdf5plugin.PLUGIN_PATH)" ``` -------------------------------- ### Get Dataset Compression Configuration Source: https://hdf5plugin.readthedocs.io/en/latest/usage.html Retrieve compression filter configuration from HDF5 dataset's low-level API and instantiate filter configurations using hdf5plugin. ```APIDOC ## Get dataset compression For **built-in** compression filters (i.e., GZIP, LZF, SZIP), dataset compression configuration can be retrieved with h5py.Dataset’s compression and compression_opts properties. For **third-party** compression filters such as the one supported by hdf5plugin, the dataset compression configuration is stored in HDF5 filter pipeline. This filter pipeline configuration can be retrieved with h5py.Dataset “low level” API. For a given h5py.Dataset, `dataset`: ```python create_plist = dataset.id.get_create_plist() for index in range(create_plist.get_nfilters()): filter_id, _, filter_options, _ = create_plist.get_filter(index) print(filter_id, filter_options) ``` For compression filters supported by hdf5plugin, `hdf5plugin.from_filter_options()` instantiates the filter configuration from the filter id and options. `hdf5plugin.from_filter_options(_filter_id_ , _filter_options_)` Returns corresponding compression filter configuration instance. ```python create_plist = dataset.id.get_create_plist() compression_filters = [] for index in range(create_plist.get_nfilters()): filter_id, _, filter_options, _ = create_plist.get_filter(index) if filter_id in hdf5plugin.FILTERS.values(): compression_filters.append(hdf5plugin.from_filter_options(filter_id, filter_options)) ``` Parameters: * **filter_id** (`int` | `str`) – HDF5 compression filter ID * **filter_options** (`tuple`[`int`, `...`]) – Compression filter configuration as stored in HDF5 datasets Raises: * **ValueError** – Unsupported or invalid filter_id, filter_options combination * **NotImplementedError** – Given filter or version of the filter is not supported Return type: `FilterRefBase` ``` -------------------------------- ### Load Benchmark Results Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2023/benchmark.html This code loads benchmark data from a 'benchmark.json' file and initializes Result objects. Make sure 'benchmark.json' exists in the current directory. ```python import json benchmarks = json.load(open("benchmark.json")) config = benchmarks["config"] results = {k: Result(**v) for k, v in benchmarks["results"].items()} ``` -------------------------------- ### Check Code with Flake8 Source: https://hdf5plugin.readthedocs.io/en/latest/contribute.html Perform static code analysis using 'flake8' to check for style guide violations and potential errors. Run from the source directory. ```bash flake8 ``` -------------------------------- ### Initialize filter with libHDF5 symbols (C) Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Initializes the compression filter by loading symbols from libHDF5 dynamically. This is specific to Linux/macOS environments. ```c typedef size_t (* DL_func_H5Tget_size)(hid_t type_id); static struct { /* Structure storing HDF5 function pointers */ DL_func_H5Tget_size H5Tget_size; } DL_H5Functions = {NULL}; /* Init wrapper by loading symbols from `libHDF5` */ int init_filter(const char* libname) { void * handle = dlopen(libname, RTLD_LAZY | RTLD_LOCAL); /*Load libHDF5*/ DL_H5Functions.H5Tget_size = (DL_func_H5Tget_size)dlsym(handle, "H5Tget_size"); } ``` -------------------------------- ### Get HDF5 Dataset Create Property List in Python Source: https://hdf5plugin.readthedocs.io/en/latest/_sources/usage.rst.txt Retrieve the create property list for an HDF5 dataset to inspect its filters. This is useful for understanding the compression settings applied to a dataset. ```python create_plist = dataset.id.get_create_plist() for index in range(create_plist.get_nfilters()): filter_id, _, filter_options, _ = create_plist.get_filter(index) print(filter_id, filter_options) ``` -------------------------------- ### Create Compressed Dataset with Bitshuffle/LZ4 Source: https://hdf5plugin.readthedocs.io/en/latest/hdf5plugin_EuropeanHUG2021.html Demonstrates creating an HDF5 dataset using the Bitshuffle filter with LZ4 compression. This method uses the filter identifier directly. ```python h5file = h5py.File("new_file_bitshuffle_lz4.h5", mode="w") h5file.create_dataset( "/compressed_data_bitshuffle_lz4", data=data, compression=32008, # bitshuffle/lz4 HDF5 filter identifier compression_opts=(0, 2) # options: default number of elements/block, enable LZ4 ) h5file.close() ``` -------------------------------- ### Run Tests with HDF5 Files Source: https://hdf5plugin.readthedocs.io/en/latest/contribute.html Execute tests that require actual HDF5 files. This command should be run from the source directory of the project to ensure correct file path resolution. ```bash python test/test.py ```