Skip to main content

Python tools for small-angle scattering data analysis.

Project description

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: v0.6.0 (public beta)

PyPI version Python Version License: MIT


Installation

From PyPI (recommended):

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.

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

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 HDF5 Viewer / Data Extractor
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, Treubner-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.

HDF5 Viewer / Data Extractor

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

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.


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
HDF5 Viewer guide docs/hdf5_viewer_gui.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
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

Project details


Download files

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

Source Distribution

pyirena-0.6.0.tar.gz (551.7 kB view details)

Uploaded Source

Built Distribution

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

pyirena-0.6.0-py3-none-any.whl (558.4 kB view details)

Uploaded Python 3

File details

Details for the file pyirena-0.6.0.tar.gz.

File metadata

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

File hashes

Hashes for pyirena-0.6.0.tar.gz
Algorithm Hash digest
SHA256 e9252994262b4b7b7c660948d02d8f0a3f8a2adccb4f40d4740ee6b8b065bc0f
MD5 674951db5788e041f5e378ef3af8b3b7
BLAKE2b-256 497f2fee8842d507a6cf6d721e274dc98c935f53025177ab496d7928ff64f47d

See more details on using hashes here.

File details

Details for the file pyirena-0.6.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pyirena-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0848293d388966b680eebc5e50cbc9f343d2e10f42678d4ad31d92b81ae5c5e1
MD5 9a15704c0ec88211a84745c48ae55831
BLAKE2b-256 9becf5e3302d0b23aa136b5310b9bdf0f6c930debbaef3e8d8b3792c3c9c9974

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page