Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
321 changes: 162 additions & 159 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,159 +1,162 @@
Introduction
============

The *Stoner* Python package is a set of utility classes for writing data
analysis code. It was written within the Condensed Matter Physics group
at the University of Leeds as a shared resource for quickly writing
simple programs to do things like fitting functions to data, extract
curve parameters and churn through large numbers of small text data
files.

For a general introduction, users are referred to the Users Guide, which
is part of the [online documentation](http://pythonhosted.org/Stoner/)
along with the API Reference guide. The [github
repository](http://www.github.com/gb119/Stoner-PythonCode/) also
contains some example scripts.

Getting this Code
=================

The *Stoner* package requires numpy \>=1.8, scipy \>=0.14, matplotlib
\>=1.4, h5py, numba lmfit, filemagic, and blist. Experimental code also
makes use of the Enthought Tools Suite packages.

Ananconda Python (and probably other scientific Python distributions)
include nearly all of the dependencies, aprt from lmfit. However, this
can by installed with the usual tools such as *easy\_install* or *pip*.

``` {.sourceCode .sh}
easy_install lmfit
```

The easiest way to install the Stoner package is via seuptools'
easy\_install

``` {.sourceCode .sh}
easy_install Stoner
```

This will install the Stoner package and any missing dependencies into
your current Python environment. Since the package is under fairly
constant updates, you might want to follow the development with git. The
source code, along with example scripts and some sample data files can
be obtained from the github repository:
<https://github.com/gb119/Stoner-PythonCode>

The codebase is largely compatible with Python 3.4, with the expception
of the 3D vector map plots which make use of Enthought's *mayavi*
package which is still only Python 2 compatible due to the underlying
Vtk toolkit. Other issues of broken 3.4 code are bugs to be squashed.

Overview
========

The **Stoner** package provides two basic top-level classes that
describe an individual file of experimental data and a list (such as a
directory tree on disc) of many experimental files. For our research, a
typical single experimental data file is essentially a single 2D table
of floating point numbers with associated metadata, usually saved in
some ASCII text format. This seems to cover most experiments in the
physical sciences, but it you need a more complex format with more
dimensions of data, we suggest you look elsewhere.

DataFile and Friends
--------------------

**Stoner.Core.DataFile** is the base class for representing individual
experimental data sets. It provides basic methods to examine and
manipulate data, manage metadata and load and save data files. It has a
large number of sub classes - most of these are in Stoner.FileFormats
and are used to handle the loading of specific file formats. Two,
however, contain additional functionality for writing analysis programs.

- **Stoner.Analysis.AnalyseFile** provides additional methods for curve-fitting, differentiating, smoothing and carrying out
: basic calculations on data.

- **Stoner.Plot.PlotFile** provides additional routines for plotting
data on 2D or 3D plots.

As mentioned above, there are subclasses of **DataFile** in the
**Stoner.FileFormats** module that support loading many of the common
file formats used in our research.

For rapid development of small scripts, we would recommend the
**Stoner.Data** class which is a superclass of the above, and provides a
'kitchen-sink' one stop shop for most of the package's functionality.

DataFolder
----------

**Stoner.Folders.DataFolder** is a class for assisting with the work of
processing lots of files in a common directory structure. It provides
methods to list. filter and group data according to filename patterns or
metadata and then to execute a function on each file or group of files.

The **Stoner.HDF5** module provides some experimental classes to
manipulate *DataFile* and *DataFolder* objects within HDF5 format files.
These are not a way to handle arbitary HDF5 files - the format is much
to complex and flexible to make that an easy task, rather it is a way to
work with large numbers of experimental sets using just a single file
which may be less brutal to your computer's OS than having directory
trees with millions of individual files.

Resources
=========

Included in the [github
repository](http://www.github.com/gb119/Stoner-PythonCode/) are a
(small) collection of sample scripts for carrying out various operations
and some sample data files for testing the loading and processing of
data. There is also a User\_Guide as part of this documentation, along
with a complete API reference \<Stoner\>

Contact and Licensing
=====================

The lead developer for this code is [Dr Gavin
Burnell](http://www.stoner.leeds.ac.uk/people/gb)
\<<g.burnell@leeds.ac.uk>\> . The User Guide gives the current list of
other contributors to the project.

This code and the sample data are all (C) The University of Leeds
2008-2015 unless otherwise indficated in the source file. The contents
of this package are licensed under the terms of the GNU Public License
v3

Recent Changes
==============

Development Version
-------------------

Teh current development version is 0.7. Features of 0.7 include

> - DataFolder now defaults to using :pyStoner.Util.Data
> - DataFolder has an options to skip iterating over empty Data files
> - Further improvements to :pyStoner.Core.DataFile.setas handline.

Online documentation for the development version can be found on the
[githib repository pages](http://gb119.github.io/Stoner-PythonCode)

[![image](https://zenodo.org/badge/17265/gb119/Stoner-PythonCode.svg)](https://zenodo.org/badge/latestdoi/17265/gb119/Stoner-PythonCode)

Stable Version
--------------

The current stable version is 0.6. This features some major changes in
the architecture, switching from a numpy MaskedArray as the main data
store to a custom sub-class that contains most of the logic for indexing
data by column name and designation. The metadata storage has also been
switched to using blist.sortteddict for a fast, alphabetically ordered
dictionary storage. Other underlying changes are a switch to using
properties rather than straight attribute access.

0.6 now also makes use of filemagic to work out the mime type of files
to be loaded to try and improve the resilience of the automatic file
format detection on platforms where this is supported and adds some
extra methods to AnalyseFile for extrapolation.

0.6 should work on Python 2.7 and 3.5
Introduction
============

The *Stoner* Python package is a set of utility classes for writing data
analysis code. It was written within the Condensed Matter Physics group
at the University of Leeds as a shared resource for quickly writing
simple programs to do things like fitting functions to data, extract
curve parameters and churn through large numbers of small text data
files.

For a general introduction, users are referred to the Users Guide, which
is part of the [online documentation](http://pythonhosted.org/Stoner/)
along with the API Reference guide. The [github
repository](http://www.github.com/gb119/Stoner-PythonCode/) also
contains some example scripts.

Getting this Code
=================

The *Stoner* package requires numpy &gt;=1.8, scipy &gt;=0.14,
matplotlib &gt;=1.5, h5py, numba lmfit, filemagic, and blist.
Experimental code also makes use of the Enthought Tools Suite packages.

Ananconda Python (and probably other scientific Python distributions)
include nearly all of the dependencies, aprt from lmfit. However, this
can by installed with the usual tools such as *easy\_install* or *pip*.

``` {.sourceCode .sh}
easy_install lmfit
```

The easiest way to install the Stoner package is via seuptools'
easy\_install

``` {.sourceCode .sh}
easy_install Stoner
```

This will install the Stoner package and any missing dependencies into
your current Python environment. Since the package is under fairly
constant updates, you might want to follow the development with git. The
source code, along with example scripts and some sample data files can
be obtained from the github repository:
<https://github.com/gb119/Stoner-PythonCode>

The codebase is largely compatible with Python 3.4, with the expception
of the 3D vector map plots which make use of Enthought's *mayavi*
package which is still only Python 2 compatible due to the underlying
Vtk toolkit. Other issues of broken 3.4 code are bugs to be squashed.

Overview
========

The **Stoner** package provides two basic top-level classes that
describe an individual file of experimental data and a list (such as a
directory tree on disc) of many experimental files. For our research, a
typical single experimental data file is essentially a single 2D table
of floating point numbers with associated metadata, usually saved in
some ASCII text format. This seems to cover most experiments in the
physical sciences, but it you need a more complex format with more
dimensions of data, we suggest you look elsewhere.

DataFile and Friends
--------------------

**Stoner.Core.DataFile** is the base class for representing individual
experimental data sets. It provides basic methods to examine and
manipulate data, manage metadata and load and save data files. It has a
large number of sub classes - most of these are in Stoner.FileFormats
and are used to handle the loading of specific file formats. Two,
however, contain additional functionality for writing analysis programs.

-

**Stoner.Analysis.AnalyseFile** provides additional methods for curve-fitting, differentiating, smoothing and carrying out

: basic calculations on data.

- **Stoner.Plot.PlotFile** provides additional routines for plotting
data on 2D or 3D plots.

As mentioned above, there are subclasses of **DataFile** in the
**Stoner.FileFormats** module that support loading many of the common
file formats used in our research.

For rapid development of small scripts, we would recommend the
**Stoner.Data** class which is a superclass of the above, and provides a
'kitchen-sink' one stop shop for most of the package's functionality.

DataFolder
----------

**Stoner.Folders.DataFolder** is a class for assisting with the work of
processing lots of files in a common directory structure. It provides
methods to list. filter and group data according to filename patterns or
metadata and then to execute a function on each file or group of files.

The **Stoner.HDF5** module provides some experimental classes to
manipulate *DataFile* and *DataFolder* objects within HDF5 format files.
These are not a way to handle arbitary HDF5 files - the format is much
to complex and flexible to make that an easy task, rather it is a way to
work with large numbers of experimental sets using just a single file
which may be less brutal to your computer's OS than having directory
trees with millions of individual files.

Resources
=========

Included in the [github
repository](http://www.github.com/gb119/Stoner-PythonCode/) are a
(small) collection of sample scripts for carrying out various operations
and some sample data files for testing the loading and processing of
data. There is also a User\_Guide as part of this documentation, along
with a complete API reference &lt;Stoner&gt;

Contact and Licensing
=====================

The lead developer for this code is [Dr Gavin
Burnell](http://www.stoner.leeds.ac.uk/people/gb)
&lt;<g.burnell@leeds.ac.uk>&gt; . The User Guide gives the current list
of other contributors to the project.

This code and the sample data are all (C) The University of Leeds
2008-2015 unless otherwise indficated in the source file. The contents
of this package are licensed under the terms of the GNU Public License
v3

Recent Changes
==============

Development Version
-------------------

Teh current development version is 0.7. Features of 0.7 include

> - DataFolder now defaults to using :pyStoner.Util.Data
> - DataFolder has an options to skip iterating over empty Data files
> - Further improvements to :pyStoner.Core.DataFile.setas handline.

Online documentation for the development version can be found on the
[githib repository pages](http://gb119.github.io/Stoner-PythonCode)

[![image](https://zenodo.org/badge/17265/gb119/Stoner-PythonCode.svg)](https://zenodo.org/badge/latestdoi/17265/gb119/Stoner-PythonCode)

Stable Version
--------------

The current stable version is 0.6. This features some major changes in
the architecture, switching from a numpy MaskedArray as the main data
store to a custom sub-class that contains most of the logic for indexing
data by column name and designation. The metadata storage has also been
switched to using blist.sortteddict for a fast, alphabetically ordered
dictionary storage. Other underlying changes are a switch to using
properties rather than straight attribute access.

0.6 now also makes use of filemagic to work out the mime type of files
to be loaded to try and improve the resilience of the automatic file
format detection on platforms where this is supported and adds some
extra methods to AnalyseFile for extrapolation.

0.6 should work on Python 2.7 and 3.5
10 changes: 7 additions & 3 deletions Stoner/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
from inspect import getargspec,isclass
from collections import Iterable
try: #Allow lmfit to be optional
from lmfit.model import Model, ModelFit
import lmfit
if LooseVersion(lmfit.__version__)<LooseVersion("0.9.0"):
from lmfit.model import Model, ModelFit
else:
from lmfit.model import Model
from lmfit.model import ModelResult as ModelFit
from lmfit import Parameters
_lmfit=True
except ImportError:
Expand Down Expand Up @@ -709,8 +714,7 @@ def curve_fit(self, func, xcol=None, ycol=None, p0=None, sigma=None, **kargs):
if output == "full":
kargs["full_output"] = True

_=self._col_args(xcol=xcol,ycol=ycol,yerr=sigma,scalar=False)

_=self._col_args(scalar=False,xcol=xcol,ycol=ycol,yerr=sigma)
xcol,ycol,sigma=_.xcol,_.ycol,_.yerr

working = self.search(xcol, bounds)
Expand Down
1 change: 1 addition & 0 deletions Stoner/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ def get_filedialog(what="file", **opts):
return funcs[what](**opts)

index_types = string_types + (int, _pattern_type)
from distutils.version import LooseVersion
2 changes: 1 addition & 1 deletion Stoner/stylelib/JTB.mplstyle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
axes.color_cycle:k,r,b,g,c,m,y
axes.prop_cycle:cycler("color","krbgcmy")
axes.formatter.limits:-3, 3
axes.grid:False
axes.labelsize:18
Expand Down
2 changes: 1 addition & 1 deletion Stoner/stylelib/JTBinset.mplstyle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
axes.color_cycle:k,r,b,g,c,m,y
axes.prop_cycle:cycler("color":"krbgcmy")
axes.formatter.limits:-4, 4
axes.grid:False
axes.labelsize:16
Expand Down
2 changes: 1 addition & 1 deletion Stoner/stylelib/default.mplstyle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
axes.color_cycle:K, r, g, b, c, m, y
axes.prop_cycle:cycler('color',"Krgbcmy")
axes.formatter.limits:-1, 1
axes.grid:False
axes.labelsize:12
Expand Down
2 changes: 1 addition & 1 deletion Stoner/stylelib/sketch.mplstyle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
axes.color_cycle:b, r, g, c, m, y
axes.prop_cycle:cycler("color":"brgcmy")
font.family: Comic Sans MS
xtick.direction:inout
ytick.direction:inout
Expand Down
6 changes: 3 additions & 3 deletions doc/UserGuide/credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ A number of current and former members of the Condensed Matter Physics Group
at the University of Leeds have contributed to this code in various forms.

The original versions were developped by Dr Matthew Newman and Dr Chris Allen.
Rowan Temple, Sophie Morely and Joe Batley have all contributed file formats,
plot styles. They, and Dr May Wheeler, Philippa Shepley and Nathan Satchell have
Dr Rowan Temple, Dr Sophie Morely and Dr Joe Batley have all contributed file formats,
plot styles. They, and Dr May Wheeler, Dr Philippa Shepley and Nathan Satchell have
found bugs and made helpful suggestions.

The lead developer is Dr Gavin Burnell <g.burnell@leeds.ac.uk>. Most of the
development of this code has been indirectly supported by the UK Engineering
and Physical Sciences Research Council.

The code, except where otherwise noted, is Copyrigt The University of Leeds
2008-2015 and is released under the GNU Public License v3.
2008-2016 and is released under the GNU Public License v3.
Loading