Skip to main content

pyLEEM

License: BSD 3-Clause Python 3.11+ Tests

A Python toolkit for Low Energy Electron Microscopy (LEEM) data analysis. pyLEEM provides readers, ROI tools, domain-specific analyzers, calibration analyzers, and workflow recording for reproducible runs.

Installation

pip install pyleem

Development installation

Clone the development branch:

git clone --branch develop https://github.com/peterhys/PyLEEM.git
cd PyLEEM
pip install -e .

Design

Overview

pyLEEM is a Python toolkit for analyzing Low Energy Electron Microscopy (LEEM) data. It provides tools for reading LEEM metadata and raw data, and for calibrating and analyzing X-ray Photoelectron Spectroscopy (XPS), Secondary Electron Energy Spectroscopy (SEES), Diffuse Elastic Scattering Pattern (DESP), and X-ray Absorption Spectroscopy (XAS).

Additional tools include stitching that can create a continuous spectrum from overlapping spectra.

The package is designed to be modular and extendable.

Reader class

The Reader class takes care of converting a LEEM file into a Python-readable format, and parses all the metadata from the file. Currently, the only available reader is the UViewReader class, used to read UView .dat files. Custom readers can be easily implemented to support other file formats.

ROI class

The ROI class is used to define the region of interest (ROI) for the analysis. ROI can either be manually defined or parsed from an ImageJ ROI file. Calibrated ROI stores calibration parameters for the region of interest. For LEEM, the pixel per eV and peak shift values are used to convert the pixel profile to the proper energy scale.

Analyzer class

The base unit of pyLEEM analysis is an Analyzer object. The basic Analyzer class provides simple analysis tools for raw data.

For domain-specific analysis, Analyzer subclasses can be created. Currently, the available subclasses are:

  • SEESAnalyzer: Secondary Electron Energy Spectroscopy (SEES) analyzer.
  • DESPAnalyzer: Diffuse Elastic Scattering Pattern (DESP) analyzer.
  • XASAnalyzer: X-ray Absorption Spectroscopy (XAS) analyzer.
  • XPSAnalyzer: X-ray Photoelectron Spectroscopy (XPS) analyzer.

These subclasses provide domain-specific analysis tools for the raw data.

Workflow

For reproducibility, workflow can be used to build readers, ROI, and analyzer objects, and define tasks. Workflow can be loaded and saved from configuration TOML files.

Users can instantiate readers, ROI, and analyzers directly without Config or Workflow. Users use Workflow when they want standardized calibration, reproducible input, parameters, and streamlined I/O.

Examples

For detailed examples, please refer to the example notebook.

The notebook uses the external example data repository. Clone it as example/ next to the notebook:

git clone https://github.com/peterhys/pyLEEM-example.git example

Here we show some examples of pyLEEM's capabilities.

XPS: binding energy calibration, peak fitting and stitching

from pyleem.analysis.xps import XPSAnalyzer, XPSCalibration
from pyleem.reader import UViewReader, read_files
from pyleem.roi import LineROI

readers = read_files(
    ["xps_0.dat", "xps_1.dat", "xps_2.dat"],
    UViewReader,
    metadata_list=[
        {"Beam Energy": (400, "eV")},
        {"Beam Energy": (400, "eV")},
        {"Beam Energy": (400, "eV")},
    ],
)

roi = LineROI(src=[0, 0], dst=[0, 127], linewidth=1)

calibration = XPSCalibration(readers, roi)
cal_result = calibration.analyze(
    baselines=[(197, 100)] * 3,
    num_peaks=1,
    ref_index=0,
    ref_value=285.0,
)

analyzer = XPSAnalyzer(
    readers,
    roi,
    cal_result["pixel_per_ev"],
    cal_result["peak_shift"],
)

fit_result = analyzer.fit(0, num_peaks=1, baseline=(200, 100))

# Automatically stitch profiles into a single spectrum
stitched_energy, stitched_profile = analyzer.stitch_profiles([0, 1, 2])

SEES: surface potential from an onset shift

from pyleem.analysis.sees import SEESAnalyzer, SEESCalibration
from pyleem.reader import UViewReader, read_files
from pyleem.roi import LineROI

readers = read_files(["sees_0.dat", "sees_1.dat", "sees_2.dat"], UViewReader)
roi = LineROI(src=[0, 0], dst=[0, 127], linewidth=1)

calibration = SEESCalibration(readers, roi)
cal_result = calibration.analyze(sigma=0)

analyzer = SEESAnalyzer(
    [readers[0]],
    roi,
    cal_result["pixel_per_ev"],
    cal_result["peak_shift"],
    sigma=10,
)

result = analyzer.analyze_profile(0)
print(result["surface_potential"])

Workflow: run and save analysis results

Workflow file can be partially filled as a template for distribution.

sees_calibration.toml

[session]
reader = "UViewReader"
roi = "LineROI"
analyzer = "SEESCalibration"

[reader]
paths = ["sees_0.dat", "sees_1.dat", "sees_2.dat"]

[roi]
src = [0, 0]
dst = [0, 127]
linewidth = 1

[task]
sigma = 0
import pyleem.analysis.sees  # registers SEESCalibration class
from pyleem.config import load_config
from pyleem.workflow import Workflow

config = load_config("sees_calibration.toml")
workflow = Workflow(config)
result = workflow.run()
workflow.save("sees_calibration_run.toml")

Documentation

License

pyLEEM is distributed under the BSD 3-Clause License, see LICENSE.

Additional Brookhaven National Laboratory, U.S. Department of Energy, and U.S. Government rights notices are provided in NOTICE.

Third-party dependencies are distributed under their own licenses, see THIRD_PARTY_LICENSES.

Metadata

Release files for pyleem 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyleem 0.3.0
File Size Uploaded
pyleem-0.3.0.tar.gz 56.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyleem 0.3.0
File Interpreter ABI Platform
pyleem-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 99.1 kB

Release files / pyleem-0.3.0.tar.gz

Download URL pyleem-0.3.0.tar.gz
Size 56.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f789345f065dde8ec807880ce5e4a78cec994d269d7fcccc3d7e5a1b32b9f646
BLAKE2b-256 checksum
How to use checksums
be9d90034575ae1e494734664251188c79bacf2001fcb223b8818417f3d25c0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

Release files / pyleem-0.3.0-py3-none-any.whl

Download URL pyleem-0.3.0-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05b6e531fa04679e18459ec82851293533556b8110eb099cc23a084e833eb121
BLAKE2b-256 checksum
How to use checksums
930e9c58fae47ba24e7fcaf53562680ff38e8dcba7d17c1ca9c13528effe91dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page