Skip to content

Add module for combining SasView models with reflectivity data#11

Open
hoogerheide wants to merge 14 commits intomainfrom
sasrefl
Open

Add module for combining SasView models with reflectivity data#11
hoogerheide wants to merge 14 commits intomainfrom
sasrefl

Conversation

@hoogerheide
Copy link
Collaborator

Sometimes reflectivity data have features that look like they might come from small angle scattering. Usually this means the sample needs to be re-made, but there are cases where this might actually be useful data, and other cases where the sources of the small angle scattering can otherwise not be removed.

This PR is for an Experiment-like object that combines SANS and reflectivity data into a single curve, and exposes the parameters of the sasmodels SANS model as Bumps parameters. The model specification includes the SANS model name, a dictionary of parameter values, and a transverse angular resolution dtheta_l which is used to smear the SANS data.

A custom decomposition plot into I(q) and R(q) is registered as well.

@hoogerheide
Copy link
Collaborator Author

This is an example script. You can put it any dummy data for this to work.

test_sas_script.py

@hoogerheide
Copy link
Collaborator Author

This is an example script. You can put it any dummy data for this to work.

test_sas_script.py

Now look at the tiox_dopc_sas.py example in the repo

@hoogerheide
Copy link
Collaborator Author

One note on this -- the calculation is quite slow. Loading the model takes about 0.3 seconds; the DirectModel instantiation takes about 0.03 seconds, and the calculation itself is quite fast. I'm not sure why it's slow given this; is FitProblem re-created on each calculation node every time a new data point is sent?

@bmaranville
Copy link
Member

bmaranville commented Feb 3, 2026

All the mappers in bumps are designed to create workers that are set up only once per fit.
The problem is deserialized on each worker at the start of the fit, then the mapper feeds parameter vectors to the workers, which call problem.nllf(pvec) for each set of parameters.

…d setstate to support problem copying and pickling
Copy link
Member

@bmaranville bmaranville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good - when we refactor the plot registry you'll have to change the register_webview_plot bit, but that's going to be a small change on this end (a bigger change on the bumps end)

@hoogerheide
Copy link
Collaborator Author

Just improved the abstraction to allow both standard SAS models as well as full integration (spherical geometry only because this is the only multi-shell model supported by sasmodels at the moment) with MolgroupsLayer objects. This allows one to calculate the small angle scattering directly from molgroups layers. Also registers the molgroups plots.

After this PR is merged I will work on a direct SAS calculator a la sasmodels.bumps_model that supports serialization and molgroups functionality.

@hoogerheide
Copy link
Collaborator Author

There's an issue with this PR that the CVO uncertainty plots don't work for the SAS models. This is because the plots are expecting the molgroups layer to show up in a particular place (model.sample.molgroups_layer) but this doesn't exist on the SAS models. The right way to do this is to have the Experiment objects expose a dictionary of molgroups layers associated with them, and then the worker function can go look them up by name. I will implement and test this before merging this PR.

@hoogerheide
Copy link
Collaborator Author

There's an issue with this PR that the CVO uncertainty plots don't work for the SAS models. This is because the plots are expecting the molgroups layer to show up in a particular place (model.sample.molgroups_layer) but this doesn't exist on the SAS models. The right way to do this is to have the Experiment objects expose a dictionary of molgroups layers associated with them, and then the worker function can go look them up by name. I will implement and test this before merging this PR.

Resolved by most recent pushes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants