Data model

The ParSeq data model is a hierarchical tree model, where each element has zero or more children. If an element has zero children, it is called item and is a data container. If an element has at least one child, it is called group. All items and groups are instances of Spectrum.

The tree model can be manipulated in a script, and the following reference documentation explains how. Otherwise, most typically it is used within the ParSeq GUI, where the tree model feeds the model-view-controller software architecture of Qt, where the user does not have to know about the underlying objects and methods.

class parseq.core.spectra.Spectrum(madeOf, parentItem=None, insertAt=None, **kwargs)

This class is the main building block of the ParSeq data model and is either a group that contains other instances of Spectrum or an item (data container). All elements, except the root, have a parent referred to by parentItem field, and parents have their children in a list childItems. Only the root item is explicitly created by the constructor of Spectrum, and this is done in the module that defines the pipeline. All other tree elements are typically created by the parent’s insert_data() or insert_item() methods.

__init__(madeOf, parentItem=None, insertAt=None, **kwargs)
madeOf

is either a file name, a callable, a list of other Spectrum instances (for making a combination) or a dictionary (for creating branches).

parentItem

is another Spectrum instance or None (for the tree root).

insertAt: int

the position in parentItem.childItems list. If None, the spectrum is appended.

kwargs: dict

defaults to the dictionary: dict(alias=’auto’, dataFormat={}, originNodeName=None, terminalNodeName=None, transformNames=’each’, copyTransformParams=True). The default kwargs can be changed in parseq.core.singletons.dataRootItem.kwargs, where dataRootItem is the root item of the data model that gets instantiated in the module that defines the pipeline.

dataFormat: dict

is assumed to be an empty dict for a data group and must be non-empty for a data item. As a minimum, it defines the key dataSource and sets it to a list of hdf5 names (when for hdf5 data), column numbers or expressions of ‘Col1’, ‘Col2’ etc variables (when for column data). It may define ‘conversionFactors’ as a list of either floats or strings; a float is a multiplicative factor that converts to the node’s array unit and a string is another unit that cannot be converted to the node’s array unit, e.g. the node defines an array with a ‘mA’ unit while the data was measured with a ‘count’ unit. It may define ‘metadata’: a comma separated str of hdf5 attribute names that define metadata.

originNodeName, terminalNodeName: str

The data propagation is between origin node and terminal node, both ends are included. If undefined, they default to the 0th node (the head of the pipeline) and the open end(s). If a node is between the origin node and the terminal node (in the data propagation sense) then the data is present in the node’s data tree view as alias and is displayed in the plot.

transformNames

A list of transform names (or a single str ‘each’). It defines whether a particular transform should be run for this data.

copyTransformParams: bool, default True.

Controls the way the transformParams of the Spectrum are initialized: If False, they are copied from defaultParams of all transforms. If True, they are copied from the first selected spectrum when at least one is selected or otherwise from the ini file.

find_data_item(alias=None)

Finds the first data item with a given alias. Returns None if fails.

get_items(alsoGroupHeads=False)

Returns a list of all items in a given group, also included in all subgroups.

insert_data(data, insertAt=None, **kwargs)

This method inserts a tree-like structure data into the list of children. An example of data: data=["groupName", ["fName1.dat", "fName2.dat"]] for a group with two items in it. All other key word parameters lumped into kwargs are the same as of __init__().

insert_item(name, insertAt=None, **kwargs)

This method inserts a data item name into the list of children. All other key word parameters lumped into kwargs are the same as of __init__() and additionally configData that can pass an instance config.ConfigParser() that contains a saved project.