Import of Bruker OPUS files
Bruker OPUS files have also a proprietary file format. The Opus reader (read_opus() ) of spectrochempy is essentially a wrapper of the python module brukeropus developed by Josh Duran. The use of read_opus() is similar to that of read_omnic().
Basic loading of OPUS file
Individual Opus files can be opened and loaded as a new NDDataset using:
[1]:
import spectrochempy as scp
[2]:
Z = scp.read_opus("irdata/OPUS/test.0002")
Z
[2]:
NDDataset [test] — float64, shape: (y:1, x:2567), a.u.
Spectra type: Absorbance
Data
Dimension `x`
Dimension `y`
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002]]
The namespace API is equivalent:
[3]:
Z = scp.opus.read("irdata/OPUS/test.0002")
Z
[3]:
NDDataset [test] — float64, shape: (y:1, x:2567), a.u.
Spectra type: Absorbance
Data
Dimension `x`
Dimension `y`
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002]]
Note: In the previous use of read_opus(), we have assumed that the file is in datadir folder (see the import tutorial or more details on this). If this not the case, you should use an absolute path or a relative path to the current notebook folder.
For multifile loading, one can use:
[4]:
Z1 = scp.read_opus("test.0000", "test.0001", "test.0002", directory="irdata/OPUS")
Z1
[4]:
NDDataset — float64, shape: (y:3, x:2567), a.u.
( test, test, test )
2026-08-16 03:11:25+00:00> Merged from several files
Data
[0.000451 0.0004229 ... 0.5752 0.6311]
[0.0002479 0.0002325 ... 0.5809 0.6376]] a.u.
Dimension `x`
Dimension `y`
[ MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0000 /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0001
/home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002]]
Note: By default all files in the given directory are merged as a single dataset if they are compatibles (i.e., same shape, same type of experiment…). If they cannot be merged due to incompatible shape or type, separate datasets are returned with dataset merged in different groups.
For instance in the following, two dataset will be returned:
[5]:
LZ1 = scp.read_opus(
"test.0000", "test.0001", "test.0002", "background.0", directory="irdata/OPUS"
)
LZ1
[5]:
List (len=2, type=NDDataset)
0: NDDataset — float64, shape: (y:3, x:2567), a.u.
name:NDDataset_2a31ec8fauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Concatenation of 3 datasets:
( test, test, test )history:2026-08-16 03:11:25+00:00> Created by concatenate from 3 datasets: test, test, test
2026-08-16 03:11:25+00:00> Merged from several filesData
title:absorbancevalues:...[[0.000459 0.0004219 ... 0.5771 0.6324]
[0.000451 0.0004229 ... 0.5752 0.6311]
[0.0002479 0.0002325 ... 0.5809 0.6376]] a.u.shape:(y:3, x:2567)Dimension x
size:2567title:wavenumbercoordinates:[ 3998 3997 ... 700.7 699.4] cm⁻¹Dimension y
size:3title:acquisition timestamp (GMT)coordinates:[1.581e+09 1.581e+09 1.581e+09] slabels:...[[ 2020-02-06 12:09:58.095000+00:00 2020-02-06 12:10:02.232000+00:00 2020-02-06 12:10:06.368000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0000 /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0001
/home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002]]1: NDDataset [background] — float64, shape: (y:1, x:4096)
name:backgroundauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Single-channel reference spectrahistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.112818+00:00: import from opus filesData
title:single-channel reference spectravalues:...[[ 0.01242 0.01243 ... 0.001023 0.01261]]shape:(y:1, x:4096)Dimension x
size:4096title:wavenumbercoordinates:[ 5265 5263 ... 1.286 0] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:01:55.349000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/background.0]]
Multifile loading can also be achieved by only specifying the directory to read, if all files in a directory must be read:
[6]:
LZ = scp.read_opus("irdata/OPUS")
LZ
[6]:
List (len=3, type=NDDataset)
0: NDDataset — float64, shape: (y:4, x:2567), a.u.
name:NDDataset_2a5a5f86author:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Concatenation of 4 datasets:
( test, test, test, test )history:2026-08-16 03:11:25+00:00> Created by concatenate from 4 datasets: test, test, test, test
2026-08-16 03:11:25+00:00> Merged from several filesData
title:absorbancevalues:...[[0.000459 0.0004219 ... 0.5771 0.6324]
[0.000451 0.0004229 ... 0.5752 0.6311]
[0.0002479 0.0002325 ... 0.5809 0.6376]
[0.0003685 0.0003442 ... 0.5827 0.6388]] a.u.shape:(y:4, x:2567)Dimension x
size:2567title:wavenumbercoordinates:[ 3998 3997 ... 700.7 699.4] cm⁻¹Dimension y
size:4title:acquisition timestamp (GMT)coordinates:[1.581e+09 1.581e+09 1.581e+09 1.581e+09] slabels:...[[ 2020-02-06 12:09:58.095000+00:00 2020-02-06 12:10:02.232000+00:00 2020-02-06 12:10:06.368000+00:00 2020-02-06 12:10:10.505000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1] MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0000 /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0001
/home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002 /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0003]]1: NDDataset [OPUS_assembled_file] — float64, shape: (y:95, x:1607), a.u.
name:OPUS_assembled_fileauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Absorbancehistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.292373+00:00: import from opus filesData
title:absorbancevalues:...[[0.009281 0.009549 ... 0.03194 0.05728]
[0.009423 0.009198 ... 0.03941 0.04382]
...
[0.008347 0.008503 ... 0.01711 0.007519]
[0.009164 0.009174 ... 0.02331 0.02256]] a.u.shape:(y:95, x:1607)Dimension x
size:1607title:wavenumbercoordinates:[ 3996 3994 ... 900.7 898.8] cm⁻¹Dimension y
size:95title:elapsed timecoordinates:[ 1.265 7.748 ... 602.3 608.8] s2: NDDataset [background] — float64, shape: (y:1, x:4096)
name:backgroundauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Single-channel reference spectrahistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.301005+00:00: import from opus filesData
title:single-channel reference spectravalues:...[[ 0.01242 0.01243 ... 0.001023 0.01261]]shape:(y:1, x:4096)Dimension x
size:4096title:wavenumbercoordinates:[ 5265 5263 ... 1.286 0] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:01:55.349000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/background.0]]
As previously two datasets are returned due to the incompatible types and shapes of the experiments.
If one desire to load of files into separate datasets, then set the merge attribute to False.
[7]:
LZ1 = scp.read_opus("irdata/OPUS", merge=False)
LZ1
[7]:
List (len=6, type=NDDataset)
0: NDDataset [test] — float64, shape: (y:1, x:2567), a.u.
name:testauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Absorbancehistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.600144+00:00: import from opus filesData
title:absorbancevalues:...[[0.000459 0.0004219 ... 0.5771 0.6324]] a.u.shape:(y:1, x:2567)Dimension x
size:2567title:wavenumbercoordinates:[ 3998 3997 ... 700.7 699.4] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:09:58.095000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0000]]1: NDDataset [test] — float64, shape: (y:1, x:2567), a.u.
name:testauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Absorbancehistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.608298+00:00: import from opus filesData
title:absorbancevalues:...[[0.000451 0.0004229 ... 0.5752 0.6311]] a.u.shape:(y:1, x:2567)Dimension x
size:2567title:wavenumbercoordinates:[ 3998 3997 ... 700.7 699.4] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:10:02.232000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0001]]2: NDDataset [test] — float64, shape: (y:1, x:2567), a.u.
name:testauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Absorbancehistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.616455+00:00: import from opus filesData
title:absorbancevalues:...[[0.0002479 0.0002325 ... 0.5809 0.6376]] a.u.shape:(y:1, x:2567)Dimension x
size:2567title:wavenumbercoordinates:[ 3998 3997 ... 700.7 699.4] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:10:06.368000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002]]3: NDDataset [test] — float64, shape: (y:1, x:2567), a.u.
name:testauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Absorbancehistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.624673+00:00: import from opus filesData
title:absorbancevalues:...[[0.0003685 0.0003442 ... 0.5827 0.6388]] a.u.shape:(y:1, x:2567)Dimension x
size:2567title:wavenumbercoordinates:[ 3998 3997 ... 700.7 699.4] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:10:10.505000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0003]]4: NDDataset [OPUS_assembled_file] — float64, shape: (y:95, x:1607), a.u.
name:OPUS_assembled_fileauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Absorbancehistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.584916+00:00: import from opus filesData
title:absorbancevalues:...[[0.009281 0.009549 ... 0.03194 0.05728]
[0.009423 0.009198 ... 0.03941 0.04382]
...
[0.008347 0.008503 ... 0.01711 0.007519]
[0.009164 0.009174 ... 0.02331 0.02256]] a.u.shape:(y:95, x:1607)Dimension x
size:1607title:wavenumbercoordinates:[ 3996 3994 ... 900.7 898.8] cm⁻¹Dimension y
size:95title:elapsed timecoordinates:[ 1.265 7.748 ... 602.3 608.8] s5: NDDataset [background] — float64, shape: (y:1, x:4096)
name:backgroundauthor:runner@runnervmzvulzcreated:2026-08-16 03:11:25+00:00description:Dataset from opus files.
Spectra type: Single-channel reference spectrahistory:2026-08-16 03:11:25+00:00> 2026-08-16 03:11:25.592979+00:00: import from opus filesData
title:single-channel reference spectravalues:...[[ 0.01242 0.01243 ... 0.001023 0.01261]]shape:(y:1, x:4096)Dimension x
size:4096title:wavenumbercoordinates:[ 5265 5263 ... 1.286 0] cm⁻¹Dimension y
size:1title:acquisition timestamp (GMT)coordinates:[1.581e+09] slabels:...[[ 2020-02-06 12:01:55.349000+00:00]
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/background.0]]
Loading given type of OPUS spectra
By default absortion spectra (AB) are load, if present in the file.
Opus file however can contain several types of spectra and they can be retrieved eventually using the correct type in the call to read_opus:
Types possibly availables and readables by read_opus are listed here:
AB: Absorbance (default if present in the file)TR: TransmittanceKM: Kubelka-MunkRAM: RamanEMI: EmissionRFL: ReflectanceLRF: log(Reflectance)ATR: ATRPAS: PhotoacousticRF: Single-channel reference spectraSM: Single-channel sample spectraIGRF: Reference interferogramIGSM: Sample interferogramPHRF: Reference phasePHSM: Sample phase
It is possible to know which are the other types availables in the original file:
[8]:
Z.meta.other_data_types
[8]:
['RF', 'IGRF', 'AB', 'SM', 'PHSM', 'IGSM']
Thus if one wants to load the single-channel sample spectra, the read function syntax would be:
[9]:
ZSM = scp.read_opus("irdata/OPUS/test.0002", type="SM")
ZSM
[9]:
NDDataset [test] — float64, shape: (y:1, x:2567)
Spectra type: Single-channel sample spectra
Data
Dimension `x`
Dimension `y`
[ MCT D317 1mm² [8500 - 700 Cm-1]]
[ /home/runner/.spectrochempy/testdata/irdata/OPUS/test.0002]]
Reading OPUS file Metadata
As just seen above, more information can be obtained on the experiment and spectrometer parameters using the dataset metadata (meta attribute).
For instance, to get a display of all metadata:
[10]:
Z.meta
[10]:
OPUS Parameters
Sample/Result Parameters [params]
Reference Parameters [rf_params]
To display only a sub-group of metadata, you can use :
[11]:
Z.meta.params.fourier_transform
[11]:
Fourier Transform Parameters
or a single parameter:
[12]:
Z.meta.params.optical.bms
[12]:
Beamsplitter
[13]:
Z.meta.params.optical.bms.value
[13]:
'KBr'
Acting on a parameter
Metadata modification, addition, deletion are forbidden by default (readonly=True).
For instance, if one want to add a new parameters, the following is not permitted and then raise an error:
[14]:
try:
Z.meta.xxx = "forbidden"
except ValueError:
scp.error_("meta data dictionary is read only!")
ERROR | SpectroChemPyError: meta data dictionary is read only!
To add a new value (or to modify/delete an existing value), the readonly flag must be unset before the operation:
[15]:
Z.meta.readonly = False
Z.meta.xxx = "permitted"
Z.meta
[15]:
OPUS Parameters
Sample/Result Parameters [params]
Reference Parameters [rf_params]
It is advised to set back the readonly flag to True.