Skip to content
Jack Sankey edited this page Nov 13, 2021 · 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:

# Import the library
import spinmob

# Create a fitter object
f = spinmob.data.fitter()

# Set the functions
f.set_functions('a*x*cos(b*x)+c', 'a=-0.2, b, c=3')

# Supply the data
f.set_data([1, 2, 3, 4, 5], [1.7, 2, 3, 4, 3], 0.115, xlabel='Time (s)', ylabel='Pants (mV)')

# Fit!
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 Miniconda or the full Anaconda Python.

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

The easiest way to install Spinmob is via pip, but we need to install pip first. From your console, run:

conda install pip

We then recommend simply installing Spinmob and Spyder (a great IDE) together

pip install spinmob spyder

You can leave spyder out, but if you do, you will then need to make sure you have some version of PyQt installed as well, e.g., by running pip install pyqt5.

3. From the IPython console, python console, or a script, import Spinmob and start playing:

import spinmob as s

In general, the module is designed so that there are fewer high-level objects organized in a hierarchy, to facilitate learning by exploration on the command line and integrated help functionality. 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.

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.

Upgrading Spinmob

To upgrade Spinmob:

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

or, if you're Thomas:

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

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 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