Skip to main content

pyIrena

Coded by Claude from SAXS_IgorCode Irena. Planned, defined, debugged, and validated by Jan Ilavsky.

Python tools for small-angle scattering (SAS) data analysis. A port of the Igor Pro Irena package. Includes interactive GUI tools for fitting, modeling, data merging, and visualization of SAXS/SANS/USAXS data.

Current release: v1.2.1

Paper (open access): Irena and pyIrena, J. Appl. Cryst. (2026) — please cite it if pyIrena helps your work (see Citing pyIrena).

PyPI version Python Version License: MIT


Installation

From PyPI (recommended):

pip install pyirena[gui]

on macos with zsh:

pip install "pyirena[gui]"

This installs pyirena with all GUI dependencies (PySide6, pyqtgraph, etc.). For the core library only (no GUI), use pip install pyirena.

Trying a pre-release (beta) version:

Beta releases (e.g. 1.2.0b2) are published to PyPI ahead of a stable release for early testing. pip does not install pre-releases by default, so pass --pre explicitly:

pip install --pre "pyirena[gui]"

To install a specific version rather than whatever is newest:

pip install "pyirena[gui]==1.2.1"

Pre-releases may contain incomplete or breaking changes — see CHANGELOG.md for what's new, and please report issues at https://github.com/jilavsky/pyirena/issues.

From source (for development):

git clone https://github.com/jilavsky/pyirena.git
cd pyirena
pip install -e ".[gui]"

With conda:

git clone https://github.com/jilavsky/pyirena.git
cd pyirena
conda env create -f environment.yml
conda activate pyirena

environment.yml uses conda for Python + scientific stack and pip (inside conda) for the entire Qt6/GUI stack — this split is deliberate. Do not run conda install pyside6 in this env, and use Python 3.10 – 3.13 (Python 3.14 wheels are still flaky for compiled bindings).

See docs/getting-started/installation.md for full details, troubleshooting, and platform notes.


Running the GUI

pyirena-gui

This launches the Data Selector, the main entry point for all analysis tools. See docs/getting-started/quickstart.md for a walkthrough.

Individual tools can also be launched directly:

Command Tool
pyirena-gui Data Selector (main entry point)
pyirena-viewer Data Explorer
pyirena-modeling Modeling tool (standalone)
pyirena-datamerge Data Merge tool (standalone)
pyirena-contrast Scattering Contrast Calculator
pyirena-datamanip Data Manipulation tool (standalone)
pyirena-saxsmorph SAXS Morph tool (standalone)
pyirena-mcp MCP server for AI assistants (stdio) — see AI integration
pyirena-zmq ZMQ service for remote/beamline orchestration (docs)
pyirena-doctor Install/startup diagnostics

[project.scripts] in pyproject.toml is the authoritative list.


Analysis Tools

Modeling

Parametric forward-modeling of SAS data. Combine up to 10 populations, each of which can be a Size Distribution, Unified Fit Level, or Diffraction Peak. Fits the combined model to experimental data using least-squares optimization.

  • 5 distribution functions: Gaussian, LogNormal, LSW, Schulz-Zimm, Ardell
  • 10 form factors: Sphere, Spheroid, Cylinder (aspect ratio / fixed length), Core-Shell Sphere (by core R / shell t / total R), Core-Shell-Shell Sphere, Core-Shell Spheroid (by core R / total R)
  • 2 structure factors: Born-Green interferences, Hard Sphere (Percus-Yevick)
  • Monte Carlo uncertainty estimation
  • Modeling GUI guide

Unified Fit

Beaucage hierarchical model (1995, 1996) with 1-5 structural levels, each combining Guinier and power-law contributions. Optional Born-Green correlation function.

Size Distribution

Indirect Fourier transform to recover particle size distributions from SAS data. Four inversion methods: MaxEnt, Regularization, TNNLS, and Monte Carlo.

Simple Fits

15 direct analytical models: Guinier (sphere, rod, sheet), Porod, Power Law, Debye polymer chain, Sphere, Spheroid, Debye-Bueche, Teubner-Strey, Benedetti-Ciccariello, Hermans, Hybrid Hermans, Unified Born-Green, and the Invariant calculation. Each fit has linearization plots and Monte Carlo uncertainty estimation.

WAXS Peak Fit

Fit diffraction peaks (Gaussian, Lorentzian, Pseudo-Voigt, Log-Normal) on linear I vs Q scale. Auto-detect peaks via Savitzky-Golay + scipy.signal.find_peaks. Simultaneous background fitting (constant, linear, cubic, or 5th-order polynomial).

Data Merge

Merge two SAS datasets (e.g., SAXS + WAXS) onto a common Q scale. Optimizes scale factor, flat background, and optional Q-shift using Nelder-Mead.

Data Explorer

Browse NXcanSAS HDF5 files, inspect raw data and analysis results, extract and plot datasets, and export to Igor Pro h5xp format. Supports all pyIrena result types (Unified Fit, Sizes, Simple Fits, WAXS Peaks, Modeling).

Import Igor Experiment

Open an Igor Pro packed experiment (.pxp or .h5xp) and export each reduced USAXS/SAXS/WAXS sample as a stand-alone NXcanSAS .h5 file. Brings legacy and modern Igor data into pyIrena's analysis tools without re-reducing from raw detector files.

Scattering Contrast Calculator

Look up X-ray and neutron scattering length densities for materials by chemical formula. Computes contrast (Delta-rho-squared) between two materials.

Data Selector

Central GUI panel for managing data files and launching analysis tools. Load HDF5 files, select datasets, tabulate results across files, and generate reports.


Batch Scripting API

All analysis tools can be run headlessly from Python scripts or JSON configuration files:

from pyirena.batch import fit_pyirena

results = fit_pyirena(
    data_file='sample.h5',
    config_file='pyirena_config.json',
)

Individual functions: fit_unified, fit_sizes, fit_simple, fit_waxs, fit_modeling, merge_data.

See docs/guides/batch-api.md for the full scripting guide.


NXcanSAS I/O

All data and results are stored in HDF5 files using the NXcanSAS format. Fit results are saved alongside raw data, making files self-contained and shareable.


AI integration (MCP)

pyirena ships a Model Context Protocol server that exposes its HDF5 readers, parameter aggregation, and headless plotting to any MCP client — Claude Desktop, Claude Code, custom AI agents.

pip install pyirena[mcp]

Add to claude_desktop_config.json (or your client's MCP server config):

{
  "mcpServers": {
    "pyirena": {
      "command": "pyirena-mcp",
      "env": {
        "PYIRENA_DATA_ROOT": "/path/to/your/data",
        "PYIRENA_PLOT_CACHE": "/tmp/pyirena-plots",
        "PYIRENA_MAX_ARRAY_POINTS": "500"
      }
    }
  }
}

The agent can then call tools like pyirena_summarize_folder, pyirena_tabulate_parameter, pyirena_plot_iq, pyirena_read_modeling etc. to answer questions about analysis results in plain language. The underlying pyirena.api module is also usable as a regular Python library, with unprefixed names (api.summarize_folder, api.plot_iq, …) — no MCP needed.

Full instructions, including configs for Claude Desktop, Claude Code, and AnythingLLM:


Documentation

The documentation is published at https://jilavsky-docs.readthedocs.io/projects/pyirena/; the Help buttons in the GUI open the matching page there. The same pages, as Markdown, are in docs/:

Topic File
Installation docs/getting-started/installation.md
Quick start (GUI) docs/getting-started/quickstart.md
Modeling GUI guide docs/tools/modeling.md
Unified Fit GUI guide docs/tools/unified-fit.md
Size Distribution tool docs/tools/size-distribution.md
Size Distribution methods docs/methods/size-distribution-methods.md
Simple Fits GUI guide docs/tools/simple-fits.md
WAXS Peak Fit GUI guide docs/tools/waxs-peak-fit.md
Data Merge GUI guide docs/tools/data-merge.md
Data Explorer guide docs/tools/data-explorer.md
Import Igor Experiment (.pxp / .h5xp → NeXus) docs/guides/igor-pxp-import.md
Contrast Calculator guide docs/tools/scattering-contrast.md
NXcanSAS file format docs/reference/hdf5-nxcansas-structure.md
Batch fitting API docs/guides/batch-api.md
Usage guide (scripting) docs/guides/scripting-unified-fit.md
AI integration (MCP) — install & configure docs/guides/ai-integration.md
AI integration (MCP) — tool reference for agents docs/reference/ai-tools-reference.md
Developer: adding features (master checklist) docs/developer/adding-features.md
Developer: adding form factors docs/developer/adding-form-factors.md
Developer: adding structure factors docs/developer/adding-structure-factors.md
Testing docs/developer/testing.md
Distribution / packaging docs/developer/distribution.md
Contributing CONTRIBUTING.md
Changelog CHANGELOG.md

Citing pyIrena

If you use pyIrena in published work, please cite (open access):

Ilavsky, J. (2026). "Irena and pyIrena: 25 years of small-angle scattering analysis for complex materials, now with an AI-ready Python successor." J. Appl. Cryst. 59(6). https://doi.org/10.1107/S1600576726009647

The original Igor Pro Irena package: Ilavsky, J. & Jemian, P. R. (2009). J. Appl. Cryst. 42, 347–353. https://doi.org/10.1107/S0021889809002222


License

MIT -- see LICENSE.

Contact

Metadata

Release files for pyirena 1.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 pyirena 1.3.0
File Size Uploaded Provenance Actions
pyirena-1.3.0.tar.gz 1.2 MB Without provenance Details for pyirena-1.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.5 MB

Release files / pyirena-1.3.0.tar.gz

Download URL pyirena-1.3.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
c49b184a4bc83960515258f6f404894f25e00b56fe5780ea93fccf2daa360519
BLAKE2b-256 checksum
How to use checksums
d3463ff398b842ed739864be5981377256602ac3d77c1eeff6d36719d6b071be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / pyirena-1.3.0-py3-none-any.whl

Download URL pyirena-1.3.0-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
673d3ee3ccf0e1b3050c779365d86faf707299e516112d073fede058bbe873d4
BLAKE2b-256 checksum
How to use checksums
668b6fbb508a12a8edb22ba6800d37682bcb393678bf1d169b6f999f61b4b120
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Security for pyirena 1.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files No provenance

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