Skip to content
Jack Sankey edited this page Jul 31, 2020 · 84 revisions

Welcome to the spinmob wiki!

Spinmob is designed as a high-level, easy-to-navigate library for acquiring, saving, loading, visualizing, and analyzing data. For example, the following nonlinear fit:

Example fit

is produced with the following commands:

f = spinmob.data.fitter()
f.set_functions('a*x*cos(b*x)+c', 'a=-0.2, b, c=3')
f.set_data([1, 2, 3, 4, 5], [1.7, 2, 3, 4, 3], 0.115)
f.fit()

Check out the "chapters" on the right-hand side of this page to get a feel for what it can do (and learn a bit about python itself if you're new). By far the most popular features for new users are the fitting object (Chapter 4), the databox object (Chapter 2), and the GUI builder (Chapter 6). There are also a bunch of plotting shortcuts (Chapter 3) and a mess of random / potentially useful functions in spinmob.fun. All the code's documentation is readily accessible inside Spyder or your favorite IDE.

Recommended method for installing everything

1. Install Anaconda Python or Miniconda

Anaconda Python comes with a lot of packages. Miniconda comes with the bare bones, allowing you select only those packages you want.

2. Install Spinmob

Spinmob is tested against Python 3, but will likely still work with Python 2 (depreciated as of 2020). It relies on the following packages:

  • Scipy & Numpy for numerical calculations.
  • Matplotlib for publication-quality figures.
  • PyQtGraph for easy graphical development and fast plotting.

Most of these are already installed with Anaconda, and everything can be installed / verified using the conda command. To do so, open the "Terminal" on Linux/OSX, and "Anaconda Prompt" on Windows, and run the following commands (note spyder can be removed, but is recommended):

conda install numpy scipy matplotlib pyqtgraph pyopengl spyder

Spinmob can then be installed with pip:

pip install spinmob lmfit

To upgrade Spinmob:

pip install spinmob --upgrade --no-cache-dir

or, if you're Thomas:

python -m pip install --upgrade --no-cache-dir

3. From the IPython console (or a script!), import spinmob and start playing:

In []: import spinmob as s

In general, the module is designed so that there are fewer, high-level functions organized in a hierarchy, and the library is meant to be learned by exploration on the command line and through the integrated help. After importing, type s. and press the tab key to see what options are available. To play with data-related functionality, type s.data. and see what options appear. For plotting, s.plot., and so on. There is additional functionality hidden in items starting with underscores, but I have not finished testing these functions and / or they are very low-level / weird.

Like all python, Spinmob's documentation is built in. Much of this is visible via code-completion or Spyder's Help window, which can be accessed by typing <ctrl>-i with your cursor positioned after the last character of an object. Or, you can use python's help() command, e.g. help(s.plot.xy.data).

When I have just finished a new install, my first test is always this command:

In []: s.plot.magphase.function()

This should pop up a magnitude and phase plot for the supplied (default) complex function 1/(1+1j*x). If it popped up, spinmob & all its dependencies are correctly installed.

Other installation techniques (pros only!)

Installing Spinmob into an existing python environment

If you have a working python installation and just want to install Spinmob (and its dependencies), you can do so with "pip" from your system's command line ("Terminal" in OSX/Linux, "cmd.exe" in Windows):

pip install numpy scipy matplotlib pyqtgraph spyder spinmob

I do not recommend this approach, as system python installs are finicky and often your system relies on them in weird ways.

Direct download or git clone

If pip doesn't work for some reason, this is a sure-fire method: Create a "spinmob" folder in python's site-packages directory and either clone the spinmob repository there or download / unzip. We highly recommend using a git client as described on the contributing page. Spinmob is designed to work when cloned directly into site-packages.

Clone this wiki locally