Mask a saturated region and transform an IR dataset

This example shows three common operations on a 2D infrared dataset: masking a saturated region, transposing the dataset, and converting axis units.

import spectrochempy as scp

Load and inspect the dataset

dataset = scp.read_omnic("irdata/nh4y-activation.spg")
dataset.y -= dataset.y[0]
dataset.y.title = "time"

prefs = scp.preferences
prefs.figure.figsize = (7, 3.5)
prefs.colormap = "Dark2"
prefs.colorbar = True
_ = dataset.plot()
plot masking transpose units

Mask a saturated region

dataset[:, 1290.0:890.0] = scp.MASKED
_ = dataset.plot_stack()
plot masking transpose units

The mask is respected by subsequent operations such as reductions:

dataset.max()
3.8080601692199707 a.u.


Transpose the dataset

Transposition exchanges axes while preserving data and mask:

plot masking transpose units

Convert coordinate units

plot masking transpose units

This ends the example. Uncomment the next line to display the figures when running the script directly with Python.

# scp.show()

Total running time of the script: (0 minutes 4.130 seconds)