Skip to content

AvaRead

DOI GitHub License GitHub Workflow Status build GitHub Workflow Status docs PyPI - Version PyPI - Python versions PyPI - Downloads Ruff Hatch project

A project for reading spectra from Avantes AvaSoft 8 files in Python.

It supports all Avantes multichannel files (e.g. .raw8, .rir8, etc.), reading all avaible channels, as well as store-to-RAM/multiframe files (.str8).

Importantly, this means you can work with these files directly in your analysis!

  • No need to convert your .raw8 (or equivalent files) to work with them

  • No need to convert your .str8 into large sets of files with very similar names!

Installing

AvaRead can be easily installed with pip and only has numpy as a dependency, which will be installed if missing.

You can install the latest release from PyPI:

pip install avaread

To install the latest development version from GitHub, you can use:

pip install git+https://github.com/AntoineTUE/avaread.git

How to use

Using avaread is fairly straightforward, you should be fine with using the read_file function to open any Avantes AvaSoft 8 file.

Depending on the detected file type, you will either receive an instance of AVSFile or STRFile, which are iterable, container-like objects that give you access to the data and metadata read from the file.

Most of the data is stored as numpy.ndarrays under the hood.

Note that these files store data differently:

  • AVSFile stores data from multiple devices (or channels), one spectrum per device, which can be of different shape.
  • STRFile stores multiple spectra recorded in sequence by a single device (or channel).

See also the documentation for more details and examples.

import avaread
from avaread.reader import AVSFile, STRFile
from pathlib import Path
import matplotlib.pyplot as plt

file1 = Path("path/to/file1.raw8")
file2 = Path("path/to/file2.str8")

data1 = avaread.read_file(file1)
data2 = avaread.read_file(file2)

assert isinstance(data1, AVSFile)
assert isinstance(data2, STRFile)

plt.figure()
# Plot the different channels stored in the `AVSFile`
for channel in data1:
    plt.plot(channel.wavelength, channel.signal, label=f"{channel.ID.SerialNumber}")

plt.figure()
# Plot the different frames stored in the `STRFile`
for i, frame in enumerate(data2):
    plt.plot(data2.wavelength, frame, label=f"Delay: {data2.delay[i]} ms")

License

AvaRead is licensed under the MIT license.

See LICENSE.