Note
Go to the end to download the full example code.
Reading SPC format files#
This example shows reading of ‘Galactic Industries’ SPC data file format. (.spc format).
Import the package
import spectrochempy as scp
Read a single spectrum file#
ex1 = scp.read_spc("galacticdata/BENZENE.SPC")
_ = ex1.plot()
ex1

NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/BENZENE.SPC] — float64, shape: (y:1, x:1842), a.u.
name
:
/home/docs/.spectrochempy/testdata/galacticdata/BENZENE.SPC
author
:
docs@f885430b712d
created
:
2026-11-05 17:43:43+00:00
description
:
Dataset from spc file.
Memo: FT-IR Spectrum of Benzene, Capillary Film.
Memo: FT-IR Spectrum of Benzene, Capillary Film.
history
:
2026-11-05 17:43:43+00:00> Imported Galactic SPC file BENZENE.SPC
Data
title
:
Absorbance
values
:
[[ 0.1016 0.09619 ... 0.0144 0.01514]] a.u.
shape
:
(y:1, x:1842)
Dimension `x`
size
:
1842
title
:
Wavenumbers
coordinates
:
[ 449.4 451.4 ... 3999 4000] cm⁻¹
Dimension `y`
size
:
1
title
:
acquisition timestamp (GMT)
coordinates
:
[8.579e+08] s
labels
:
[ 1997-03-09 08:46:00]
Read merged subfiles#
When subfiles share the same x-coordinates, they are merged automatically:
ex2 = scp.read_spc("galacticdata/CONTOUR.SPC")
_ = ex2.plot()
ex2

NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/CONTOUR.SPC] — float64, shape: (y:19, x:179), a.u.
name
:
/home/docs/.spectrochempy/testdata/galacticdata/CONTOUR.SPC
author
:
docs@f885430b712d
created
:
2026-11-05 17:43:44+00:00
description
:
Dataset from spc file.
Memo: Subfiles are the Same Portion of POLYS Multiplied by a Sine Wave.
Memo: Subfiles are the Same Portion of POLYS Multiplied by a Sine Wave.
history
:
2026-11-05 17:43:44+00:00> Imported Galactic SPC file CONTOUR.SPC
Data
title
:
Absorbance
values
:
[[5.282e-05 4.543e-05 ... 6.53e-05 5.282e-05]
[5.217e-05 4.488e-05 ... 6.45e-05 5.217e-05]
...
[5.243e-05 4.51e-05 ... 6.482e-05 5.243e-05]
[5.335e-05 4.589e-05 ... 6.596e-05 5.335e-05]] a.u.
[5.217e-05 4.488e-05 ... 6.45e-05 5.217e-05]
...
[5.243e-05 4.51e-05 ... 6.482e-05 5.243e-05]
[5.335e-05 4.589e-05 ... 6.596e-05 5.335e-05]] a.u.
shape
:
(y:19, x:179)
Dimension `x`
size
:
179
title
:
Wavenumbers
coordinates
:
[ 3132 3130 ... 2791 2789] cm⁻¹
Dimension `y`
size
:
19
title
:
axis title
coordinates
:
[ 0 2 ... 34 36]
Read subfiles with different x-coordinates#
Subfiles with distinct x-coordinates are returned as a list:

List (len=6, type=NDDataset)
0: NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPC] — float64, shape: (y:1, x:124)
name:/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPCauthor:docs@f885430b712dcreated:2026-11-05 17:43:44+00:00description:Dataset from spc file.
Memo: Multifile of Peak Mass Spectra from Drug Sample.spcFormat
Log Text:
---------
[FILEINFO]
1999/10/14 14:10 W = Modified Date/Time (FILEINFO.AB) User=brigitte
Version = 5.22
[END FILEINFO]
[GC-MS]
Version = 1.10
2000/09/12 12:44 I = Interpolated (GCMS.AB) User=Brigitte
2000/09/12 12:44 T = Truncated (GCMS.AB) User=Brigitte
Original File = drug sample.spc
Operation: Save TIC peaks to Multifile
Peak Spectra:
Subfile # Left Bsln Center Z Right Bsln
74 4.66900015 4.75843334 4.85790014
176 5.68198347 5.77180004 5.81143332
187 5.82154989 5.88114977 5.98111677
242 6.33855009 6.42843342 6.52845001
279 6.70749998 6.79773331 6.89788342
306 6.9770999 7.06698322 7.16693354
[END GC-MS]
[FILEINFO]
2000/09/12 12:45 W = Modified Date/Time (FILEINFO.AB) User=Brigitte
Version = 6.00
[END FILEINFO]history:2026-11-05 17:43:44+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPCData
title:Arbitrary Intensityvalues:...[[ 2803 1.723e+04 ... 7720 1930]]shape:(y:1, x:124)Dimension x
size:124title:m/zcoordinates:[ 37.85 39.05 ... 305.1 354.9] g⋅e⁻¹⋅mol⁻¹Dimension y
size:1title:Timecoordinates:[ 5.881] min1: NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPC] — float64, shape: (y:1, x:141)
name:/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPCauthor:docs@f885430b712dcreated:2026-11-05 17:43:44+00:00description:Dataset from spc file.
Memo: Multifile of Peak Mass Spectra from Drug Sample.spcFormat
Log Text:
---------
[FILEINFO]
1999/10/14 14:10 W = Modified Date/Time (FILEINFO.AB) User=brigitte
Version = 5.22
[END FILEINFO]
[GC-MS]
Version = 1.10
2000/09/12 12:44 I = Interpolated (GCMS.AB) User=Brigitte
2000/09/12 12:44 T = Truncated (GCMS.AB) User=Brigitte
Original File = drug sample.spc
Operation: Save TIC peaks to Multifile
Peak Spectra:
Subfile # Left Bsln Center Z Right Bsln
74 4.66900015 4.75843334 4.85790014
176 5.68198347 5.77180004 5.81143332
187 5.82154989 5.88114977 5.98111677
242 6.33855009 6.42843342 6.52845001
279 6.70749998 6.79773331 6.89788342
306 6.9770999 7.06698322 7.16693354
[END GC-MS]
[FILEINFO]
2000/09/12 12:45 W = Modified Date/Time (FILEINFO.AB) User=Brigitte
Version = 6.00
[END FILEINFO]history:2026-11-05 17:43:44+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPCData
title:Arbitrary Intensityvalues:...[[ 6180 1823 ... 5930 2219]]shape:(y:1, x:141)Dimension x
size:141title:m/zcoordinates:[ 39.05 39.95 ... 355 355.9] g⋅e⁻¹⋅mol⁻¹Dimension y
size:1title:Timecoordinates:[ 5.772] min2: NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPC] — float64, shape: (y:1, x:237)
name:/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPCauthor:docs@f885430b712dcreated:2026-11-05 17:43:44+00:00description:Dataset from spc file.
Memo: Multifile of Peak Mass Spectra from Drug Sample.spcFormat
Log Text:
---------
[FILEINFO]
1999/10/14 14:10 W = Modified Date/Time (FILEINFO.AB) User=brigitte
Version = 5.22
[END FILEINFO]
[GC-MS]
Version = 1.10
2000/09/12 12:44 I = Interpolated (GCMS.AB) User=Brigitte
2000/09/12 12:44 T = Truncated (GCMS.AB) User=Brigitte
Original File = drug sample.spc
Operation: Save TIC peaks to Multifile
Peak Spectra:
Subfile # Left Bsln Center Z Right Bsln
74 4.66900015 4.75843334 4.85790014
176 5.68198347 5.77180004 5.81143332
187 5.82154989 5.88114977 5.98111677
242 6.33855009 6.42843342 6.52845001
279 6.70749998 6.79773331 6.89788342
306 6.9770999 7.06698322 7.16693354
[END GC-MS]
[FILEINFO]
2000/09/12 12:45 W = Modified Date/Time (FILEINFO.AB) User=Brigitte
Version = 6.00
[END FILEINFO]history:2026-11-05 17:43:44+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPCData
title:Arbitrary Intensityvalues:...[[ 2491 2.89e+04 ... 1.123e+04 2132]]shape:(y:1, x:237)Dimension x
size:237title:m/zcoordinates:[ 38.05 39.05 ... 313.1 314.1] g⋅e⁻¹⋅mol⁻¹Dimension y
size:1title:Timecoordinates:[ 6.428] min3: NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPC] — float64, shape: (y:1, x:237)
name:/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPCauthor:docs@f885430b712dcreated:2026-11-05 17:43:44+00:00description:Dataset from spc file.
Memo: Multifile of Peak Mass Spectra from Drug Sample.spcFormat
Log Text:
---------
[FILEINFO]
1999/10/14 14:10 W = Modified Date/Time (FILEINFO.AB) User=brigitte
Version = 5.22
[END FILEINFO]
[GC-MS]
Version = 1.10
2000/09/12 12:44 I = Interpolated (GCMS.AB) User=Brigitte
2000/09/12 12:44 T = Truncated (GCMS.AB) User=Brigitte
Original File = drug sample.spc
Operation: Save TIC peaks to Multifile
Peak Spectra:
Subfile # Left Bsln Center Z Right Bsln
74 4.66900015 4.75843334 4.85790014
176 5.68198347 5.77180004 5.81143332
187 5.82154989 5.88114977 5.98111677
242 6.33855009 6.42843342 6.52845001
279 6.70749998 6.79773331 6.89788342
306 6.9770999 7.06698322 7.16693354
[END GC-MS]
[FILEINFO]
2000/09/12 12:45 W = Modified Date/Time (FILEINFO.AB) User=Brigitte
Version = 6.00
[END FILEINFO]history:2026-11-05 17:43:44+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPCData
title:Arbitrary Intensityvalues:...[[ 2096 3.101e+04 ... 5209 2257]]shape:(y:1, x:237)Dimension x
size:237title:m/zcoordinates:[ 38.05 39.05 ... 330.1 354.9] g⋅e⁻¹⋅mol⁻¹Dimension y
size:1title:Timecoordinates:[ 6.798] min4: NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPC] — float64, shape: (y:1, x:253)
name:/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPCauthor:docs@f885430b712dcreated:2026-11-05 17:43:44+00:00description:Dataset from spc file.
Memo: Multifile of Peak Mass Spectra from Drug Sample.spcFormat
Log Text:
---------
[FILEINFO]
1999/10/14 14:10 W = Modified Date/Time (FILEINFO.AB) User=brigitte
Version = 5.22
[END FILEINFO]
[GC-MS]
Version = 1.10
2000/09/12 12:44 I = Interpolated (GCMS.AB) User=Brigitte
2000/09/12 12:44 T = Truncated (GCMS.AB) User=Brigitte
Original File = drug sample.spc
Operation: Save TIC peaks to Multifile
Peak Spectra:
Subfile # Left Bsln Center Z Right Bsln
74 4.66900015 4.75843334 4.85790014
176 5.68198347 5.77180004 5.81143332
187 5.82154989 5.88114977 5.98111677
242 6.33855009 6.42843342 6.52845001
279 6.70749998 6.79773331 6.89788342
306 6.9770999 7.06698322 7.16693354
[END GC-MS]
[FILEINFO]
2000/09/12 12:45 W = Modified Date/Time (FILEINFO.AB) User=Brigitte
Version = 6.00
[END FILEINFO]history:2026-11-05 17:43:44+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPCData
title:Arbitrary Intensityvalues:...[[1.592e+04 3352 ... 2.961e+04 4199]]shape:(y:1, x:253)Dimension x
size:253title:m/zcoordinates:[ 39.05 40.05 ... 371.1 372.1] g⋅e⁻¹⋅mol⁻¹Dimension y
size:1title:Timecoordinates:[ 7.067] min5: NDDataset [/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPC] — float64, shape: (y:1, x:80)
name:/home/docs/.spectrochempy/testdata/galacticdata/DRUG_SAMPLE_PEAKS.SPCauthor:docs@f885430b712dcreated:2026-11-05 17:43:44+00:00description:Dataset from spc file.
Memo: Multifile of Peak Mass Spectra from Drug Sample.spcFormat
Log Text:
---------
[FILEINFO]
1999/10/14 14:10 W = Modified Date/Time (FILEINFO.AB) User=brigitte
Version = 5.22
[END FILEINFO]
[GC-MS]
Version = 1.10
2000/09/12 12:44 I = Interpolated (GCMS.AB) User=Brigitte
2000/09/12 12:44 T = Truncated (GCMS.AB) User=Brigitte
Original File = drug sample.spc
Operation: Save TIC peaks to Multifile
Peak Spectra:
Subfile # Left Bsln Center Z Right Bsln
74 4.66900015 4.75843334 4.85790014
176 5.68198347 5.77180004 5.81143332
187 5.82154989 5.88114977 5.98111677
242 6.33855009 6.42843342 6.52845001
279 6.70749998 6.79773331 6.89788342
306 6.9770999 7.06698322 7.16693354
[END GC-MS]
[FILEINFO]
2000/09/12 12:45 W = Modified Date/Time (FILEINFO.AB) User=Brigitte
Version = 6.00
[END FILEINFO]history:2026-11-05 17:43:44+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPCData
title:Arbitrary Intensityvalues:...[[ 9301 1.36e+04 ... 1.953e+04 1813]]shape:(y:1, x:80)Dimension x
size:80title:m/zcoordinates:[ 38.05 39.05 ... 196.1 196.9] g⋅e⁻¹⋅mol⁻¹Dimension y
size:1title:Timecoordinates:[ 4.758] min
Uncomment the following line to display all figures when running the script directly with Python.
# scp.show()
Total running time of the script: (0 minutes 0.777 seconds)