Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Aug 16, 2019
1 parent cd1f32d commit 1b2cb29
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 33 deletions.
21 changes: 7 additions & 14 deletions README.rst
Expand Up @@ -76,27 +76,20 @@ format with more dimensions of data, we suggest you look elsewhere.
Data 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
**Stoner.Data** is the core class for representing individual experimental data sets.
It is actually composed of several mixin classes that provide different functionality, with methods
to examine and manipulate data, manage metadata, load and save data files, plot results and carry out various analysis tasks.
It has a large number of sub classes - most of these are in Stoner.formats and are used to handle the loading of specific
file formats.

There are also two mxin classes designed to work with DataFile to enable additional functionality for writing analysis programs.

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

* **Stoner.plot.PlotMixin** provides additional routines for plotting data on 2D or 3D plots.

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.
a function on each file or group of files. A key feature of DataFolder is its ability to work with the collated metadata from
the individual files that are held in the DataFolder. In combination with its ability to walk through a complete heirarchy of groups of
**Data** objects, the handling of the common metadata provides powerful tools for quickly writing data reduction scripts.

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
Expand Down
2 changes: 1 addition & 1 deletion Stoner/core/utils.py
Expand Up @@ -6,7 +6,7 @@
"add_core",
"and_core",
"sub_core",
"mod_cpore",
"mod_core",
"copy_into",
"itersubclasses",
"tab_delimited",
Expand Down
25 changes: 21 additions & 4 deletions doc/UserGuide/datafile.rst
Expand Up @@ -157,11 +157,13 @@ Single Argument Constructor
A single argument passed to :py:meth:`DataFile.__init__` is interpreted as follows:

- A string is assumed to be a filename, and therefore a DataFile is created by loading a file.
- A 2 numpy array is taken as the numeric data for the new DataFile
- A 2D numpy array is taken as the numeric data for the new DataFile
- A list or other iterable of strings is assumed to represent the column headers
- A list or other iterable of numpy arrays is assumed to represent a sequence of columns
- A dictionary with string keys and numpy array values of equal length is taken as a set of columns whose
header labels are the keys of the dictionaries.
- A *pandas.DataFrame* is used to provide data, column headers and if it has a suitable multi-level column index,
the :py:attr:`Stoner.Data.setas` attribute.
- Otherwise a dictionary is treated as the metadata for the new DataFile instance.

Two Argument Constructor
Expand All @@ -188,11 +190,14 @@ Examples
.. code::
# Load a file from disc, set the setas attribute and column headers
d=DataFile("filename.txt",setas="xy", column_headers=["X-Data","Y-Data"])
d=Data("filename.txt",setas="xy", column_headers=["X-Data","Y-Data"])
# Create a DataFile from a dictionary:
d=DataFile({"Temperature":temp_array,"Resistance":res_data})
d=Data({"Temperature":temp_array,"Resistance":res_data})
# The same, but set metadata too
d=DataFile({"Temperature":temp_array,"Resistance":res_data},{"User":"Fred","Sample":"X234_a","Field":2.4})
d=Data({"Temperature":temp_array,"Resistance":res_data},{"User":"Fred","Sample":"X234_a","Field":2.4})
# From a pandas DataFrame
df=pd.DataFrame(...)
d=Data(df)
Examining and Basic Manipulations of Data
Expand Down Expand Up @@ -1049,3 +1054,15 @@ filename used for a load or save operation.

The third is similar but convert the file to ``cvs`` format while the fourth also
specifies that the eliminator is a tab character.

Exporting Data to pandas
------------------------

The :py:meth:`Stoner.Data.to_pandas` method can be used to convert a :py:class:`Stoner.Data` object to
a *pandas.DataFrame*. The numerical data will be transferred directly, with the DataFrame columns being set up
as a two level index of column headers and column assignments. The Stoner library registers an additional
*metadata* extension attribute for DataFrames that provides thin sub-class wrapper around the same regular expression
based and type hinting dictionary that is used to store metadata in :py:attr:`Stoner.Data.metadata`.

The pandas.DataFrame produced by the :py:meth:`Stoner.Data.to_pandas` method is reversibly convertable back to an identical
:py:class:`Stoner.Data` object by passing the DataFrame into the constructor of the :py:class:`Stoner.Data` object.
21 changes: 7 additions & 14 deletions doc/readme.rst
Expand Up @@ -76,27 +76,20 @@ format with more dimensions of data, we suggest you look elsewhere.
Data 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
**Stoner.Data** is the core class for representing individual experimental data sets.
It is actually composed of several mixin classes that provide different functionality, with methods
to examine and manipulate data, manage metadata, load and save data files, plot results and carry out various analysis tasks.
It has a large number of sub classes - most of these are in Stoner.formats and are used to handle the loading of specific
file formats.

There are also two mxin classes designed to work with DataFile to enable additional functionality for writing analysis programs.

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

* **Stoner.plot.PlotMixin** provides additional routines for plotting data on 2D or 3D plots.

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.
a function on each file or group of files. A key feature of DataFolder is its ability to work with the collated metadata from
the individual files that are held in the DataFolder. In combination with its ability to walk through a complete heirarchy of groups of
**Data** objects, the handling of the common metadata provides powerful tools for quickly writing data reduction scripts.

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

0 comments on commit 1b2cb29

Please sign in to comment.