SANS Model Fitter
SANS-webapp
A Streamlit-based web application is now available for interactive SANS data analysis with a user-friendly interface.
Features
- 📤 Data Upload: Upload your SANS datasets (columnar CSV/.dat/.txt, CanSAS XML or NXcanSAS HDF5, read through sasdata)
- 🤖 AI-Assisted Model Selection: Get intelligent model suggestions based on your data
- 🎯 Manual Model Selection: Choose from all available SasModels
- ⚙️ Interactive Parameter Tuning: Adjust parameters with real-time UI controls
- 📊 Interactive Plots: Visualize data and fits with Plotly's zoom, pan, and export features
- 📏 Fit Q Range: Exclude beam-stop spillover or background-dominated points from the fit
- 📋 Fit Diagnostics: Reduced χ², convergence, parameters at a bound, and sans-fitter's fit report
- 💾 Export Results: Save fitted parameters and the fitted curve with residuals to CSV
Quick Start (Web App)
Requires Python >= 3.10 and sans-fitter >= 0.4.0 (pulled in automatically; numpy >= 2 and bumps >= 1 come with it).
# Install the application
pip install -e .
# Run the Streamlit app (choose one)
sans-webapp # CLI command
python -m sans_webapp # Module execution
The app will open in your browser at http://localhost:8501.
Install from PyPI
pip install sans-webapp
sans-webapp
Using the Web Application
- Upload Data: Use the sidebar to upload your SANS data file (columnar Q, I, dI[, dQ] text, CanSAS XML or NXcanSAS HDF5) or load the example dataset. A dI column is required for the bumps engine; a dQ column is applied as resolution smearing automatically
- Select Model:
- Manual: Choose from dropdown of all SasModels models
- AI-Assisted: Optionally provide an Anthropic (Claude) API key for AI-powered suggestions and MCP tool access, or use built-in heuristics
- Configure Parameters: Set initial values, bounds, and which parameters to fit
- Run Fit: Choose optimization engine (BUMPS or LMFit) and method, optionally restrict the fit Q range, then click "Run Fit"
- View Results: Interactive plots show data with error bars, the fitted curve and residuals; the panel reports the reduced χ² (χ²/dof), degrees of freedom, convergence and any parameter resting on a bound, plus sans-fitter's full fit report
- Export: Download fitted parameters, or the fitted curve with residuals, as CSV
Web App Deployment
Streamlit Cloud
- Push this repository to GitHub
- Go to share.streamlit.io
- Connect your GitHub account and deploy from the repository
- Set
src/sans_webapp/app.pyas the main file
Heroku
# The Procfile is already configured
# Deploy directly
heroku create your-app-name
git push heroku main
Docker
# Build image
docker build -t SANS-webapp-app .
# Run container
docker run -p 8501:8501 SANS-webapp-app
API Integration
The web app supports optional AI-powered model suggestions and MCP tool usage via Anthropic (Claude):
- Get an API key from Anthropic (https://console.anthropic.com/)
- Enter the key in the sidebar when using AI-Assisted mode
- Or set as environment variable:
export ANTHROPIC_API_KEY=your-key-here
Note: The app also works without an API key using built-in heuristic suggestions.
License
BSD 3-Clause License. See LICENSE for the full text.
References
- SasModels: https://github.com/SasView/sasmodels
- BUMPS: https://github.com/bumps/bumps
- LMFit: https://lmfit.github.io/lmfit-py/
- Streamlit: https://streamlit.io
- Plotly: https://plotly.com/python/
Metadata
Release files for sans-webapp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sans_webapp-0.1.0.tar.gz | 87.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sans_webapp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 153.1 kB
Release files / sans_webapp-0.1.0.tar.gz
| Download URL | sans_webapp-0.1.0.tar.gz |
|---|---|
| Size | 87.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06634069a14b2c65eb674917e481b7b77f0c16d0f7266e874cb7306ebc15ba80
|
|
BLAKE2b-256 checksum How to use checksums |
effae4ad1974d1c36c6c9cbcbd1d20cb88640b0f592d2f7ec858db6f41dad06e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / sans_webapp-0.1.0-py3-none-any.whl
| Download URL | sans_webapp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 65.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5ac7c524137b9721b706a13053d944e99d79adb798538fa924a0f2399cc8147
|
|
BLAKE2b-256 checksum How to use checksums |
e9877bb942575b7bd1ddafb1c0d4304c372a366a0c16e6d3e015961b319d3876
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log