[241b617] | 1 | Sasmodels |
---|
| 2 | ========= |
---|
| 3 | |
---|
| 4 | Theory models for small angle scattering. |
---|
| 5 | |
---|
| 6 | The models provided are usable directly in the bumps fitting package and |
---|
| 7 | in the sasview analysis package. If OpenCL is available, the models will |
---|
| 8 | run much faster. If not, then precompiled versions will be included with |
---|
| 9 | the distributed package. New models can be added if OpenCL or a C compiler |
---|
| 10 | is available. |
---|
| 11 | |
---|
[ade01a0] | 12 | Install |
---|
[241b617] | 13 | ------- |
---|
| 14 | |
---|
[f8a6e4a] | 15 | The easiest way to use sasmodels is from `SasView <http://www.sasview.org/>`_. |
---|
[ade01a0] | 16 | |
---|
[2a64722] | 17 | You can also install sasmodels as a standalone package in python. Use |
---|
[f8a6e4a] | 18 | `miniconda <https://docs.conda.io/en/latest/miniconda.html>`_ |
---|
[2a64722] | 19 | or `anaconda <https://www.anaconda.com/>`_ |
---|
| 20 | to create a python environment with the sasmodels dependencies:: |
---|
[ade01a0] | 21 | |
---|
| 22 | $ conda create -n sasmodels -c conda-forge numpy scipy matplotlib pyopencl |
---|
| 23 | |
---|
[2a64722] | 24 | The option ``-n sasmodels`` names the environment sasmodels, and the option |
---|
| 25 | ``-c conda-forge`` selects the conda-forge package channel because pyopencl |
---|
[ade01a0] | 26 | is not part of the base anaconda distribution. |
---|
| 27 | |
---|
| 28 | Activate the environment and install sasmodels:: |
---|
| 29 | |
---|
| 30 | $ conda activate sasmodels |
---|
| 31 | (sasmodels) $ pip install sasmodels |
---|
| 32 | |
---|
[f8a6e4a] | 33 | Install `bumps <https://github.com/bumps/bumps>`_ if you want to use it to fit |
---|
[ade01a0] | 34 | your data:: |
---|
| 35 | |
---|
| 36 | (sasmodels) $ pip install bumps |
---|
| 37 | |
---|
| 38 | Usage |
---|
| 39 | ----- |
---|
| 40 | |
---|
| 41 | Check that the works:: |
---|
| 42 | |
---|
| 43 | (sasmodels) $ python -m sasmodels.compare cylinder |
---|
| 44 | |
---|
| 45 | To show the orientation explorer:: |
---|
| 46 | |
---|
| 47 | (sasmodels) $ python -m sasmodels.jitter |
---|
| 48 | |
---|
| 49 | Documentation is available online as part of the SasView |
---|
| 50 | `fitting perspective <http://www.sasview.org/docs/index.html>`_ |
---|
| 51 | as well as separate pages for |
---|
| 52 | `individual models <http://www.sasview.org/docs/user/sasgui/perspectives/fitting/models/index.html>`_. |
---|
| 53 | Programming details for sasmodels are available in the |
---|
| 54 | `developer documentation <http://www.sasview.org/docs/dev/dev.html>`_. |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | Fitting Example |
---|
| 58 | --------------- |
---|
| 59 | |
---|
[241b617] | 60 | The example directory contains a radial+tangential data set for an oriented |
---|
| 61 | rod-like shape. |
---|
| 62 | |
---|
[ade01a0] | 63 | To load the example data, you will need the SAS data loader from the sasview |
---|
| 64 | package. This is not yet available on PyPI, so you will need a copy of the |
---|
| 65 | SasView source code to run it. Create a directory somewhere to hold the |
---|
| 66 | sasview and sasmodels source code, which we will refer to as $SOURCE. |
---|
[241b617] | 67 | |
---|
[ade01a0] | 68 | Use the following to install sasview, and the sasmodels examples:: |
---|
[241b617] | 69 | |
---|
[ade01a0] | 70 | (sasmodels) $ cd $SOURCE |
---|
| 71 | (sasmodels) $ conda install git |
---|
| 72 | (sasmodels) $ git clone https://github.com/sasview/sasview.git |
---|
| 73 | (sasmodels) $ git clone https://github.com/sasview/sasmodels.git |
---|
[241b617] | 74 | |
---|
[ade01a0] | 75 | Set the path to the sasview source on your python path within the sasmodels |
---|
| 76 | environment. On Windows, this will be:: |
---|
[241b617] | 77 | |
---|
[ade01a0] | 78 | (sasmodels)> set PYTHONPATH="$SOURCE\sasview\src" |
---|
| 79 | (sasmodels)> cd $SOURCE/sasmodels/example |
---|
| 80 | (sasmodels)> python -m bumps.cli fit.py cylinder --preview |
---|
| 81 | |
---|
| 82 | On Mac/Linux with the standard shell this will be:: |
---|
| 83 | |
---|
| 84 | (sasmodels) $ export PYTHONPATH="$SOURCE/sasview/src" |
---|
| 85 | (sasmodels) $ cd $SOURCE/sasmodels/example |
---|
| 86 | (sasmodels) $ bumps fit.py cylinder --preview |
---|
[241b617] | 87 | |
---|
| 88 | The fit.py model accepts up to two arguments. The first argument is the |
---|
| 89 | model type, which has been defined for cylinder, capped_cylinder, |
---|
| 90 | core_shell_cylinder, ellipsoid, triaxial_ellipsoid and lamellar. The |
---|
| 91 | second argument is view, which can be radial or tangential. To fit |
---|
| 92 | both radial and tangential simultaneously, use the word "both". |
---|
| 93 | |
---|
[c03e0cc] | 94 | See `bumps documentation <https://bumps.readthedocs.io/>`_ for detailed |
---|
[ade01a0] | 95 | instructions on running the fit. |
---|
[241b617] | 96 | |
---|
[84bc3c1] | 97 | |TravisStatus|_ |
---|
| 98 | |
---|
| 99 | .. |TravisStatus| image:: https://travis-ci.org/SasView/sasmodels.svg?branch=master |
---|
| 100 | .. _TravisStatus: https://travis-ci.org/SasView/sasmodels |
---|