-
Notifications
You must be signed in to change notification settings - Fork 47
Update install instructions, Readme, and add resources #3753
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
+321
−27
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
12edd91
updated install instructions
TLO218 d8930c0
added resoures file
TLO218 86e40c0
attempt to fix CI Badge
TLO218 c287928
remove CI badge add logo and tutorial repo
TLO218 fdb5b34
removed transparency from hello_world.png
TLO218 2628a3e
Update README.md
drnpaul c6a4d2d
Update RESOURCES.md
TLO218 1869e15
Update RESOURCES.md
drnpaul 4a6428a
implemented suggestionsfrom PR
TLO218 2399e3a
asdas
TLO218 3f8f6cc
Revert "asdas"
TLO218 e255448
-
TLO218 487e76e
Revert "-"
TLO218 c2f171e
implemented changes
TLO218 ba5f217
fixed typos in the install files
TLO218 cc0ad9c
tidying up
TLO218 cbfcb3f
remove CI badge
TLO218 b8db75d
fix simpleexample.png
TLO218 3f7486d
Merge branch 'main' into update_install_instructions
TLO218 9d070d5
Remove whitespace around links that gets rendered
llimeht c279d2e
Fix typos in README.md
llimeht 83d499c
Improve installation instructions in README.md
llimeht ee0eb6e
Correct Python versions note in INSTALL.md
llimeht d767304
Improve installation intro notes in INSTALL.md
llimeht 61b618e
Fix stray reference to venv
llimeht 6cac59e
Use bold not tt for Note
llimeht 65f5498
Use consistent spacing around comments in instructions
llimeht 130a008
Make links rather than include full URLs
llimeht ca353d8
Add (re)install instructions for working on docs
llimeht 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
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,7 +1,170 @@ | ||
| [SasView](http://www.sasview.org) is a Small Angle Scattering (SAS) analysis package for the analysis of 1D and 2D scattering data directly in inverse space. The focus was originally on neutron data (SANS) but has been used for X-ray’s as well and includes a tool for determining a slit resolution for the SAXSess instrument. SansView also includes PrView to invert SAS data to P(r), a resolution calculator, and a scattering length density calculator among others tools. A simple plugin mechanism is available for users to add custom models. | ||
|  | ||
|
|
||
| This project was initiated by the NSF funded DANSE project, DMR-0520547, SANS sub-project at the University of Tennessee Knoxville. Acknowledgement of that original funding would be appreciated in any publications that make use of the software. | ||
| <div align='center'> | ||
| <a href="https://github.com/SasView/sasview/releases/latest"><img src="https://img.shields.io/github/v/release/SasView/sasview" alt="Latest Release" /></a> | ||
| <a href="https://github.com/SasView/sasview/commits/main"><img src="https://img.shields.io/github/last-commit/SasView/sasview" alt="Last Commit" /></a> | ||
| <a href="https://sasview.org"><img src="https://img.shields.io/website-up-down-green-red/http/sasview.org.svg" alt="Website Status" /></a> | ||
| <a href="https://opensource.org/licenses/bsd-3-clause"><img src="https://img.shields.io/badge/License-BSD-brightgreen" alt="License"></a> | ||
| </div> | ||
|
|
||
| This project receives funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 654000 | ||
| --- | ||
|
|
||
| # General | ||
|
|
||
| [SasView](http://www.sasview.org) is a Small Angle Scattering (SAS) analysis package for the analysis of 1D and 2D scattering data directly in inverse space. | ||
| The focus was originally on neutron data (SANS) but has been used for X-rays as well and includes a tool for determining a slit resolution for the SAXSess instrument. | ||
| SasView also includes PrView to invert SAS data to P(r), a resolution calculator, and a scattering length density calculator among others tools. | ||
| A simple plugin mechanism is available for users to add custom models. | ||
|
|
||
| # Acknowledgement | ||
llimeht marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| This project was initiated by the NSF-funded DANSE project, DMR-0520547, a SANS sub-project at the University of Tennessee. Acknowledgement of that original funding would be appreciated in any publications that make use of the software. | ||
|
|
||
| This project received funding from the European Union’s Horizon 2020 research and innovation programme under the SINE2020 project, grant agreement No 654000. | ||
|
|
||
| [SasView website](http://www.sasview.org) | ||
|
|
||
| The latest stable releases of SasView can be found on the website. | ||
| The following instructions will focus on providing materials for scripting, developing and would lead you to the most important resources. | ||
|
|
||
| # Install instructions | ||
|
|
||
| ## Users | ||
|
|
||
| Users can install SasView either from the installers listed on the [SasView website](http://www.sasview.org), | ||
| or directly from the packages distributed by `pip`. | ||
|
|
||
| ### Install using `pip` inside a virtual environment in the current directory: | ||
|
|
||
|
|
||
| ```shell | ||
| python -m venv .venv # create the environment | ||
TLO218 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| . .venv/bin/activate # activate the environment on linux and MacOS | ||
| # .venv\Scripts\activate & REM Windows: activate environment | ||
|
|
||
| python -m pip install sasview | ||
|
|
||
| python -m sas # launch the gui | ||
| ``` | ||
|
|
||
| ### Install using `uv` for your user: | ||
|
|
||
| ```shell | ||
| uv tool install sasview | ||
|
|
||
| uvx sasview # launch the gui | ||
| ``` | ||
|
|
||
| **Note:** To launch SasView, it needs to be installed. | ||
| Running SasView from a source directory is not supported. | ||
|
|
||
| ## Developers | ||
|
|
||
| The installation instructions for developers can be found [here](INSTALL.md). | ||
| Installing the development-version of SasView with conda is currently not supported. | ||
| `NOTE:` In case you want to contribute, please also checkout the [DevelopersNotes](https://github.com/SasView/sasview/wiki/DevNotes_DevGuide_GettingStarted). | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Scripting | ||
|
|
||
| This section is a small scripting example in SasView to check your installation. | ||
| We will fit a simple sphere model. For this first lets synthesize input data. | ||
|
|
||
| ```python | ||
| import numpy as np | ||
| from sasmodels.bumps_model import Model | ||
| from sasmodels.core import load_model | ||
| from sasmodels.direct_model import call_kernel | ||
|
|
||
| # define q vector | ||
| q = np.logspace(-3, -0.1, 200) | ||
|
|
||
| # define the model | ||
| exp_model = load_model("sphere") | ||
| exp_pars = { | ||
| "radius": 50, | ||
| "sld": 1, | ||
| "sld_solvent": 6, | ||
| "scale": 1, | ||
| "background": 0.001, | ||
| } | ||
|
|
||
| # calculate intensities | ||
| Iq = call_kernel(exp_model.make_kernel([q]), exp_pars) | ||
|
|
||
| # calculate errors and normalize data | ||
| max_counts = 1e7 # approximate number of counts at first q values | ||
| norm = Iq[0] / max_counts | ||
| counts = np.random.poisson((Iq / norm).astype(int)) | ||
| errors = np.sqrt(counts) * norm | ||
| data = counts * norm | ||
| dataset = np.array([q, data, errors]).T | ||
|
|
||
| # saving the data | ||
| header = ( | ||
| "Neutron-like data generated for model " | ||
| + exp_model.info.name | ||
| + " with parameters:\n" | ||
| ) | ||
| for key in exp_pars.keys(): | ||
| header += key + " = " + str(exp_pars[key]) + "\n" | ||
| header += "Q\t counts\t error" | ||
|
|
||
| np.savetxt("scattering.txt", dataset, fmt="%12.6e", delimiter="\t", header=header) | ||
| ``` | ||
|
|
||
| ...and now let's do the fitting. We will optimize the scale, radius and background starting from an inital values close to the ground truth. | ||
|
|
||
| ```python | ||
| import matplotlib.pyplot as plt | ||
| from sasmodels.bumps_model import Model, Experiment | ||
| from sasmodels.core import load_model | ||
| from sasmodels.data import load_data | ||
| from bumps.fitters import fit | ||
| from bumps.names import FitProblem | ||
|
|
||
| # defining the model to fit | ||
| fit_pars = { | ||
| "radius": 80, | ||
| "sld": 1, | ||
| "sld_solvent": 6, | ||
| "scale": 0.900, | ||
| "background": 0.05, | ||
| } | ||
| fit_kernel = load_model("sphere") | ||
| fit_model = Model(fit_kernel, **fit_pars) | ||
|
|
||
| ## setting fitting ranges | ||
| fit_model.radius.range(10, 1000) | ||
| fit_model.scale.range(1e-3, 10) | ||
| fit_model.background.range(1e-9, 0.1) | ||
|
|
||
| # load the data we synthesized above | ||
| exp_data = load_data("scattering.txt") | ||
|
|
||
| # Setup the experiments, sharing the same model across all datasets. | ||
| M = Experiment(data=exp_data, model=fit_model, name="MyAwsomeFit") | ||
|
|
||
| problem = FitProblem(M) | ||
|
|
||
| plt.figure() | ||
| problem.plot(view=True) | ||
TLO218 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # fit the results | ||
| result = fit(problem, method="dream") | ||
|
|
||
| print(f"Final chisq {problem.chisq()}\n") | ||
| problem.plot() | ||
| for k, v, dv in zip(problem.labels(), result.x, result.dx): | ||
| print(f"{k} : {v:.4f} +- {dv:.4f}") | ||
| plt.show() | ||
| ``` | ||
|
|
||
| This simple fit should results in a $\chi^2$ close to one. | ||
|
|
||
|  | ||
|
|
||
| # Resources | ||
|
|
||
| In case you are just getting started or you want to contribute please checkout some selected [resources](/RESOURCES.md). | ||
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.