Back to home
2022-Present 4 min read

ERLabPy–A Python library for ARPES experiments

Building a complete analysis workflow for ARPES data with Python.

PythonData analysis

Motivation

ERLabPy started from a practical frustration. When I first began working with ARPES as an undergraduate researcher, much of the analysis workflow around me depended on proprietary, domain-specific software. As an undergraduate student, I wanted to learn modern, open tools that would let me build transferable skills and work in a more productive way that lets me think about how I wanted to do analysis rather than spend time just figuring out how the existing tools worked. As a result, I found myself writing analysis routines from scratch with languages I was more comfortable with, such as Python and MATLAB.

I initially looked to existing Python-based ARPES tools, especially PyARPES, as a way into a more modern workflow. But over time I found that I wanted a different foundation: a cleaner data model, better momentum-space handling, and a tighter connection between interactive work and reproducible code. That would have been a significant amount of work to retrofit onto an existing codebase, so I decided to build something new instead.

What I built

Once a collection of useful macros, ERLabPy has evolved into a complete Python workflow for ARPES experiments. It is built on top of NumPy, SciPy, and xarray, and is designed to integrate naturally with the broader scientific Python ecosystem. The package combines data loading, manipulation, plotting, curve fitting, momentum conversion, and interactive visualization, with support for data from multiple synchrotron endstations and laboratory systems through a plugin-based loader framework.

A major goal of the project is to avoid the usual split between “quick GUI work” and “reproducible analysis code.” ERLabPy’s interactive tools can be used for rapid inspection and selection, but they are also designed to round-trip back into code through code export, notebook integration, and shared data structures.

One of the clearest examples of that philosophy is ImageTool. It was built as a Python-native successor to Igor-style image exploration: inspired by the Image Tool developed at the Advanced Light Source, but extended with xarray objects, Dask-backed data, multiple synchronized cursors, code export, notebook synchronization, and an ImageTool manager for handling many datasets at once. For me, that is what makes ERLabPy more than a collection of analysis routines: it is an attempt to make interactive ARPES work fast without giving up reproducibility.

The data model is based on xarray’s DataArray objects, which provide labeled, N-dimensional arrays with built-in support for metadata and coordinate systems. This is useful for ARPES data, which often involves complex relationships between energy, momentum, and other experimental parameters.

One challenge while building ERLabPy was that the xarray-based data model lacked a direct integration path with model-based fitting tools such as lmfit. To solve that problem, I built a side project called xarray-lmfit that provides a bridge between the two libraries. It allows users to define fitting models using lmfit and apply them directly to xarray objects, while preserving metadata and coordinate information. This was a significant amount of work, but it was necessary to make the fitting workflow in ERLabPy as seamless and powerful as I wanted it to be. That project is now a standalone library that can be used in other contexts as well, and it is a good example of how building the tools I wanted for my own work led to contributions that could be useful to the broader community.

A project that keeps evolving

ERLabPy is an active project that continues to evolve. I have made a commitment to maintain it and keep it up to date with the latest developments in the scientific Python ecosystem. That includes regular updates to dependencies, improvements to documentation, and ongoing development of new features based on user feedback and my own research needs. I also welcome contributions from the community, whether in the form of bug reports, feature requests, or pull requests with new code. The repository currently lists over 2500 commits and 100 releases.

More broadly, ERLabPy reflects how I think about experimental physics: not just as a way to understand the world, but as a practice that can be improved through better tools, better workflows, and better communication. I care about building tools that make experiments easier to understand, easier to reproduce, and easier to share. In that sense, ERLabPy is both a software project and part of a larger effort to make ARPES analysis more open, portable, and sustainable.