WrightTools.collection package

Module contents

Collection class and associated.

class WrightTools.collection.Collection(file=None, parent=None, name=None, **kwargs)[source]

Bases: WrightTools._group.Group

Nestable Collection of Data objects.

class_name = 'Collection'
create_collection(name='collection', position=None, **kwargs)[source]

Create a new child colleciton.

Parameters:
  • name (string) – Unique identifier.
  • position (integer (optional)) – Location to insert. Default is None (append).
  • kwargs – Additional arguments to child collection instantiation.
Returns:

New child.

Return type:

WrightTools Collection

create_data(name='data', position=None, **kwargs)[source]

Create a new child data.

Parameters:
  • name (string) – Unique identifier.
  • position (integer (optional)) – Location to insert. Default is None (append).
  • kwargs – Additional arguments to child data instantiation.
Returns:

New child.

Return type:

WrightTools Data

flush()[source]

Ensure contents are written to file.

index()[source]

Index.

print_tree(depth=9, *, verbose=False)[source]

Print a ascii-formatted tree representation of the collection contents.

Parameters:
  • depth (integer (optional)) – Number of layers to include in the tree. Default is 9.
  • verbose (boolean (optional)) – Toggle inclusion of extra information. Default is True.
WrightTools.collection.from_Cary(filepath, name=None, parent=None, verbose=True)[source]

Create a collection object from a Cary UV VIS absorbance file.

We hope to support as many Cary instruments and datasets as possible. This function has been tested with data collected on a Cary50 UV/VIS spectrometer. If any alternate instruments are found not to work as expected, please submit a bug report on our issue tracker.

>>> import WrightTools as wt
>>> from WrightTools import datasets
>>> p = datasets.Cary.CuPCtS_H2O_vis
>>> data = wt.collection.from_Cary(p)[0]
>>> wt.artists.quick1D(data)

(Source code, png, pdf)

../_images/WrightTools-collection-1.png
Parameters:
  • filepath (string) – Path to Cary output file (.csv).
  • parent (WrightTools.Collection) – A collection object in which to place a collection of Data objects.
  • verbose (boolean (optional)) – Toggle talkback. Default is True.
Returns:

New data object.

Return type:

data

WrightTools.collection.from_directory(filepath, from_methods, *, name=None, parent=None, verbose=True)[source]

Create a WrightTools Collection from a directory of source files.

Parameters:
  • filepath (str) – Path to the directory on the file system
  • from_methods (dict<str, callable>) – Dictionary which maps patterns (using Unix-like glob wildcard patterns) to functions which take a filepath, plus the keyword arguments [‘name’, ‘parent’, and ‘verbose’]. (e.g. most from_<kind> methods within WrightTools) The value can be None which results in that item being ignored. The first matching pattern encountered will be used. Therefore, if multiple patterns will match the same file, use and OrderedDict. Patterns are matched on the file name level, not using the full path.
Keyword Arguments:
 
  • name (str) – Name to use for the root data object. Default is the directory name.
  • parent (Collection) – Parent collection to insert the directory structure into. Default is a new collection in temp file.
  • verbose (bool) – Print information as objects are created. Passed to the functions.

Examples

>>> from_dict = {'*.data':wt.data.from_PyCMDS,
...              '*.csv':wt.collections.from_Cary,
...              'unused':None,
...             }
>>> col = wt.collection.from_directory('path/to/folder', from_dict)