Spectrum¶
The position of spectra is not yet completely set in ixdat.
A spectrum is in essence just a 1-D field where a response variable (e.g. counts, detector current, adsorption) lives on a space defined by a scanning variable (e.g. wavelength, mass-to-charge ratio, two-theta). As such it could be a DataSeries on par with ValueSeries (a 1-D field with a value living in a space defined by a TimeSeries). A Spectrum is however a stand-alone output of an experimental technique. It could also be a type of Measurement.
As it is now, Spectrum is its own base class on par with Measurement, with its own table (i.e. the Spectrum class
inherits directly from Saveable). It has properties which give quick access to the scanning
variable and response as x and y, respectively. It also has its
own plotter and exporter.
Similar questions can be raised about a sequence of spectra - whether it is a Measurement or a 2-D field.
As it is now, sequences of spectra are represented by SpectrumSeries, which inherits from
Spectrum.
The spectra module¶
-
class
ixdat.spectra.Spectrum(name, technique='spectrum', metadata=None, sample_name=None, reader=None, tstamp=None, field=None, field_id=None)[source]¶ The Spectrum class.
A spectrum is a data structure including one-dimensional arrays of x and y variables of equal length. Typically, information about the state of a sample can be obtained from a plot of y (e.g. absorbance OR intensity OR counts) vs x (e.g energy OR wavelength OR angle OR mass-to-charge ratio). Even though in reality it takes time to require a spectrum, a spectrum is considered to represent one instance in time.
In ixdat, the data of a spectrum is organized into a Field, where the y-data is considered to span a space defined by the x-data and the timestamp. If the x-data has shape (N, ), then the y-data has shape (N, 1) to span the x-axis and the single-point t axis.
The Spectrum class makes the data in this field intuitively available. If spec is a spectrum, spec.x and spec.y give access to the x and y data, respectively, while spec.xseries and spec.yseries give the corresponding DataSeries.
-
data_objects¶ The data-containing objects that need to be saved when the spectrum is saved.
For a field to be correctly saved and loaded, its axes_series must be saved first. So there are three series in the data_objects to return FIXME: with backend-specifying id’s, field could check for itself whether FIXME: its axes_series are already in the database.
-
field¶ Since a spectrum can be loaded lazily, we make sure the field is loaded
-
field_id¶ The id of the field
-
classmethod
from_data(x, y, tstamp=None, x_name='x', y_name='y', x_unit_name=None, y_unit_name=None, **kwargs)[source]¶ Initiate a spectrum from data. Does so via cls.from_series
Parameters: - x (np array) – x data
- y (np array) – y data
- tstamp (timestamp) – the timestamp of the spectrum. Defaults to None.
- x_name (str) – Name of the x variable. Defaults to ‘x’
- y_name (str) – Name of the y variable. Defaults to ‘y’
- x_unit_name (str) – Name of the x unit. Defaults to None
- y_unit_name (str) – Name of the y unit. Defaults to None
- kwargs – key-word arguments are passed on ultimately to cls.__init__
-
classmethod
from_field(field, **kwargs)[source]¶ Initiate a spectrum from data. Does so via cls.from_field
Parameters: - field (Field) – The field containing all the data of the spectrum. field.data is the y-data, which is considered to span x and t. field.axes_series[0] is a DataSeries with the x data. field.axes_series[1] is a TimeSeries with one time point.
- kwargs – key-word arguments are passed on ultimately to cls.__init__
-
classmethod
from_series(xseries, yseries, tstamp, **kwargs)[source]¶ Initiate a spectrum from data. Does so via cls.from_field
Parameters: - xseries (DataSeries) – a series with the x data
- yseries (DataSeries) – a series with the y data. The y data should be a vector of the same length as the x data.
- tstamp (timestamp) – the timestamp of the spectrum. Defaults to None.
- kwargs – key-word arguments are passed on ultimately to cls.__init__
-
plotter¶ The default plotter for Measurement is ValuePlotter.
-
classmethod
read(path_to_file, reader, **kwargs)[source]¶ Return a Measurement object from parsing a file with the specified reader
Parameters: - path_to_file (Path or str) – The path to the file to read
- reader (str or Reader class) – The (name of the) reader to read the file with.
- kwargs – key-word arguments are passed on to the reader’s read() method.
-
series_list¶ A Spectrum’s series list includes its field and its axes_series.
-
tseries¶ The TimeSeries of a spectrum is a single point [0] and its tstamp
-
x¶ The x data is the data attribute of the xseries
-
x_name¶ The name of the x variable is the name attribute of the xseries
-
xseries¶ The x DataSeries is the first axis of the field
-
y¶ The y data is the data attribute of the field
-
y_name¶ The name of the y variable is the name attribute of the field
-
yseries¶ The yseries is a DataSeries reduction of the field
-
-
class
ixdat.spectra.SpectrumSeries(*args, **kwargs)[source]¶ -
plotter¶ The default plotter for Measurement is ValuePlotter.
-
t¶ The time array of a SectrumSeries is the data of its tseries. Note that it it is not sorted!
-
t_name¶ The name of the time variable of the spectrum series
-
tseries¶ The TimeSeries of a SectrumSeries is the 0’th axis of its field. Note that its data is not sorted!
-
x¶ The x (scanning variable) data
-
x_name¶ The name of the scanning variable
-
xseries¶ The x-axis DataSeries of a SectrumSeries is the 1’st axis of its field
-
y_average¶ The y-data of the average spectrum
-
yseries¶ The yseries is a DataSeries reduction of the field
-