A data object contains your entire n-dimensional dataset, including axes, units, channels, and relevant metadata. Once you have a data object, all of the other capabilities of WrightTools are immediately open to you, including processing, fitting, and plotting tools.
WrightTools aims to provide user-friendly ways of creating data directly from common spectroscopy file formats. Here are the formats currently supported.
|BrunoldrRaman||Files from Brunold lab resonance raman measurements||
|Cary||Files from Varian’s Cary® Spectrometers||
|COLORS||Files from Control Lots Of Research in Spectroscopy||
|JASCO||Files from JASCO optical spectrometers.||
|KENT||Files from “ps control” by Kent Meyer||
|PyCMDS||Files from PyCMDS.||
|Ocean Optics||.scope files from ocean optics spectrometers||
|Shimadzu||Files from Shimadzu UV-VIS spectrophotometers.||
|SPCM||Files from Becker & Hickl spcm software||
|Tensor 27||Files from Bruker Tensor 27 FT-IR||
Is your favorite format missing? It’s easy to add—promise! Check out Contributing.
Got bare numpy arrays and dreaming of data? It is possible to create data objects directly in special circumstances, as shown below.
# import import numpy as np import WrightTools as wt # generate arrays for example def my_resonance(xi, yi, intensity=1, FWHM=500, x0=7000): def single(arr, intensity=intensity, FWHM=FWHM, x0=x0): return intensity*(0.5*FWHM)**2/((xi-x0)**2+(0.5*FWHM)**2) return single(xi) * single(yi) xi = np.linspace(6000, 8000, 75)[:, None] yi = np.linspace(6000, 8000, 75)[None, :] zi = my_resonance(xi, yi) # package into data object data = wt.Data(name='example') data.create_variable(name='w1', units='wn', values=xi) data.create_variable(name='w2', units='wn', values=yi) data.create_channel(name='signal', values=zi) data.transform('w1', 'w2')
Structure & properties¶
So what is a data object anyway?
To put it simply,
Data is a collection of
Axis objects are composed of
See also Data.axis_expressions, Data.channel_names and Data.variable_names.
Axes are the coordinates of the dataset. They have the following key attributes:
|axis.label||LaTeX-formatted label, appropriate for plotting|
|axis.min()||coordinates minimum, in current units|
|axis.max()||coordinates maximum, in current units|
|axis.units||current axis units (change with
Channels contain the n-dimensional data itself. They have the following key attributes:
|channel.label||LaTeX-formatted label, appropriate for plotting|
|channel.mag()||channel magnitude (furthest deviation from null)|
|channel.null||channel null (value of zero signal)|
|channel.signed||flag to indicate if channel is signed|
As mentioned above, the axes and channels within data can be accessed within the
Data also supports natural naming, so axis and channel objects can be accessed directly according to their name.
The natural syntax is recommended, as it tends to result in more readable code.
>>> data.axis_expressions ('w1', 'w2') >>> data.w2 == data.axes True >>> data.channel_names ('signal', 'pyro1', 'pyro2', 'pyro3') >>> data.pyro2 == data.channels True
The order of axes and channels is arbitrary.
However many methods within WrightTools operate on the zero-indexed channel by default.
For this reason, you can bring your favorite channel to zero-index using
Units aware & interpolation ready¶
Experiments are taken over all kinds of dynamic range, with all kinds of units. You might wish to take the difference between a UV-VIS scan taken from 400 to 800 nm, 1 nm steps and a different scan taken from 1.75 to 2.00 eV, 1 meV steps. This can be a huge pain! Even if you converted them to the same unit system, you would still have to deal with the different absolute positions of the two coordinate arrays.
WrightTools data objects know all about units, and they implicitly use interpolation to map between different absolute coordinates. Here we list some of the capabilities that are enabled by this behavior.
||use interpolation to guess the value of NaNs within a channel|
||join together multiple data objects, accounting for dimensionality and overlap|
||re-map data coordinates|
||offset one axis based on another|
Dimensionality without the cursing¶
Working with multidimensional data can be intimidating. What axis am I looking at again? Where am I in the other axis? Is this slice unusual, or do they all look like that?
WrightTools tries to make multi-dimensional data easy to work with. The following methods deal directly with dimensionality manipulation.
||chop data into a list of lower dimensional data|
||destroy one dimension of data using a mathematical strategy|
||split data at a series of coordinates, without reducing dimensionality|
WrightTools seamlessly handles dimensionality throughout. Artists is one such place where dimensionality is addressed explicitly.
Processing without the pain¶
There are many common data processing operations in spectroscopy. WrightTools endeavors to make these operations easy. A selection of important methods follows.
||clip values outside of a given range|
||level the edge of data along a certain axis|
||smooth a channel via convolution with a n-dimensional Kaiser window|
||zoom a channel using spline interpolation|