Skip to content
PierreBouvet edited this page Sep 16, 2025 · 4 revisions

Welcome to the HDF5_BLS wiki!

This wiki presents the use of the HDF5_BLS library. HDF5 is a very popular format in the scientific community, and is used by many large scientific projects. We here propose to use HDF5 to store data obtained during Brillouin Light Scattering (BLS) experiments, independently of the type of instrument used to acquire the data and the parameters used in the experiment.

To allow for a unified way of storing and reading data, we propose to add two layers of abstraction on top of HDF5:

  • All the data obtained during a BLS experiment is stored under the "Brillouin" group, at the root level of the HDF5 file.
  • All the elements stored in the HDF5 file have a "Brillouin_type" attribute, which is a string describing the type of the element.

The HDF5_BLS library is a Python library, which provides a set of functions to read and write data from/to HDF5 files, and manipulate the file to comply with the two layers of abstraction described above.

Installation

The HDF5_BLS library can be installed using the following command:

pip install HDF5_BLS

Quick start guide

To use the HDF5_BLS library, you need to import it in your Python script:

import HDF5_BLS

Creating a Wrapper object

You can open a HDF5 file by creating a 'Wrapper' object:

from HDF5_BLS import Wrapper
wrapper = Wrapper('path/to/file.h5')

This object is a wrapper around the HDF5 file, and simplifies the access to the data stored in it.

Displaying the structure of the file and accessing data

You can display the structure of the file by simply printing the 'wrapper' object:

print(wrapper)

This will display the structure of the file, with the name of the elements stored in the file, and the Brillouin type of the elements, for example:

file.h5
├── Brillouin (Root)
│   ├── Measure (Measure)
│   │   ├── Power Spectral Density (PSD)
│   │   ├── Frequency (Frequency)
│   │   ├── Results (Treatment)
│   │   │   ├── Linewidth (Linewidth)
│   │   │   ├── Shift (Shift)

From there, you can easily retrieve a dataset from the file by specifying the path to the dataset, for example:

dataset = wrapper['Brillouin/Measure/Power Spectral Density']

This will return an array with the specifed dataset (in this example, the Power Spectral Density of the Measure).

Adding data to the file

You can add data to the file by using one of the type-specific functions, for example:

wrapper.add_PSD(data = dataset, parent_group = "Brillouin/Measure/Power Spectral Density", name = "My PSD")

You can add the different types of datasets to the file:

  • Power Spectral Density (a power spectral density) - 'add_PSD'
  • Frequency (a frequency array associated to the PSD) - 'add_frequency'
  • Raw data (a raw data array) - 'add_raw_data'
  • Abscissa (an abscissa array associated to the PSD) - 'add_abscissa' (you then also need to specify the units of the abscissa and the dimensions of the PSD to which it is associated)
  • Other (any other array) - 'add_other'

You can also add results of treatments using the "add_treated_data" function. Using this function, you can add the following datasets:

  • Shift (a shift array associated to the PSD) - 'shift' attribute of the "add_treated_data" function
  • Linewidth (a linewidth array associated to the PSD) - 'linewidth' attribute of the "add_treated_data" function
  • Amplitude (an amplitude array associated to the PSD) - 'amplitude' attribute of the "add_treated_data" function
  • BLT (the Brillouin Loss Tangent) - 'blt' attribute of the "add_treated_data" function

and all the associated errors: 'shift_err', 'linewidth_err', 'amplitude_err', 'blt_err'