-
Notifications
You must be signed in to change notification settings - Fork 30
Update examples and plotters for bumps webview #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
560d8a7
move polynomial model example to example/models
49dd290
rewrite sesans 2μ example to use bumps directly
b83ee18
update sesans Code Camp III example to use sasdata loader
20d6fac
update 2d fitting example to load data relative to model file
75a250b
update examples to use latex_smeared from sasdata example datasets
a5e2b7a
fix oriented usans example: Slit2D interface changed from qx_width,qy…
65c89ef
Rewrite plotters to a more compact layout, better suited to bumps; in…
8daeb6e
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 80b023f
nicer layout for sasmodels.compare plots
7dce76e
correct limits for 2d log plots
6e88cbb
don't return matplotlib figure; it confuses jupyter
767ef0c
make sure residuals plot uses same xscale as data; leave more room fo…
2099f29
use matplotlib backend in bumps fitter for now
cbb1e32
better 2D plots for matplotlib
f80b388
better 2D plots for matplotlib in bumps webview
621b2c5
Merge branch 'master' into fix-plotly-plotting
krzywon 1892f03
[pre-commit.ci lite] apply automatic fixes for ruff linting errors
pre-commit-ci-lite[bot] 88347c9
use plotly for bumps webview
bdbf066
fix 2D plots and enable plotly in webview
158c97e
bumps sliders do not support inf limits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,54 @@ | ||
| """ | ||
| This is a data file used to load in sesans data and fit it using the bumps engine | ||
|
|
||
| Usage: | ||
|
|
||
| bumps sesans_sphere_2micron.py | ||
| """ | ||
| import sesansfit | ||
| from bumps.names import Parameter | ||
| from bumps.names import FitProblem, Parameter | ||
|
|
||
| # Enter the model name to use | ||
| model_name = "sphere" | ||
| from sasdata import data_path | ||
|
|
||
| # DO NOT MODIFY THIS LINE | ||
| model = sesansfit.get_bumps_model(model_name) | ||
| from sasmodels.bumps_model import Experiment, Model | ||
| from sasmodels.core import load_model | ||
| from sasmodels.data import load_data | ||
|
|
||
| # Enter any custom parameters | ||
| # name = Parameter(initial_value, name='name') | ||
| phi = Parameter(0.0855, name='phi') | ||
| # Add the parameters to this list that should be displayed in the fitting window | ||
| custom_params = {"phi" : phi} | ||
| # Enter the model name and the datafile path | ||
| model_name = "sphere" | ||
| data_file = data_path / "sesans_data" / "sphere2micron.ses" | ||
|
|
||
| # SESANS data file name | ||
| sesans_file = "spheres2micron.ses" | ||
| # Custom parameters for use in expressions | ||
| # name = Parameter(initial_value, name='name') | ||
| phi = Parameter(0.0855, name='phi') # scale = phi*(1-phi) | ||
|
|
||
| # Initial parameter values (if other than defaults) | ||
| # "model_parameter_name" : value | ||
| initial_vals = { | ||
| # Initial parameter values and expressions (if other than defaults) | ||
| # "model_parameter_name" : value or expression | ||
| pars = { | ||
| "scale": phi*(1-phi), | ||
| "sld" : 1.41, | ||
| "radius" : 10000, | ||
| "sld_solvent" : 2.70, | ||
| } | ||
|
|
||
| # Ranges for parameters if other than default | ||
| # "model_parameter_name" : [min, max] | ||
| param_range = { | ||
| "phi" : [0.001, 0.5], | ||
| "radius" : [100, 100000] | ||
| } | ||
| # DO NOT MODIFY THIS LINE | ||
| model = Model(load_model(model_name), **pars) | ||
|
|
||
| # Constraints | ||
| # Bounds constraints | ||
| # model.param_name = f(other params) | ||
| # EXAMPLE: model.scale = model.radius*model.radius*(1 - phi) - where radius | ||
| # and scale are model functions and phi is a custom parameter | ||
| model.scale = phi*(1-phi) | ||
| model.radius.range(100, 100000) | ||
| phi.range(0.001, 0.5) | ||
|
|
||
|
|
||
| # Send to the fitting engine | ||
| # DO NOT MODIFY THIS LINE | ||
| problem = sesansfit.sesans_fit(sesans_file, model, initial_vals, custom_params, param_range) | ||
| # DO NOT MODIFY THESE LINES | ||
| data = load_data(str(data_file)) | ||
| M = Experiment(data=data, model=model) | ||
| problem = FitProblem([M]) | ||
|
|
||
| if __name__ == "__main__": | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| print(f"==== {model_name} model for {data_file.name} has χ² = {problem.chisq_str()} ====") | ||
| print(problem.summarize()) | ||
| problem.plot() | ||
| plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.