# Basic Concepts¶

## Data¶

The data is stored in a tree-like structure. There is one top-level element,
the *project*. The next lower level is that of the *plots*, each of which can
hold an arbitrary number of *sets*. A *set* is a 2d array containing the x-y
data, where the x-data is ordered (typical for spectroscopic data). This data
structure is represented by the tree view on the right side of the main frame.
In addition to the plain x-y data, a set can have various objects attached, such
as transformations (*trafo*), a fit *model* and *weights*.

Unlike some other data analysis programs, peak-o-mat allows for data
manipulation/transformation on a higher level than operating on the raw data
through a spreadsheet like interface. As peak-o-mat is especially designed to
work with spectroscopic data, arithmetics on *sets* will do what you would
expect intuitively, e.g. adding two *sets* will only add the y-data, while
interpolating the x-axes in case they differ. Those kind of manipulations can be
done using the ‘Set operations’ module. If you need to do more complicate
operations, you can still copy the data to a *data grid* and manipulate the data
there by means of a python shell.

## Models¶

A *model* is an analytical function to which the set data is fitted. It can be
described by

- a valid python expression, where
*x*stands for the set’s x-values. You can use arbitrary variable names containing alphanumeric characters, e.g. “a*exp(-b0*x**2)”, and all functions/symbols defined in the top level namespace of the*numpy*package. There are some pre-defined physical constants which can be accessed using their name prefixed by ‘c_‘, e.g. ‘c_e0’ referes to the elementary charge. See the ‘customisation’ sectioin for how to add your own constants. - a space separated list of pre-defined symbols, here called
*tokens*, which represent common backgrounds and peak shapes. The function values represented by the tokens are finally added, e.g. “CB LO GA LO” represents a model with a constant background, one gaussian peak and two lorenzian peak shapes. You can append a number to any token to be able to distinguish them later, e.g. “CB LO1 GA LO2”. Instead of the whitespace between the tokens, the ‘+’ operator can be used. In some rare cases you might want to multiply the function represented by the tokens. This can be achieved by using the ‘*’ operator. The model is evaluated from left to right and the usual sign rules do not apply!

Once a data set has been fitted, the model including the fitted parameters is attached to the set and whenever the set is selected, the model is evaluated and plotted in green together with the data.

## Transformations and masks¶

A *trafo* denotes any transformation of the x- or y-data of a set. Instead of
changing the original data, all trafos are attached to a set and evaluated on
demand whenever the set data is accessed. Like this, the original data can be
restored by simply removing all trafos. Furthermore, if you remove bad data
points from a set, a *mask* is applied to the data so that all points can be
restored at any time. Use the popup menu in the tree view to unset a mask or
remove the transformations attached to the currently selected sets. The ‘Set
Info’ model allows for manipulation of every single transformation of a set. The
transformation expresseion can be changed, transofrmations can be deactivated
and both masks and tranformations can be made permanent, i.e. they are applied
once and the original data is overwritten with the result from the evaluation.

## Weights¶

Sometimes one may need to weight the data in order to suppress the effect of outliers on the fit. Weights can be specified both relative to the data or in absolute values. See the description of the fit module for how to specify the weights. The weights are visualised by two blue lines corresponding to the bounds of the variance evaluated as sigma^2 = 1/w.