A PyQt-based interactive application to explore scattering models using the sasmodels
library.
This app enables visualization and fine-tuning of model parameters via a user-friendly GUI, featuring both sliders and dropdown menus for parameter adjustments, and a real-time plot of scattering intensity.
- Interactive Parameter Controls: Adjust model parameters with sliders, text boxes, and dropdowns.
- Real-Time Plotting: View scattering intensity plots that update in real time as parameters are adjusted.
- Polydispersity Support: Automatically includes polydispersity controls for relevant parameters.
- Custom Model Loading: Load any supported
sasmodels
model by typing its name and pressing Enter. - Command-Line Interface (CLI): Run the app or interact with models directly via the command line.
- clone the repository:
git clone https://github.com/BAMresearch/SasModelsExplorer.git
cd SasModelsExplorer
- (optional). setup a virtual enviroment for this explorer:
python3.12 -m venv .venv
- (optional). activate the virtual environment:
source .venv/bin/activate
- install the dependencies:
pip install -r requirements.txt
- install this package:
pip install -e .
- run the app:
python -m ModelExplorer -v sphere@hardsphere
- (optional) deactivate the virtual environment:
deactivate
Type the model name (e.g., "sphere", "cylinder", or sasmodels-syntax combinations such as "sphere@hardsphere+cylinder") in the model field and press Enter to load it. The app will display parameter controls for the model.
Sliders and Text Boxes: Each parameter has an adjustable slider and a text box for exact values. Logarithmic sliders enable wide-range adjustments. Dropdown Menus: Parameters with multiple text options (e.g., _pd_type for polydispersity) appear as dropdowns. Polydispersity Controls: Automatically includes controls for relevant parameters: polydispersity and (default number-weighted) distribution shape. Axis controls: Under the graph, the q limits and q units can be adjusted.
Try these models to get started:
"sphere"
: Spherical scatterer model."cylinder"
: Cylindrical scatterer model."sphere@hardsphere"
: sphere model with a hard-shell structure factor."sphere@hardsphere+porod"
: sphere model with a hard-shell structure factor and additional Porod slope.
The entire sasmodels library is available, which you can combine, multiply, subtract with the syntax alluded to above... A help text with the available models is displayed when a nonexistent model is entered.
The application uses logging
for tracking parameter changes:
- Logs are printed in the console to show current parameter values.
- To enable detailed logs, set the logging level to
DEBUG
in the code or use the -vv option at the CLI.
Also check the "issues" in the Github repository.
- The app currently does not display 2D scattering models. They will probably not be fast enough to be fun anyway
- There is an issue clearing the parameters when entering a new model, causing the new parameters to be shifted down in the UI.
- There should be a timeout for model calculations that take long.
- The font in the help dialog is not monospaced, which makes it hard to read.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License.