X-ray Absorption Spectroscopy (XAS) is a powerful synchrotron-based technique used to probe the local atomic structure, oxidation state, and electronic configuration of materials. Unlike X-ray diffraction — which reveals long-range crystal structure — XAS is sensitive to the immediate environment (first few coordination shells) around a specific element. This makes it invaluable for studying catalysts, battery materials, amorphous solids, and biological metal centers.
A typical synchrotron beamtime produces gigabytes of raw data that must be reduced, normalized, and fitted to extract meaningful structural parameters. Self-hosting these analysis tools ensures data integrity between beamtimes and allows researchers to develop custom analysis protocols that persist across experiments.
In this guide, we compare three open-source frameworks for XAS analysis: Demeter (which includes Athena and Artemis), Larch (the modern successor to IFEFFIT), and xraylib (the fundamental cross-section library powering most XAS software).
Understanding XAS Data: XANES and EXAFS
XAS spectra are divided into two regions with different physical information content:
- XANES (X-ray Absorption Near-Edge Structure): The region within ~50 eV of the absorption edge. Sensitive to oxidation state, coordination geometry, and electronic structure. XANES analysis is often qualitative — comparing spectra to reference compounds.
- EXAFS (Extended X-ray Absorption Fine Structure): The oscillatory region 50-1000 eV above the edge. Provides quantitative information: bond distances (±0.02 Å), coordination numbers, and Debye-Waller disorder factors. Requires fitting to theoretical scattering paths calculated by FEFF.
| Feature | Demeter (Athena/Artemis) | Larch | xraylib |
|---|---|---|---|
| Primary Function | Data processing + EXAFS fitting | Full replacement for IFEFFIT | Cross-section calculations |
| GitHub Stars | 83 | 175 | 168 |
| Language | Perl (Athena), Fortran (IFEFFIT) | Python | C with Python bindings |
| GUI | Yes (Athena/Artemis) | Python scripting / Jupyter | Library (no GUI) |
| FEFF Integration | Built-in (Artemis) | Supported via feff6l | Input generation only |
| Installation | Windows/Mac GUI installers | pip, conda | pip, conda |
| Key Strength | Mature, beamline standard | Modern Python API, extensible | Low-level accuracy, speed |
Demeter: The Beamline Standard
Demeter is a suite of Perl programs for XAS data processing and analysis, developed by Bruce Ravel at NIST. It includes Athena (data reduction, normalization, linear combination fitting) and Artemis (EXAFS fitting using FEFF). For over 15 years, Demeter has been the standard software at most synchrotron beamlines worldwide.
Installation and Usage
Demeter is primarily distributed as Windows and macOS installer packages with bundled dependencies. On Linux, it can be built from source:
| |
Athena: Data Processing
Athena provides a graphical interface for importing beamline data files (in virtually any format), aligning multiple scans, performing energy calibration, background subtraction (AUTOBK algorithm), and normalization. Key features include:
| |
Athena’s linear combination fitting (LCF) module is widely used for XANES analysis — fitting an unknown spectrum as a weighted sum of reference spectra to determine chemical speciation. The LCF module reports each reference’s fractional contribution with uncertainty estimates.
Artemis: EXAFS Fitting
Artemis uses FEFF-calculated scattering paths to fit EXAFS data. Users define a structural model (atomic positions, scattering paths), and Artemis refines parameters (bond distances, coordination numbers, sigma² disorder terms) by minimizing chi² between the theoretical and experimental chi(k):
| |
Larch: The Modern Python Alternative
Larch (X-ray Analysis Library) is a Python-based replacement for IFEFFIT, developed by Matt Newville at the University of Chicago. It provides a clean, modern API for XAS analysis that integrates naturally with the Python scientific ecosystem (NumPy, SciPy, Matplotlib).
Installation
| |
Processing XAS Data with Larch
Larch’s strength is its programmatic interface — ideal for batch processing hundreds of spectra from a beamtime run. Here’s a complete processing workflow:
| |
EXAFS Fitting with Larch
Larch integrates FEFF path calculations directly into its fitting engine:
| |
Larch also supports advanced analysis methods including wavelet transform analysis, linear combination fitting, and principal component analysis of XANES spectra — all within the same Python session.
xraylib: The Foundation Library
xraylib provides accurate calculations of X-ray fundamental parameters: cross-sections, fluorescence yields, line energies, and elastic/inelastic scattering factors. Most XAS analysis software (including Larch and Demeter) depends on xraylib or its predecessor for fundamental constants.
Installation and Basic Usage
| |
| |
xraylib’s calculations are based on the EPDL97 and EADL evaluated data libraries from Lawrence Livermore National Laboratory, making it the gold standard for accuracy in X-ray physics computations.
Setting Up a Self-Hosted XAS Analysis Server
For research groups with regular synchrotron access, deploying a dedicated analysis server with JupyterHub provides multi-user access to Larch, xraylib, and supporting tools:
| |
Data Pipeline from Beamline to Analysis
A typical synchrotron experiment workflow with self-hosted tools:
- Data Acquisition: Raw data files (
.dat,.xdi,.hdf5) saved to shared storage during beamtime - Transfer & Backup: Automated rsync from beamline workstation to institutional server after each scan
- Processing: Athena (GUI) or Larch (scripted batch) for normalization and background subtraction
- EXAFS Fitting: FEFF calculation → path definition → parameter refinement
- Visualization & Reporting: Jupyter notebooks combining Larch results with Matplotlib/Plotly figures
Why Self-Host Your XAS Analysis Pipeline?
Synchrotron beamtime is extraordinarily expensive and competitive — major facilities like APS, ESRF, and Spring-8 receive 3-5× more proposals than they can accommodate. Every allocated shift represents a year or more of preparation. Self-hosting your analysis pipeline provides three concrete benefits that protect this investment.
First, data provenance tracking: containerized tools with pinned versions create an immutable record of exactly how each dataset was processed. When a reviewer questions your EXAFS fitting procedure two years later, you can reproduce the analysis bit-for-bit by re-running the same container image. This is particularly important for XAS where normalization and background subtraction parameters (Rbkg, k-weight, Fourier transform range) significantly affect the fitted structural parameters.
Second, batch processing at scale: a single EXAFS beamtime can produce 200+ individual spectra from in-situ experiments (battery cycling, catalysis, high-pressure cells). Larch’s Python API enables automated batch processing that would take days manually in Athena’s GUI — fitting a dozen spectra takes minutes instead of hours.
Third, FEFF calculation management: FEFF is computationally expensive (hours per cluster for multiple-scattering paths). A dedicated server allows queueing calculations and caching results, avoiding redundant recomputation when fitting similar structures.
For crystallography and complementary structural methods, see our guide to Phenix, CCP4 and XDS. For other spectroscopic analysis tools, check our comparison of HyperSpy, Quasar and RamanSPy. For molecular visualization that complements XAS analysis, see our MolStar, 3Dmol.js and NGLview guide.
FAQ
What’s the difference between XANES and EXAFS?
XANES probes electronic structure (oxidation state, coordination geometry) within ~50 eV of the absorption edge. EXAFS probes local atomic structure (bond distances, coordination numbers) using oscillations extending 500-1000 eV past the edge.
Do I need to install FEFF separately?
FEFF (version 6) is bundled with Larch as feff6l. For Demeter/Artemis, FEFF is also bundled. For advanced FEFF9/10 calculations (full multiple scattering, XANES simulation), you need a separate installation and license from the FEFF Project.
Can Larch replace Athena entirely?
For most routine processing tasks, yes. Larch handles normalization, background subtraction, Fourier transforms, and EXAFS fitting. Athena’s GUI remains preferred for interactive data exploration and quick quality checks during beamtime.
Why does my EXAFS fit give unrealistic coordination numbers?
This typically indicates an incorrect S₀² (amplitude reduction factor). S₀² accounts for multi-electron excitations and should be determined from a reference compound measured under the same beamline conditions, then fixed during fitting of unknown samples.
How do I handle self-absorption effects in fluorescence-mode XAS?
For concentrated samples measured in fluorescence mode, self-absorption attenuates the EXAFS amplitude. Both Athena and Larch provide self-absorption correction algorithms. For thin, dilute samples (Δμx < 1), the correction is negligible.
Is xraylib suitable for simulating XAS spectra?
No — xraylib calculates atomic cross-sections and fundamental parameters, not spectral shapes. For XANES simulation, use FEFF (full multiple scattering), FDMNES (finite difference method), or ORCA/Quantum ESPRESSO (DFT-based).
💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com