This release is a pre-release and may not be stable for production use.
Anisa
Small-angle scattering (SAXS / USAXS / SANS) modelling of anisotropic particle populations.
Anisa fits populations of spheroids with orientation distributions to several 1D cuts I(Q), each measured along a different direction of Q in the sample frame. It is the Python successor of the Igor Pro AnisoSAS macros (theory: A. J. Allen, NIST 2001). Compared with the Igor version it is faster, uses multiple cores, and has no fixed limit on the number of directions or populations.
Status: beta. The engine, data input, fitting, GUI, results files, command line, MCP server and Bernardyn export are done and tested on synthetic data; it has not yet been validated on real measurements, so expect changes. See PLAN.md for the plan and progress.
Quick install (from PyPI)
You need Python 3.10, 3.11, 3.12 or 3.13 (3.12 recommended). Newer versions (3.14, 3.15, ...) do not work yet, because some of the libraries Anisa depends on are not available for them. If your Python is newer, install 3.12 from python.org/downloads (older releases are listed there too) alongside it; do not remove the newer one.
Check which Python you have:
python --version # macOS / Linux: try python3 --version. Windows: try py --version
Then, in a terminal (Windows: Command Prompt or PowerShell), create a private environment for Anisa, install it with the GUI, and start it:
Windows
py -3.12 -m venv anisa-env
anisa-env\Scripts\activate
python -m pip install --upgrade pip
pip install "anisa[gui]"
anisa-gui
macOS / Linux
python3.12 -m venv anisa-env
source anisa-env/bin/activate
python -m pip install --upgrade pip
pip install "anisa[gui]"
anisa-gui
(Use 3.10, 3.11 or 3.13 in place of 3.12 if that is what you have installed.) The first
line creates the environment, the second switches into it (your prompt then starts with
(anisa-env)), the last starts the program. Next time, only repeat the activate line and
anisa-gui. To update later: pip install --upgrade "anisa[gui]".
Try it without your own data: in the program choose File → Create test system, pick any system, and press Fit. It writes synthetic data with known parameters and shows the fit recovering them.
What the install options give you:
| Command | Installs |
|---|---|
pip install anisa |
calculation, command line anisa, no window (no Qt) |
pip install "anisa[gui]" |
the above plus the graphical program anisa-gui |
pip install "anisa[mcp]" |
the above plus the anisa-mcp server for AI agents |
Problems? pip install says No matching distribution or requires a different Python: your
Python is too new or too old (see the box above). anisa-gui is not found: the environment is
not activated. Already using pyIrena or Bernardyn? Install Anisa into the same environment
(pip install "anisa[gui]"); it does not change their Qt version.
Alternative: conda, from the GitHub source
Download or clone github.com/jilavsky/anisa, then in that folder:
conda env create -f environment.yml # creates the "anisa" environment
conda activate anisa
anisa-gui
For developers: pip install -e ".[gui,dev]" in a checkout. The GUI uses PySide6 (never PyQt6).
The repository also has ready-made synthetic data in testdata/.
Anisa is part of the pyIrena family:
- pyIrena — data input (NXcanSAS HDF5 and ASCII) and shared GUI pieces.
- Bernardyn — publication plots.
- Aida — agent workbench, which will use the Anisa MCP server.
All of them install into the same Python environment.
Using the GUI
anisa-gui # or: python -m anisa.gui (after activating the environment)
- File → Create test system writes a synthetic data set with known parameters (prolate,
oblate, both with different alignment, interference, spheres, 12 directions;
TRUTH.txtlists the answer) and opens it with perturbed starting values; press Fit to see it recover them. Create demo data… does the same for the three-population coating example. (Or Add data… / drag files onto the directions table to load your own: NXcanSAS HDF5 or text.) - Give each direction its angles α_Q (from the sample normal) and ω_Q (azimuth) in the table.
- Set the particle parameters of each population, tick Fit? for those to vary, and press Fit. The errors appear next to the fitted values; Uncertainty… refits re-drawn data for a Monte-Carlo estimate; Revert fit returns to the values before the fit.
- The Anisotropy tab shows the model as a function of the direction of Q (polar plots, or I(angle)) with your measured cuts on top, which is the quickest check that the orientation distributions make sense.
After a fit, File → Save results (HDF5)… writes one NAME.anisa.h5 with the data, model
curves, parameters and errors of all directions (an NXcanSAS entry per direction, so pyIrena
opens each); File → Open reads it back.
Command line
anisa testdata folder --system prolate_oblate # synthetic data with known truth
anisa info folder/prolate_oblate/prolate_oblate_start.anisa.json
anisa fit folder/prolate_oblate/prolate_oblate_start.anisa.json --mc 20 --text
anisa calc project.anisa.json --results out.anisa.h5
anisa export-bernardyn project.anisa.json plot # needs Bernardyn installed
anisa anisotropy project.anisa.json --sweep alpha --fixed 0 --q 0.01 0.05 --csv scan.csv
The project file is the one the GUI saves; every command prints JSON (anisa.api has the same
functions for Python).
MCP server (agents)
pip install "anisa[mcp]"
ANISA_DATA_ROOT=/path/to/data anisa-mcp # stdio server
aida mcp server add anisa --command anisa-mcp # register with Aida
Tools (anisa_ prefix): list_files, describe, calculate, fit, anisotropy,
read_results, list_test_systems, write_test_system. They are the anisa.api functions;
file access is confined to ANISA_DATA_ROOT (default: the working directory).
Example
import numpy as np
from anisa.core import AnisaModel, Direction, Population, Engine
from anisa.core.orientation import AngularDistribution
# oblate disks (beta = 0.2) with their axes along the sample z axis
pop = Population(radius=800.0, beta=0.2, volume_fraction=0.03, delta_rho=2e11,
alpha_dist=AngularDistribution(par1=0.0, par2=12.0))
model = AnisaModel([Direction(alpha_q=0.0), Direction(alpha_q=90.0)], [pop])
q = np.geomspace(1e-4, 0.1, 200)
result = Engine().evaluate(model, [q, q])
along_z, across_z = (d.intensity for d in result.directions) # I(Q) in 1/cm
Any number of directions and populations is allowed. Parameters and their Igor names: docs/parameters.md.
Synthetic multi-direction data with known parameters, for trying things out:
python -m anisa.demo demo_data # NXcanSAS files + demo.anisa.json (the truth)
from anisa.core import fit
from anisa.io.project import load_project
model = load_project("demo_data/demo_start.anisa.json") # perturbed start, fit flags set
result = fit(model) # model now holds the best parameters
for p in result.parameters:
print(p.parameter.label, p.value, "+-", p.std)
Units
- Q in Å⁻¹.
- Intensity in cm⁻¹ (absolute).
- Radii in Å.
- Scattering contrast Δρ in cm⁻² (Δρ, not Δρ²).
- Angles in degrees.
License
MIT — see LICENSE.
Metadata
Release files for anisa 0.0.1b2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anisa-0.0.1b2.tar.gz | 144.2 kB | Without provenance | Details for anisa-0.0.1b2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anisa-0.0.1b2-py3-none-any.whl | Python 3 | none | any | Details for anisa-0.0.1b2-py3-none-any.whl |
Total release size: 261.2 kB
Release files / anisa-0.0.1b2.tar.gz
| Download URL | anisa-0.0.1b2.tar.gz |
|---|---|
| Size | 144.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
114be76683f8ffb3068b0e8b02db5bc09d67852cb1504c37f982ffff5f0e4c26
|
|
BLAKE2b-256 checksum How to use checksums |
406156521eaabd7a5493051e1cfbb36cdf95b5a7e9104eb7711edf7ba7cce67a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / anisa-0.0.1b2-py3-none-any.whl
| Download URL | anisa-0.0.1b2-py3-none-any.whl |
|---|---|
| Size | 117.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
614fcf094819f794734a5b54abb1e8b679f70f9f34c290540018c7bad7e3090f
|
|
BLAKE2b-256 checksum How to use checksums |
d9761fc8b9b5c3714b38d1205b59ce44ffe8db85725f980a8921a7b962661717
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for anisa 0.0.1b2
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.