Stoner Package

Primary Classes

Stoner.Data(*args)

The principal class for representing a data file.

Stoner.DataFolder(*args, **kargs)

Provide an interface to manipulating lots of data files stored within a directory structure on disc.

Stoner.Image.ImageFile(*args)

An Image file type that is analogous to Stoner.Data.

Stoner.Image.ImageFolder(*args, **kargs)

Folder object for images.

Inheritance Diagrams

Inheritance diagram of Stoner.Data
Inheritance diagram of Stoner.DataFolder
Inheritance diagram of Stoner.ImageFile
Inheritance diagram of Stoner.ImageFolder

Numerical Data Objects

Core Package and Modules

Stoner.core.base Module

Base classes for the Stoner package.

Functions

string_to_type(value)

Given a string value try to work out if there is a better python type dor the value.

Classes

_evaluatable()

Placeholder to indicate that special action needed to convert a string representation to valid Python type.

regexpDict

An ordered dictionary that permits looks up by regular expression.

typeHintedDict(*args, **kargs)

Extends a regedpDict to include type hints of what each key contains.

metadataObject(*args)

Represent some sort of object that has metadata stored in a Stoner.Core.typeHintedDict object.

Stoner.core.array Module

Provides the DataArray class.

A subclass of numpy.ma.MaskedArray that knows that columns have names.

Classes

DataArray(input_array, *args, **kargs)

A sub class of numpy.ma.MaskedArray with a copy of the setas attribute to allow indexing by name.

Stoner.core.setas Module

setas module provides the setas class for DataFile and friends.

Classes

setas([row, bless])

A Class that provides a mechanism for managing the column assignments in a DataFile like object.

Stoner.core.exceptions Module

Stoner Package specific exceptions.

Functions

assertion(condition[, message])

Raise an error when condition is false.

Classes

StonerAssertionError

An exception raised when the library thinks an assertion has failed.

StonerLoadError

An exception thrown by the file loading routines in the Stoner Package.

StonerSetasError

An exception tjrown when we try to access a column in data without setas being set.

StonerUnrecognisedFormat

An exception thrown by the file loading routines in the Stoner Package.

Stoner.core.utils Module

Functions

add_core(other, newdata)

Implement the core work of adding other to self and modifying newdata.

and_core(other, newdata)

Implement the core of the & operator, returning data in newdata.

sub_core(other, newdata)

Worker for the subtraction.

mod_core(other, newdata)

Implement the column deletion method.

copy_into(source, dest)

Copy the data associated with source to dest.

decode_string(value)

Expand a string of column assignments, replacing numbers with repeated characters.

Classes

tab_delimited()

A customised csv dialect class for reading tab delimited text files.

Stoner.Core Classes

Stoner.Core.DataFile(*args)

Base class object that represents a matrix of data, associated metadata and column headers.

Analysis Package

Stoner.Analysis Module

Stoner .Analysis provides a subclass of Data that has extra analysis routines builtin.

Classes

AnalysisMixin()

A mixin calss designed to work with Stoner.Core.DataFile to provide additional analysis methods.

Stoner.analysis.fitting Package

Provides additional functionality for doing curve fitting to data.

Classes

odr_Model(*args, **kargs)

A wrapper for converting lmfit models to odr models.

FittingMixin()

A mixin calss for Stoner.Core.DataFile to provide additional curve_fiotting methods.

Fitting Models

Plot Package and Modules

Stoner.plot Package

Stoner.plot sub-package - contains classes and functions for visuallising data.

Most of the plotting functionality is provided by the PlotMixin mixin class which is available through the Stoner.Data class.

The formats module provides a set of template classes for producing different plot styles and formats. The Stoner.plot.util module provides some handy utility functions.

Classes

PlotMixin(*args, **kargs)

A mixin class that works with Stoner.Core.DataFile to add additional plotting functionality.

Stoner.plot.formats Module

Plot Templates module - contains classes that style plots produced by Data.

Classes

TexFormatter()

An axis tick label formatter that emits Tex formula mode code.

TexEngFormatter([unit, places, sep, usetex, ...])

An axis tick label formatter that emits Tex formula mode code.

DefaultPlotStyle(*args, **kargs)

Produces a default plot style.

GBPlotStyle(*args, **kargs)

Template developed for Gavin's plotting.

JTBPlotStyle(*args, **kargs)

Template class for Joe's Plot settings.

JTBinsetStyle(*args, **kargs)

Template class for Joe's Plot settings.

PRBPlotStyle(*args, **kargs)

A figure Style for making figures for Phys Rev * Jounrals.

SketchPlot(*args, **kargs)

Turn on xkcd plot style.

SeabornPlotStyle

alias of DefaultPlotStyle

Class Inheritance Diagram
Inheritance diagram of Stoner.plot.formats.TexFormatter, Stoner.plot.formats.TexEngFormatter, Stoner.plot.formats.DefaultPlotStyle, Stoner.plot.formats.GBPlotStyle, Stoner.plot.formats.JTBPlotStyle, Stoner.plot.formats.JTBinsetStyle, Stoner.plot.formats.PRBPlotStyle, Stoner.plot.formats.SketchPlot, Stoner.plot.formats.DefaultPlotStyle

Stoner.plot.utils Module

Functions

errorfill(x, y[, yerr, xerr, color, ls, lw, ...])

Plot data with errors marked by a filled region.

File Formats Package Module

Generic Fomats

Instrument Formats

Facility Outputs

Measurement Rig Files

Simulation Package Files

Stoner.analysis.fitting Package

Provides additional functionality for doing curve fitting to data.

Classes

odr_Model(*args, **kargs)

A wrapper for converting lmfit models to odr models.

FittingMixin()

A mixin calss for Stoner.Core.DataFile to provide additional curve_fiotting methods.

The following modules offer specialised file and foler formats.

HDF Support

Stoner.HDF5 Module

Classes

HDF5File(*args)

A sub class of DataFile that sores itself in a HDF5File or group.

HDF5Folder(*args, **kargs)

Just enforces the loader attriobute to be an HDF5File.

HGXFile(*args)

A subclass of DataFile for reading GenX HDF Files.

SLS_STXMFile(*args)

Load images from the Swiss Light Source Pollux beamline.

STXMImage(*args)

An instance of KerrArray that will load itself from a Swiss Light Source STXM image.

HDFFileManager(filename[, mode])

Context manager for HDF5 files.

Zip File Support

Stoner.Zip Module

Functions

test_is_zip(filename[, member])

Recursively searches for a zipfile in the tree.

Classes

ZippedFile(*args)

A sub class of DataFile that sores itself in a zip file.

ZipFolderMixin(*args, **kargs)

Provides methods to load and save data from a single Zip file.

ZipFolder(*args, **kargs)

A sub class of DataFile that sores itself in a zip file.

Utility Functions

Stoner.Util Module

Functions

split_up_down(data[, col, folder])

Split the DataFile data into several files where the column col is either rising or falling.

ordinal(value)

Format an integer into an ordinal string.

hysteresis_correct(data, **kargs)

Perform corrections to a hysteresis loop.

Stoner.tools Package

Support functions for Stoner package.

These functions depend only on Stoner.compat which is used to ensure a consistent namespace between python 2.7 and 3.x.

Functions

all_size(iterator[, size])

Check whether each element of iterator is the same length/shape.

all_type(iterator, typ)

Determine if an interable omnly contains a common type.

fix_signature(proxy_func, wrapped_func)

Update proxy_func to have a signature that matches the wrapped func.

format_error(value[, error])

Format answer with the uncertaintly to 1sf and the value to no more sf's than the uncertainty.

format_val(value, **kargs)

Format a number as an SI quantity.

html_escape(s[, quote])

Replace special characters "&", "<" and ">" to HTML-safe sequences.

isanynone(*args)

Intelligently check whether any of the inputs are None.

isComparable(v1, v2)

Return true if v1 and v2 can be compared sensibly.

isnone(iterator)

Return True if input is None or an empty iterator, or an iterator of None.

isiterable(value)

Chack to see if a value is iterable.

isLikeList(value)

Return True if value is an iterable but not a string.

isproperty(obj, name)

Check whether an attribute of an object or class is a property.

isTuple(obj, *args[, strict])

Determine if obj is a tuple of a certain signature.

isclass(obj, cls)

Check whether obj is a class and if so whether it is a subclass of cls.

copy_into(source, dest)

Copy the data associated with source to dest.

make_Data(*args, **kargs)

Return an instance of Stoner.Data or Stoner.ImageFile passig through constructor arguments.

quantize(number, quantum)

Round a number to the nearest multiple of a quantum.

tex_escape(text)

Escapes spacecial text characters in a string.

get_option(name)

Return the option value.

set_option(name, value)

Set a global package option.

ordinal(value)

Format an integer into an ordinal string.

Classes

AttributeStore

alias of attributeStore

typedList(*args, **kargs)

Subclass list to make setitem enforce strict typing of members of the list.

Options()

Dead simple class to allow access to package options.

Folders pacakge - Collections Classes

Main Classes

Stoner.Folders Module

Stoner.Folders : Classes for working collections of Data files.

The core classes provides a means to access them as an ordered collection or as a mapping.

Classes

DataFolder(*args, **kargs)

Provide an interface to manipulating lots of data files stored within a directory structure on disc.

PlotFolder(*args, **kargs)

A Stoner.folders.baseFolder that knows how to ploth its underlying data files.

Class Inheritance Diagram
Inheritance diagram of Stoner.Folders.DataFolder, Stoner.Folders.PlotFolder

Folders Package and Submodules

Stoner.folders Package

Core support for working with collections of files in the Stoner.DataFolder.

Classes

DataFolder(*args, **kargs)

Provide an interface to manipulating lots of data files stored within a directory structure on disc.

PlotFolder(*args, **kargs)

A Stoner.folders.baseFolder that knows how to ploth its underlying data files.

Stoner.folders.core Module

Provide the base classes and functions for the Stoner.DataFolder class.

Classes

baseFolder(*args, **kargs)

A base class for objectFolders that supports both a sequence of objects and a mapping of instances of itself.

Stoner.folders.mixins Module

mixin classes for Stoner.folders.core.baseFoler.

Classes

DiskBasedFolderMixin(*args, **kargs)

A Mixin class that implements reading metadataObjects from disc.

DataMethodsMixin()

Methods for working with Stner.Data in py:class:`Stoner.DataFolder`s.

PlotMethodsMixin()

A Mixin for Stoner.folders.core.baseFolder with extra methods for plotting lots of files.

Stoner.folders.each Module

Classes and support functions for the Stoner.DataFolder.each.magic attribute.

Classes

Item(folder)

Provides a proxy object for accessing methods on the inividual members of a Folder.

Class Inheritance Diagram
Inheritance diagram of Stoner.folders.each.Item

Stoner.folders.metadata Module

Provides classes and functions to support the Stoner.DataFolder.metadata magic attribute.

Classes

MetadataProxy(folder)

Provide methods to interact with a whole collection of metadataObjects' metadata.

Class Inheritance Diagram
Inheritance diagram of Stoner.folders.metadata.MetadataProxy

Image Subpackage

Main Image Classes

Stoner.Image Package

The Stoner.Image package provides a means to carry out image processing functions in a smilar way that Stoner.Core and Stoner.Data and Stoner.DataFolder do. The Stomner.Image.core module contains the key classes for achieving this.

Classes

ImageArray(*args)

A numpy array like class with a metadata parameter and pass through to skimage methods.

ImageFile(*args)

An Image file type that is analogous to Stoner.Data.

ImageFolder(*args, **kargs)

Folder object for images.

ImageStack(*args, **kargs)

An alternative implementation of an image stack based on baseFolder.

KerrArray(*args)

A subclass for Kerr microscopy specific image functions.

KerrStack(*args, **kargs)

Represent a stack of Kerr images.

MaskStack(*args, **kargs)

Represent a set of masks for Kerr images.

Class Inheritance Diagram
Inheritance diagram of Stoner.Image.core.ImageArray, Stoner.Image.core.ImageFile, Stoner.Image.folders.ImageFolder, Stoner.Image.stack.ImageStack, Stoner.Image.kerr.KerrArray, Stoner.Image.kerr.KerrStack, Stoner.Image.kerr.MaskStack

Stoner.Image.folders Module

Classes

ImageFolderMixin()

Mixin to provide a folder object for images.

ImageFolder(*args, **kargs)

Folder object for images.

Class Inheritance Diagram
Inheritance diagram of Stoner.Image.folders.ImageFolderMixin, Stoner.Image.folders.ImageFolder

Stoner.Image.stack Module

Classes

ImageStackMixin(*args, **kargs)

Implement an interface for a baseFolder to store images in a 3D numpy array for faster access.

ImageStack(*args, **kargs)

An alternative implementation of an image stack based on baseFolder.

ImageStack(*args, **kargs)

An alternative implementation of an image stack based on baseFolder.

Class Inheritance Diagram
Inheritance diagram of Stoner.Image.stack.ImageStackMixin, Stoner.Image.stack.ImageStack, Stoner.Image.stack.ImageStack

Stoner.Image.attrs Module

Classes

DrawProxy(*args, **kargs)

Provides a wrapper around skimage.draw to allow easy drawing of objects onto images.

MaskProxy(*args)

Provides a wrapper to support manipulating the image mask easily.

Class Inheritance Diagram
Inheritance diagram of Stoner.Image.attrs.DrawProxy, Stoner.Image.attrs.MaskProxy

Generic Fomats

Attocube SPM Scans

Stoner.formats.attocube.AttocubeScan(*args, ...)

An ImageStack subclass that can load scans from the AttocubeScan SPM System.

Additional Image Functions

Stoner.Image.imagefuncs Module

Functions

adjust_contrast(im[, lims, percent])

Rescale the intensity of the image.

align(im, ref[, method])

Use one of a variety of algroithms to align two images.

convert(image, dtype[, force_copy, uniform, ...])

Convert an image to the requested data-type.

correct_drift(im, ref, **kargs)

Align images to correct for image drift.

subtract_image(im, background[, contrast, ...])

Subtract a background image from the ImageArray.

fft(im[, shift, phase, remove_dc, gaussian, ...])

Perform a 2d fft of the image and shift the result to get zero frequency in the centre.

filter_image(im[, sigma])

Alias for skimage.filters.gaussian.

gridimage(im[, points, xi, method, ...])

Use scipy.interpolate.griddata() to shift the image to a regular grid of coordinates.

hist(im, *args, **kargs)

Pass through to matplotlib.pyplot.hist() function.

imshow(im, **kwargs)

Quickly plot of image.

level_image(im[, poly_vert, poly_horiz, ...])

Subtract a polynomial background from image.

normalise(im[, scale, sample, limits, ...])

Norm alise the data to a fixed scale.

profile_line(img[, src, dst, linewidth, ...])

Wrap sckit-image method of the same name to get a line_profile.

quantize(im, output[, levels])

Quantise the image data into fixed levels given by a mapping.

radial_coordinates(im[, centre, pixel_size, ...])

Rerurn a map of the radial coordinates of an image from a given centre, with adjustments for pixel size.

radial_profile(im[, angle, r, centre, ...])

Extract a radial profile line from an image.

remove_outliers(im[, percentiles, replace])

Find values of the data that are beyond a percentile of the overall distribution and replace them.

rotate(im, angle[, resize, center, order, ...])

Rotate image by a certain angle around its center.

translate(im, translation[, add_metadata, ...])

Translate the image.

translate_limits(im, translation[, reverse])

Find the limits of an image after a translation.

plot_histogram(im[, bins])

Plot the histogram and cumulative distribution for the image.

threshold_minmax(im[, threshmin, threshmax])

Return a boolean array which is thresholded between threshmin and threshmax.

do_nothing(self)

Nulop function for testing the integration into ImageArray.

denoise(im[, weight])

Rename the skimage restore function.

Stoner.Image.util Module

Code adapted from skimage module.

Functions

sign_loss(dtypeobj_in, dtypeobj)

Warn over loss of sign information when converting image.

prec_loss(dtypeobj_in, dtypeobj)

Warn over precision loss when converting image.

_dtype(itemsize, *dtypes)

Return first of dtypes with itemsize greater than `itemsize.

_dtype2(kind, bits[, itemsize])

Return dtype of kind that can store a bits wide unsigned int.

Kerr Image Handling

Stoner.Image.kerr Module

Classes

KerrArray(*args)

A subclass for Kerr microscopy specific image functions.

KerrStack(*args, **kargs)

Represent a stack of Kerr images.

MaskStack(*args, **kargs)

Represent a set of masks for Kerr images.