HyperSpy

2.4.0 · active · verified Thu Apr 16

HyperSpy is an open-source Python library, currently at version 2.4.0, providing a comprehensive framework for the interactive analysis of multidimensional datasets, particularly within scientific domains like electron microscopy. It offers tools for efficient exploration, manipulation, and visualization of complex data arrays, including those larger than available memory. The project maintains an active development pace with several minor releases annually, and significant architectural changes in major versions like 2.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import HyperSpy, load an example dataset, and plot it. It also includes commented-out code to illustrate how to create a signal directly from a NumPy array and set its axes properties, which is useful for custom data.

import hyperspy.api as hs
import numpy as np

# Load example data (e.g., an EDS spectrum image)
s = hs.datasets.example_signals.EDS_TEM_Spectrum()

# Or create a signal from a numpy array
# data = np.random.rand(10, 10, 1024) # e.g., 10x10 image of 1024-channel spectra
# s_from_array = hs.signals.Signal1D(data)
# s_from_array.set_axes(axis=0, name='X', units='nm')
# s_from_array.set_axes(axis=1, name='Y', units='nm')
# s_from_array.set_signal_axis(0, name='Energy', units='eV')

print(s)
s.plot()

view raw JSON →