Skip to main content

SANS Model Fitter

Tests PyPI badge Codacy Badge

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

  1. 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
  2. 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
  3. Configure Parameters: Set initial values, bounds, and which parameters to fit
  4. Run Fit: Choose optimization engine (BUMPS or LMFit) and method, optionally restrict the fit Q range, then click "Run Fit"
  5. 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
  6. Export: Download fitted parameters, or the fitted curve with residuals, as CSV

Web App Deployment

Streamlit Cloud

  1. Push this repository to GitHub
  2. Go to share.streamlit.io
  3. Connect your GitHub account and deploy from the repository
  4. Set src/sans_webapp/app.py as 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):

  1. Get an API key from Anthropic (https://console.anthropic.com/)
  2. Enter the key in the sidebar when using AI-Assisted mode
  3. 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

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)

Source distribution for sans-webapp 0.1.0
File Size Uploaded
sans_webapp-0.1.0.tar.gz 87.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sans-webapp 0.1.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release 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