Warning

You are reading the documentation related to the development version. Go here if you are looking for the documentation of the stable release.

2D-IRIS analysis example

In this example, we perform the 2D IRIS analysis of CO adsorption on a sulfide catalyst.

import spectrochempy as scp

Uploading dataset

X = scp.read("irdata/CO@Mo_Al2O3.SPG")

X has two coordinates: * wavenumbers named “x” * and timestamps (i.e., the time of recording) named “y”.

print(X.coordset)
CoordSet: [x:wavenumbers, y:acquisition timestamp (GMT)]

Setting new coordinates

The y coordinates of the dataset is the acquisition timestamp. However, each spectrum has been recorded with a given pressure of CO in the infrared cell.

Hence, it would be interesting to add pressure coordinates to the y dimension:

pressures = [
    0.003,
    0.004,
    0.009,
    0.014,
    0.021,
    0.026,
    0.036,
    0.051,
    0.093,
    0.150,
    0.203,
    0.300,
    0.404,
    0.503,
    0.602,
    0.702,
    0.801,
    0.905,
    1.004,
]

c_pressures = scp.Coord(pressures, title="pressure", units="torr")

Now we can set multiple coordinates:

c_times = X.y.copy()  # the original coordinate
X.y = [c_times, c_pressures]
print(X.y)
CoordSet: [_1:acquisition timestamp (GMT), _2:pressure]

To get a detailed a rich display of these coordinates. In a jupyter notebook, just type:

DIMENSION `x`
size 3112
title wavenumbers
coordinates
[ 4000 3999 ... 1001 999.9] cm⁻¹
DIMENSION `y`
size 19
(_1)
title acquisition timestamp (GMT)
coordinates
[1.477e+09 1.477e+09 ... 1.477e+09 1.477e+09] s
labels
[[ 2016-10-18 13:49:35+00:00 2016-10-18 13:54:06+00:00 ... 2016-10-18 16:01:33+00:00 2016-10-18 16:06:37+00:00]
[ *Résultat de Soustraction:04_Mo_Al2O3_calc_0.003torr_LT_after sulf_Oct 18 15:46:42 2016 (GMT+02:00)
*Résultat de Soustraction:04_Mo_Al2O3_calc_0.004torr_LT_after sulf_Oct 18 15:51:12 2016 (GMT+02:00) ...
*Résultat de Soustraction:04_Mo_Al2O3_calc_0.905torr_LT_after sulf_Oct 18 17:58:42 2016 (GMT+02:00)
*Résultat de Soustraction:04_Mo_Al2O3_calc_1.004torr_LT_after sulf_Oct 18 18:03:41 2016 (GMT+02:00)]]
(_2)
title pressure
coordinates
[ 0.003 0.004 ... 0.905 1.004] torr


By default, the current coordinate is the first one (here c_times ). For example, it will be used by default for plotting:

prefs = X.preferences
prefs.figure.figsize = (7, 3)
_ = X.plot(colorbar=True)
_ = X.plot_map(colorbar=True)
  • plot iris
  • plot iris

To seamlessly work with the second coordinates (pressures), we can change the default coordinate:

X.y.select(2)  # to select coordinate `_2`
X.y.default
size 19
title pressure
coordinates
[ 0.003 0.004 ... 0.905 1.004] torr


Let’s now plot the spectral range of interest. The default coordinate is now used:

X_ = X[:, 2250.0:1950.0]
print(X_.y.default)
_ = X_.plot()
_ = X_.plot_map()
  • plot iris
  • plot iris
Coord: [float64] torr (size: 19)

IRIS analysis without regularization

Perform IRIS without regularization (the loglevel can be set to INFO to have information on the running process)

iris1 = scp.IRIS(log_level="INFO")

first we compute the kernel object

K = scp.IrisKernel(X_, "langmuir", q=[-8, -1, 50])
Creating Kernel...
Kernel now ready as IrisKernel().kernel!

The actual kernel is given by the kernel attribute

name langmuir kernel matrix
author runner@fv-az1106-694
created 2024-04-27 03:03:02+02:00
DATA
title coverage
values
[[ 0.06424 0.1265 ... 0.001332 0.0005778]
[ 0.0659 0.1303 ... 0.00177 0.0007683]
...
[ 0.0714 0.1428 ... 0.1056 0.05078]
[ 0.0714 0.1428 ... 0.1084 0.05227]]
shape (y:19, x:50)
DIMENSION `x`
size 50
title $\Delta_{ads}G^{0}/RT$
coordinates
[ -8 -7.857 ... -1.143 -1]
DIMENSION `y`
size 19
title pressure
coordinates
[ 0.003 0.004 ... 0.905 1.004] torr


Now we fit the model - we can pass either the Kernel object or the kernel NDDataset

 Build S matrix (sharpness)
 ... done
 Solving for 312 channels and 19 observations, no regularization
 -->  residuals = 1.09e-01    curvature = 9.14e+04
 Done.

<spectrochempy.analysis.decomposition.iris.IRIS object at 0x7f1a3603a980>

Plots the results

  • 2D IRIS distribution, $\lambda$ = 0.00e+00
  • 2D IRIS merit plot, $\lambda$ = 0.00e+00