|
| 1 | +.. image:: https://travis-ci.com/stonerlab/Stoner-PythonCode.svg?branch=master |
| 2 | + :target: https://travis-ci.com/stonerlab/Stoner-PythonCode |
| 3 | + |
| 4 | +.. image:: https://coveralls.io/repos/github/stonerlab/Stoner-PythonCode/badge.svg?branch=master |
| 5 | + :target: https://coveralls.io/github/stonerlab/Stoner-PythonCode?branch=master |
| 6 | + |
| 7 | +.. image:: https://api.codacy.com/project/badge/Grade/372f2f9227134fab9c6c2f2ba83962ba |
| 8 | + :target: https://www.codacy.com/app/stonerlab/Stoner-PythonCode?utm_source=github.com&utm_medium=referral&utm_content=stonerlab/Stoner-PythonCode&utm_campaign=Badge_Grade |
| 9 | + |
| 10 | +.. image:: https://badge.fury.io/py/Stoner.svg |
| 11 | + :target: https://badge.fury.io/py/Stoner |
| 12 | + |
| 13 | +.. image:: https://anaconda.org/phygbu/stoner/badges/version.svg |
| 14 | + :target: https://anaconda.org/phygbu/stoner |
| 15 | + |
| 16 | +.. image:: https://readthedocs.org/projects/stoner-pythoncode/badge/?version=latest |
| 17 | + :target: http://stoner-pythoncode.readthedocs.io/en/latest/?badge=latest |
| 18 | + :alt: Documentation Status |
| 19 | + |
| 20 | +.. image:: https://zenodo.org/badge/10057055.svg |
| 21 | + :target: https://zenodo.org/badge/latestdoi/10057055 |
| 22 | + |
| 23 | + |
| 24 | +Introduction |
| 25 | +============ |
| 26 | + |
| 27 | + |
| 28 | +The *Stoner* Python package is a set of utility classes for writing data analysis code. It was written within |
| 29 | +the Condensed Matter Physics group at the University of Leeds as a shared resource for quickly writing simple |
| 30 | +programs to do things like fitting functions to data, extract curve parameters, churn through large numbers of |
| 31 | +small text data files and work with certain types of scientific image files. |
| 32 | + |
| 33 | +For a general introduction, users are referred to the Users Guide, which is part of the `online documentation`_ along with the |
| 34 | +API Reference guide. The `github repository`_ also contains some example scripts. |
| 35 | + |
| 36 | +Getting this Code |
| 37 | +================== |
| 38 | + |
| 39 | +.. image:: https://i.imgur.com/h4mWwM0.png |
| 40 | + :target: https://www.youtube.com/watch?v=uZ_yKs11W18 |
| 41 | + :alt: Introduction and Installation Guide to Stoner Pythin Package |
| 42 | + :width: 320 |
| 43 | + |
| 44 | +The *Stoner* package requires h5py>=2.7.0, lmfit>=0.9.7, matplotlib>=2.0,numpy>=1.13, Pillow>=4.0, |
| 45 | +scikit-image>=0.13.0 & scipy>=1.0.0 and also optional depends on filemagic, npTDMS, imreg_dft and numba. |
| 46 | + |
| 47 | +Ananconda Python (and probably other scientific Python distributions) include nearly all of the dependencies, and the remaining |
| 48 | +dependencies are collected together in the **phygbu** repositry on anaconda cloud. The easiest way to install the Stoner package is, |
| 49 | +therefore, to install the most recent Anaconda Python distribution. |
| 50 | + |
| 51 | +Compatibility |
| 52 | +-------------- |
| 53 | + |
| 54 | +Versions 0.9.x (stable branch) are compatible with Python 2.7, 3.5, 3.6 and 3.7. The latest 0.9.6 version is also compatible with Python 3.8 |
| 55 | +The development verstion (0.10, master branch) is compatible with Python 3.6, 3.7 and 3.8 but not 2.7. |
| 56 | + |
| 57 | +Conda packages are prepared for the stable branch and when the development branch enters beta testing. Pip wheels are prepared for selected stable releases only. |
| 58 | + |
| 59 | +Installation |
| 60 | +------------ |
| 61 | + |
| 62 | +After installing the current Anaconda version, open a terminal (Mac/Linux) or Anaconda Prompt (Windows) an do: |
| 63 | + |
| 64 | +.. code-block:: sh |
| 65 | +
|
| 66 | + conda install -c phygbu Stoner |
| 67 | +
|
| 68 | +If you are not using Anaconda python, then pip should also work: |
| 69 | + |
| 70 | +.. code-block:: sh |
| 71 | +
|
| 72 | + pip install Stoner |
| 73 | +
|
| 74 | +This will install the Stoner package and any missing dependencies into your current Python environment. Since the package is under fairly |
| 75 | +constant updates, you might want to follow the development with git. The source code, along with example scripts |
| 76 | +and some sample data files can be obtained from the github repository: https://github.com/stonerlab/Stoner-PythonCode |
| 77 | + |
| 78 | +Overview |
| 79 | +======== |
| 80 | + |
| 81 | +The main part of the **Stoner** package provides four basic top-level classes that describe: |
| 82 | + - an individual file of experimental data (**Stoner.Data**), |
| 83 | + - an individual experimental image (**Stoner.ImageFile**), |
| 84 | + - a list (such as a directory tree on disc) of many experimental files (**Stoner.DataFolder**) |
| 85 | + - a list (such as a directory tree on disc) of many image files (**Stoner.ImageFolder**). |
| 86 | + |
| 87 | +For our research, a typical single experimental data file is essentially a single 2D table of floating point |
| 88 | +numbers with associated metadata, usually saved in some ASCII text format. This seems to cover most experiments |
| 89 | +in the physical sciences, but it you need a more complex format with more dimensions of data, we suggest |
| 90 | +you look elsewhere. |
| 91 | + |
| 92 | +Increasingly we seem also to need process image files and so partnering the experimental measurement file classes, |
| 93 | +we have a parallel set of classes for interacting with image data. |
| 94 | + |
| 95 | +The general philosophy used in the package is to work with data by using methods that transform the data in place. |
| 96 | +Additionally, many of the analysis methods pass a copy of the data as their return value, allowing a sequence of |
| 97 | +operations to be chained together in one line. |
| 98 | + |
| 99 | +This is a *data-centric* approach - we have some data and we do various operations on it to get to our result. In |
| 100 | +contrasr, traditional functional programming thinks in terms of various functions into which you pass data. |
| 101 | + |
| 102 | + |
| 103 | +Data and Friends |
| 104 | +---------------- |
| 105 | + |
| 106 | +**Stoner.Data** is the core class for representing individual experimental data sets. |
| 107 | +It is actually composed of several mixin classes that provide different functionality, with methods |
| 108 | +to examine and manipulate data, manage metadata, load and save data files, plot results and carry out various analysis tasks. |
| 109 | +It has a large number of sub classes - most of these are in Stoner.formats and are used to handle the loading of specific |
| 110 | +file formats. |
| 111 | + |
| 112 | +ImageFile |
| 113 | +--------- |
| 114 | + |
| 115 | +**Stoner.ImageFile** is the top-level class for managing image data. It is the equivalent of **Stoner.Data** and maintains |
| 116 | +metadta and comes with a number of methods to manipulate image data. The image data is stored internally as a masked numpy |
| 117 | +array and where possible the masking is taken into account when carrying out image analysis tasks. Through some abuse of |
| 118 | +the Python class system, functions in the scpy.ndimage and scikit-image modules are mapped into methods of the ImageFile |
| 119 | +class allowing a very rich set of operations on the data sets. The default IO methods handle tiff and png images and can |
| 120 | +store the metadata of the ImageFile within those file formats. |
| 121 | + |
| 122 | +DataFolder |
| 123 | +---------- |
| 124 | + |
| 125 | +**Stoner.DataFolder** is a class for assisting with the work of processing lots of files in a common directory |
| 126 | +structure. It provides methods to list. filter and group data according to filename patterns or metadata and then to execute |
| 127 | +a function on each file or group of files and then collect metadata from each file in turn. A key feature of DataFolder is |
| 128 | +its ability to work with the collated metadata from the individual files that are held in the DataFolder. |
| 129 | +In combination with its ability to walk through a complete heirarchy of groups of |
| 130 | +**Data** objects, the handling of the common metadata provides powerful tools for quickly writing data reduction scripts. |
| 131 | + |
| 132 | +ImageFolder |
| 133 | +----------- |
| 134 | + |
| 135 | +**Stoner.ImageFolder** is the equivalent of DataFolder but for images (although technically a DataFolder can contain ImageFile |
| 136 | +objects, the ImageFolder class offers additional Image specific functionality). There is a subclass of ImageFolder, |
| 137 | +**Stoner.Image.ImageStack** that uses a 3D numpy array as it's primary image store which permits faster access |
| 138 | +(at the expense of a larger memory footprint) than the lazy loading ordered dictionary of **ImageFolder** |
| 139 | + |
| 140 | +Other Modules and Classes |
| 141 | +------------------------- |
| 142 | + |
| 143 | +The **Stoner.HDF5** module provides some additional classes to manipulate *Data* and *DataFolder* objects within HDF5 |
| 144 | +format files. HDF5 is a common chouse for storing data from large scale facilties, although providing a way to handle |
| 145 | +arbitary HDF5 files is beyond the scope of this package at this time - the format is much too complex and flexible to make that |
| 146 | +an easy task. Rather it provides a way to work with large numbers of experimental sets using just a single file which may be less |
| 147 | +brutal to your computer's OS than having directory trees with millions of individual files. |
| 148 | + |
| 149 | +The module also provides some classes to support loading some particular HDF5 flavoured files into **Data** and **ImageFile** |
| 150 | +objects. |
| 151 | + |
| 152 | +The **Stoner.Zip** module provides a similar set of classes to **Stoner.HDF5** but working with the ubiquitous zip compressed file format. |
| 153 | + |
| 154 | +Resources |
| 155 | +========== |
| 156 | + |
| 157 | +Included in the `github repository`_ are a (small) collection of sample scripts |
| 158 | +for carrying out various operations and some sample data files for testing the loading and processing of data. There is also a |
| 159 | +`User_Guide`_ as part of this documentation, along with a :doc:`complete API reference <Stoner>` |
| 160 | + |
| 161 | +Contact and Licensing |
| 162 | +===================== |
| 163 | + |
| 164 | +The lead developer for this code is ` Dr Gavin Burnell`_ < [email protected]>, but many current and former members of |
| 165 | +the CM Physics group have contributed code, ideas and bug testing. |
| 166 | + |
| 167 | +The User Guide gives the current list of other contributors to the project. |
| 168 | + |
| 169 | +This code and the sample data are all (C) The University of Leeds 2008-2021 unless otherwise indficated in the source |
| 170 | +file. The contents of this package are licensed under the terms of the GNU Public License v3 |
| 171 | + |
| 172 | +Recent Changes |
| 173 | +============== |
| 174 | + |
| 175 | +Current PyPi Version |
| 176 | +-------------------- |
| 177 | + |
| 178 | +The current version of the package on PyPi will be the stable branch until the development branch enters beta testing, when we start |
| 179 | +making beta packages available. |
| 180 | + |
| 181 | +Development Version |
| 182 | +------------------- |
| 183 | + |
| 184 | +The current development version is hosted in the master branch of the repository and will become version 0.10. |
| 185 | + |
| 186 | +New Features in 0.10-dev include: |
| 187 | + |
| 188 | + * Refactor Stoner.Core.DataFile to move functionality to mixin classes |
| 189 | + * Start implementing PEP484 Type hinting |
| 190 | + * Support pathlib for paths |
| 191 | + * Switch from Tk based dialogs to Qt5 ones |
| 192 | + * Refactoring the **baseFolder** class so that sub-groups are stored in an attribute that is an instance of a custom |
| 193 | + dictionary with methods to prune and filter in the virtual tree of sub-folders. |
| 194 | + * Refactoring of the **ImageArray** and **ImageFile** so that binding of external functions as methods is done at |
| 195 | + class definition time rather than at runtime with overly complex __getattr__ methods. The longer term goal is to |
| 196 | + depricate the use of ImageArray in favour of just using ImageFile. |
| 197 | + * Introduce interactive selection of boxes, lines and mask regions for interactive Matplotlib backends. |
| 198 | + |
| 199 | +Build Status |
| 200 | +~~~~~~~~~~~~ |
| 201 | + |
| 202 | +Version 0.7 onwards are tested using the Travis-CI services with unit test coverage assessed by Coveralls. |
| 203 | + |
| 204 | +Version 0.9 is tested with Python 2.7, 3.5, 3.6 using the standard unittest module. |
| 205 | + |
| 206 | +The development version - which will be 0.10 is tested using **pytest** with Python 3.6, Python 3.7 and Python 3.8. |
| 207 | + |
| 208 | + |
| 209 | +Citing the Stoner Package |
| 210 | +~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 211 | + |
| 212 | +We maintain a digital object identifier (doi) for this package (linked to on the status bar at the top of this readme) and |
| 213 | +encourage any users to cite this package via that doi. |
| 214 | + |
| 215 | +Stable Versions |
| 216 | +--------------- |
| 217 | + |
| 218 | +Online documentation for all versions can be found on the ReadTheDocs pages `online documentation`_ |
| 219 | + |
| 220 | +Version 0.9 is the current stable version. This is the last version to support Python 2 and 3<3.6. Features of this release are: |
| 221 | + |
| 222 | + * Refactoring of the package into a more granual core, plot, formats, folders packages with submodules |
| 223 | + * Overhaul of the documentation and user guide |
| 224 | + * Dropping support for the older Stoner.Image.stack.ImageStack class |
| 225 | + * Droppping support for matplotlib<2.0 |
| 226 | + * Support for Python 3.7 (and 3.8 from 0.9.6) |
| 227 | + * Unit tests now > 80% coverage across the package. |
| 228 | + |
| 229 | +Version 0.8 is the previous stable release. The main new features were: |
| 230 | + |
| 231 | + * Reworking of the ImageArray, ImageFile and ImageFolder with many updates and new features. |
| 232 | + * New mixin based ImageStack2 that can manipulate a large number of images in a 3D numpy array |
| 233 | + * Continued re-factoring of DataFolder using the mixin approach |
| 234 | + * Further increases to unit-test coverage, bug fixes and refactoring of some parts of the code. |
| 235 | + * _setas objects implement a more complete MutableMapping interface and also support +/- operators. |
| 236 | + * conda packages now being prepared as the preferred package format |
| 237 | + |
| 238 | +0.8.2 was the final release of the 0.8.0 branch |
| 239 | + |
| 240 | +The old stable version is 0.7.2. Features of 0.7.2 include |
| 241 | + |
| 242 | + * Replace older AnalyseFile and PlotFile with mixin based versions AnalysisMixin and PlotMixin |
| 243 | + * Addition of Stoner.Image package to handle image analysis |
| 244 | + * Refactor DataFolder to use Mixin classes |
| 245 | + * DataFolder now defaults to using :py:class:`Stoner.Core.Data` |
| 246 | + * DataFolder has an options to skip iterating over empty Data files |
| 247 | + * Further improvements to :py:attr:`Stoner.Core.DataFile.setas` handline. |
| 248 | + |
| 249 | +No further relases will be made to 0.7.x. |
| 250 | + |
| 251 | +0.6, 0.7 should work on Python 2.7 and 3.5 |
| 252 | +0.8 is also tested on Python 3.6 |
| 253 | + |
| 254 | +.. _online documentation: http://stoner-pythoncode.readthedocs.io/en/latest/ |
| 255 | +.. _github repository: http://www.github.com/stonerlab/Stoner-PythonCode/ |
| 256 | +.. _Dr Gavin Burnell: http://www.stoner.leeds.ac.uk/people/gb |
| 257 | +.. _User_Guide: http://stoner-pythoncode.readthedocs.io/en/latest/UserGuide/ugindex.html |
0 commit comments