Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.0.1

Current beta release: v1.1.0b10

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.1.0b10) 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 beta rather than whatever is newest:

pip install "pyirena[gui]==1.1.0b10"

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/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/gui_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

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
  • 9 form factors: Sphere, Spheroid, Cylinder (aspect ratio / fixed length), Core-Shell Sphere and Spheroid (by core R / shell t / 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

13 direct analytical models: Guinier, Guinier-Porod, Porod, Sphere, Spheroid, Debye-Bueche, Teubner-Strey, Power Law, and more. Each with 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/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

Topic File
Installation docs/installation.md
Quick start (GUI) docs/gui_quickstart.md
Modeling GUI guide docs/modeling_gui.md
Unified Fit GUI guide docs/unified_fit_gui.md
Unified Fit features & parameters docs/unified_fit_features.md
Size Distribution methods docs/sizes_methods.md
Simple Fits GUI guide docs/simple_fits_gui.md
WAXS Peak Fit GUI guide docs/waxs_peakfit_gui.md
Data Merge GUI guide docs/data_merge_gui.md
Data Explorer guide docs/hdf5_viewer_gui.md
Import Igor Experiment (.pxp / .h5xp → NeXus) docs/igor_pxp_import.md
Contrast Calculator guide docs/scattering_contrast_gui.md
NXcanSAS file format docs/NXcanSAS_UnifiedFit_Format.md
Batch fitting API docs/batch_api.md
Usage guide (scripting) docs/usage_guide.md
AI integration (MCP) — install & configure docs/ai_integration.md
AI integration (MCP) — tool reference for agents docs/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/testing.md
Distribution / packaging docs/distribution.md
Contributing CONTRIBUTING.md
Changelog CHANGELOG.md

License

MIT -- see LICENSE.

Contact

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyirena-1.1.0b10.tar.gz (985.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyirena-1.1.0b10-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file pyirena-1.1.0b10.tar.gz.

File metadata

  • Download URL: pyirena-1.1.0b10.tar.gz
  • Upload date:
  • Size: 985.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyirena-1.1.0b10.tar.gz
Algorithm Hash digest
SHA256 67f0285aac541dbf291ed35fdb773a2cdb459757c32c870b30d44189fde1d7d5
MD5 4ba74e9b87d4e864b733808b3518d7f7
BLAKE2b-256 7ea2d3e9361471b47aae3a80da9c17807d2fea55d89b80f5d8a26602dcec65ce

See more details on using hashes here.

File details

Details for the file pyirena-1.1.0b10-py3-none-any.whl.

File metadata

  • Download URL: pyirena-1.1.0b10-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyirena-1.1.0b10-py3-none-any.whl
Algorithm Hash digest
SHA256 302f3ef5a780aa3b6cb3793a48f369fc84ed9529e0bf4d50cadf34b7066e7e75
MD5 16e8b33a9df5b4ab28cb0ffcd940601d
BLAKE2b-256 8aa67c6b95316d830d33c8362ccb79133b42a5f266b2348fea17227b75cfd52e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0b10 This release

2 files

1.0.1

2 files

1.0.0

2 files

0.10.0

2 files

0.9.9

2 files

0.9.7

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.1

2 files

0.8.5

2 files

0.8.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.5

2 files

0.6.4

2 files

0.6.2

2 files

0.6.0

2 files

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.3.4

2 files

0.3.3

2 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