Public API referenceο
The SpectroChemPy
API publicly exposes many objects and functions.
They are listed below exhaustively.
What is not listed here is reserved for developers and should not normally be necessary for normal use of SpectroChemPy
.
Loading the APIο
To use the API, you must import it using one of the following syntax:
In [1]: import spectrochempy as scp # Recommended!
In [2]: nd = scp.NDDataset()
In [3]: from spectrochempy import * # strongly discouraged
In [4]: nd = NDDataset()
With the second syntax, as often in python, the access to objects/functions can be greatly simplified. For example,
we can use NDDataset
without a prefix instead of scp.NDDataset
which is the first syntax) but there is always a risk
of overwriting some variables or functions already present in the namespace. Therefore, the first syntax is generally
highly recommended.
However instead of the second syntax, one can always use the following way to import objects or functions:
In [5]: from spectrochempy import NDDataset
In [6]: nd = NDDataset()
The NDDataset Objectο
The NDDataset
is the main object use by SpectroChemPy
.
Like numpy.ndarray`s, `NDDataset
have the capability to be sliced, sorted and subject to mathematical operations.
But, in addition, NDDataset
may have units, can be masked and each dimension can also have coordinated with units.
This make NDDataset
aware of unit compatibility, e.g.,, for binary operation such as additions or subtraction or
during the application of mathematical operations. In addition or in replacement of numerical data for coordinates,
NDDataset can also have labeled coordinates where labels can be different kinds of objects (strings, datetime, numpy
nd.ndarray or other NDDatasets, etcβ¦).
This offers a lot of flexibility in using NDDatasets that, we hope, will be useful for applications. See the userguide for more information about such possible applications.
The main N-dimensional dataset class used by |
Creating NDDatasetο
A NDDataset
can be created using the NDDataset
class constructor, for instance here we create a dataset from a
random
two-dimensional array:
In [7]: import numpy as np
In [8]: X = np.random.random((4,4))
In [9]: nd = NDDataset(X)
The above code in SpectroChemPy
can be simplified using the random
creation method:
In [10]: X = NDDataset.random((4,4))
(see the userguide for a large set of examples on how to use this constructor.)
Many SpectroChemPy methods mimics numpy
equivalent, but output a NDDataset
object.
Basic creation methodsο
Return a new |
|
Return a new |
|
Return a new |
|
Return a new |
|
Return a new uninitialized |
|
Return a |
|
Return |
|
Return a |
|
Return a 2-D array with ones on the diagonal and zeros elsewhere. |
|
Return the identity |
|
Return random floats in the half-open interval [0.0, 1.0). |
|
Extract a diagonal or construct a diagonal array. |
Creation from existing dataο
Generic (shallow and deep) copying operations. |
|
Construct a nddataset by executing a function over each coordinate. |
|
Create a new 1-dimensional array from an iterable object. |
Creation from numerical rangesο
Return evenly spaced values within a given interval. |
|
Return evenly spaced numbers over a specified interval. |
|
Return numbers spaced evenly on a log scale. |
|
Return numbers spaced evenly on a log scale (a geometric progression). |
Select data in a NDDatasetο
Take elements from an array. |
Import/exportο
Import a NDataset from external sourceο
Open data from a '.scp' (NDDataset) or '.pscp' (Project) file. |
|
Read data from various file formats. |
|
Open |
|
Open a |
|
Open a Surface Optics Corps. |
|
Read an entire directory. |
|
Open a Surface Optics Corps. |
|
Open Infrared |
|
Read a single Raman spectrum or a series of Raman spectra. |
|
Read a single Raman spectrum or a series of Raman spectra. |
|
Read a single Raman spectrum or a series of Raman spectra. |
|
Read a matlab file with extension |
|
Read a matlab file with extension |
|
Open a Thermo Nicolet OMNIC file. |
|
Open Bruker OPUS file(s). |
|
Read a Pfeiffer Vacuum's QUADERA mass spectrometer software file with extension |
|
Open a Surface Optics Corps. |
|
Read a Surface Optics Corps. |
|
Open a Thermo Nicolet file or a list of files with extension |
|
Read GRAMS/Thermo Scientific Galactic files or a list of files with extension |
|
Open a Thermo Nicolet file or a list of files with extension |
|
Open a Thermo Nicolet file or a list of files with extension |
|
Open Bruker TOPSPIN (NMR) dataset. |
|
Open a zipped list of data files. |
|
Open |
|
Upload the classical "iris" dataset. |
|
Upload IR spectra from NIST webbook. |
Export a NDDatasetο
Save dataset in native .scp format. |
|
Save the current NDDataset in SpectroChemPy format (.scp). |
|
Write the current dataset. |
|
Write a dataset in CSV format. |
|
This method is an alias of |
|
Write a dataset in JCAMP-DX format. |
|
This method is an alias of |
|
This method is an alias of |
|
This method is an alias of |
|
Return a numpy masked array. |
|
Convert a NDDataset instance to an |
Plottingο
Plot the dataset using the specified method. |
|
Plot of one-dimensional data. |
|
Plot a 1D dataset with solid pen by default. |
|
Plot a 1D dataset as a scatter plot (points can be added on lines). |
|
Plot a 1D dataset with solid pen by default. |
|
Plot a 2D dataset as a stacked plot with its transposition in a second axe. |
|
Plot a 1D dataset with bars. |
|
Plot of 2D array. |
|
Plot a 2D dataset as a contoured map. |
|
Plot a 2D dataset as a stack plot. |
|
Plot a 2D dataset as an image plot. |
|
Plot of 2D array as 3D plot. |
|
Plot a 2D dataset as a a 3D-surface. |
|
Plot a 2D dataset as a a 3D-waterfall plot. |
|
Plot a series of 1D datasets as a scatter plot with optional lines between markers. |
|
Generate a figure with multiple axes arranged in array (n rows, n columns). |
|
Plot a multiplot with 2D image type plots. |
|
Plot a multiplot with 1D linetype plots. |
|
Plot a multiplot with 2D map type plots. |
|
Plot a multiplot with 1D scatter type plots. |
|
Plot a multiplot with 2D stack type plots. |
|
Plot a 2D dataset as a stacked plot with its transposition in a second axe. |
|
Force the |
Processingο
Transpose-like operationsο
Permute the dimensions of a NDDataset. |
|
Interchange two dimensions of a NDDataset. |
Changing number of dimensionsο
Remove single-dimensional entries from the shape of a NDDataset. |
Changing typeο
Set the object data as complex. |
Joining or splitting datasetsο
Concatenation of |
|
Stack of |
Indexingο
Extract a diagonal or construct a diagonal array. |
|
Return the diagonal of a 2D array. |
|
Take elements from an array. |
Sortingο
Return the dataset sorted along a given dimension. |
Minimum and maximumο
Indexes of minimum of data along axis. |
|
Indexes of maximum of data along axis. |
|
Find oordinates of the mainimum of data along axis. |
|
Find coordinates of the maximum of data along axis. |
|
Return the maximum of the dataset or maxima along given dimensions. |
|
Return the maximum of the dataset or maxima along given dimensions. |
|
Return the maximum of the dataset or maxima along given dimensions. |
|
Return the maximum of the dataset or maxima along given dimensions. |
|
Range of values (maximum - minimum) along a dimension. |
Clipping and roundingο
Clip (limit) the values in a dataset. |
|
Evenly round to the given number of decimals. |
|
Evenly round to the given number of decimals. |
Algebraο
Return the dot product of two NDDatasets. |
|
Singular Value Decomposition (SVD). |
|
Ordinary least squares Linear Regression (LSTSQ). |
|
Non-Negative least squares Linear Regression (NNLS). |
Logic functionsο
Test whether all array elements along a given axis evaluate to True. |
|
Test whether any array element along a given axis evaluates to True. |
Sums, integal, differenceο
Sum of array elements over a given axis. |
|
Return the cumulative sum of the elements along a given axis. |
|
Integrate using the composite trapezoidal rule. |
|
Integrate using the composite Simpson's rule. |
Complexο
Conjugate of the NDDataset in the specified dimension. |
|
Conjugate of the NDDataset in the specified dimension. |
|
Calculate the absolute value of the given NDDataset element-wise. |
|
Calculate the absolute value of the given NDDataset element-wise. |
Masksο
Remove all masks previously set on this array. |
Units manipulationο
Return the object with data rescaled to different units. |
|
Return an array rescaled to base units. |
|
Return an array scaled in place to reduced units. |
|
Inplace scaling to different units. |
|
Inplace rescaling to base units. |
|
Quantity scaled in place to reduced units, inplace. |
|
Check the compatibility of units with another object. |
|
Set a NMR context relative to the given Larmor frequency. |
Mathematical operationsο
Modulus calculation. |
|
Power spectrum. |
Statistical operationsο
Compute the arithmetic mean along the specified axis. |
|
Compute the weighted average along the specified axis. |
|
Compute the standard deviation along the specified axis. |
|
Sum of array elements over a given axis. |
|
Compute the variance along the specified axis. |
Baseline correctionο
Baseline Correction processor. |
|
Automatic subtraction of a reference to the dataset. |
|
Compute a baseline using the Baseline class processor. |
|
Compute a baseline corrected dataset using the Baseline class processor. |
|
Remove polynomial trend along a dimension from dataset. |
|
Asymmetric Least Squares Smoothing baseline correction. |
|
Perform Simple Non-Iterative Peak (SNIP) detection algorithm. |
Fourier transformο
Apply a complex fast fourier transform. |
|
Apply a inverse fast fourier transform. |
|
Hilbert transform. |
|
Frequency shift by Fourier transform. |
|
Frequency Shift by Fourier transform. |
Phasingο
Linear phase correction. |
|
Exponential Phase Correction. |
Time-domain processingο
Offset correctionο
Time domain baseline correction. |
Zero-fillingο
Zero fill to given size. |
|
Zero fill to next largest power of two. |
|
Zero fill by doubling original data size once or multiple times. |
|
Zero fill to given size. |
Rollingο
Circular shift. |
|
Left shift and zero fill. |
|
Roll dimensions. |
|
Right shift and zero fill. |
Apodizationο
Calculate Bartlett apodization (triangular window with end points at zero). |
|
Calculate a minimum 4-term Blackman-Harris apodization. |
|
Calculate generalized Hamming (== Happ-Genzel) apodization. |
|
Calculate generalized Hamming apodization. |
|
Return a Hann window. |
|
Calculate triangular apodization with non-null extremities and maximum value normalized to 1. |
|
Calculate exponential apodization. |
|
Calculate lorentz-to-gauss apodization. |
|
Calculate apodization with a Sine window multiplication. |
|
Strictly equivalent to |
|
Equivalent to |
|
Equivalent to |
Smoothing, filtering, denoisingο
Filters/smoothers processor. |
|
Savitzky-Golay filter. |
|
Smooth the data using a window with requested size. |
|
Smooth the data using the Whittaker smoothing algorithm. |
|
Denoise the data using a PCA method. |
|
Remove spikes from the data. |
Alignment, interpolationο
Align individual |
|
Miscellaneousο
Apply func(self, *args, **kwargs). |
Analysisο
Linear regressionο
Ordinary least squares Linear Regression (LSTSQ). |
|
Non-Negative least squares Linear Regression (NNLS). |
Non-linear optimization and curve fitο
Non-linear Least-Square Optimization and Curve-Fitting. |
Partial Least Square regressionο
Partial Least Squares regression (PLSRegression). |
Evolving factor analysisο
Evolving Factor Analysis (EFA). |
Integral inversion solver for spectroscopic dataο
Integral inversion solver for spectroscopic data (IRIS). |
|
Define a kernel matrix of Fredholm equation of the 1st kind. |
Multivariate Curve Resolution - Alternating Least Squaresο
Multivariate Curve Resolution Alternating Least Squares (MCRALS). |
Independant Component Analysisο
Fast algorithm for Independent Component Analysis (FastICA). |
Non-Negative Matrix Factorizationο
Non-Negative Matrix Factorization (NMF). |
Singular value decomposition and Principal component analysisο
Principal Component Anamysis (PCA). |
|
Singular Value Decomposition (SVD). |
SIMPLe to use Interactive Self-modeling Mixture Analysisο
SIMPLe to use Interactive Self-modeling Mixture Analysis (SIMPLISMA). |
Utilitiesο
Lineshape modelsο
Normalized 1D gaussian function. |
|
A standard Lorentzian function (also known as the Cauchy distribution). |
|
A Voigt model constructed as the convolution of a |
|
An asymmetric Voigt model. |
|
A Sigmoid function. |
|
Arbitrary-degree polynomial (degree limited to 10, however). |
Find peaksο
Find and analyze peaks in spectroscopic data with advanced filtering options. |
Kineticο
An object which stores a reaction network of elementary reactions. |
|
PFR reactor as a CSTR in series. |
Project managementο
A manager for projects, datasets and scripts. |
Scriptingο
This is rather experimental
Executable scripts. |
|
Execute a given project script in the current context. |
|
Execute all scripts in a project following their priority. |
Utilitiesο
Loggingο
Set the logging level for SpectroChemPy. |
|
Get current logging level. |
|
Format a debug message. |
|
Format an info message. |
|
Format a warning message. |
|
Format an error message. |
Miscο
Print the versions of spectrochempy and its dependencies. |
Fileο
Clean a path or a series of path. |