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
plot read spc
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@891f0bf83b67
created
:
2026-10-05 02:20:10+00:00
description
:
Dataset from spc file.
Memo: FT-IR Spectrum of Benzene, Capillary Film.
history
:
2026-10-05 02:20:10+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
plot read spc
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@891f0bf83b67
created
:
2026-10-05 02:20:11+00:00
description
:
Dataset from spc file.
Memo: Subfiles are the Same Portion of POLYS Multiplied by a Sine Wave.
history
:
2026-10-05 02:20:11+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.
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:

ex3 = scp.read_spc("galacticdata/DRUG_SAMPLE_PEAKS.SPC")
for nd in ex3:
    _ = nd.plot_bar(width=0.1, clear=False)
ex3
plot read spc
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.SPC
    author
    :
    docs@891f0bf83b67
    created
    :
    2026-10-05 02:20:11+00:00
    description
    :
    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-10-05 02:20:11+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPC
    Data
    title
    :
    Arbitrary Intensity
    values
    :
    ...
    [[ 2803 1.723e+04 ... 7720 1930]]
    shape
    :
    (y:1, x:124)
    Dimension x
    size
    :
    124
    title
    :
    m/z
    coordinates
    :
    [ 37.85 39.05 ... 305.1 354.9] g⋅e⁻¹⋅mol⁻¹
    Dimension y
    size
    :
    1
    title
    :
    Time
    coordinates
    :
    [ 5.881] min
  • 1: 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.SPC
    author
    :
    docs@891f0bf83b67
    created
    :
    2026-10-05 02:20:11+00:00
    description
    :
    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-10-05 02:20:11+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPC
    Data
    title
    :
    Arbitrary Intensity
    values
    :
    ...
    [[ 6180 1823 ... 5930 2219]]
    shape
    :
    (y:1, x:141)
    Dimension x
    size
    :
    141
    title
    :
    m/z
    coordinates
    :
    [ 39.05 39.95 ... 355 355.9] g⋅e⁻¹⋅mol⁻¹
    Dimension y
    size
    :
    1
    title
    :
    Time
    coordinates
    :
    [ 5.772] min
  • 2: 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.SPC
    author
    :
    docs@891f0bf83b67
    created
    :
    2026-10-05 02:20:11+00:00
    description
    :
    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-10-05 02:20:11+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPC
    Data
    title
    :
    Arbitrary Intensity
    values
    :
    ...
    [[ 2491 2.89e+04 ... 1.123e+04 2132]]
    shape
    :
    (y:1, x:237)
    Dimension x
    size
    :
    237
    title
    :
    m/z
    coordinates
    :
    [ 38.05 39.05 ... 313.1 314.1] g⋅e⁻¹⋅mol⁻¹
    Dimension y
    size
    :
    1
    title
    :
    Time
    coordinates
    :
    [ 6.428] min
  • 3: 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.SPC
    author
    :
    docs@891f0bf83b67
    created
    :
    2026-10-05 02:20:11+00:00
    description
    :
    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-10-05 02:20:11+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPC
    Data
    title
    :
    Arbitrary Intensity
    values
    :
    ...
    [[ 2096 3.101e+04 ... 5209 2257]]
    shape
    :
    (y:1, x:237)
    Dimension x
    size
    :
    237
    title
    :
    m/z
    coordinates
    :
    [ 38.05 39.05 ... 330.1 354.9] g⋅e⁻¹⋅mol⁻¹
    Dimension y
    size
    :
    1
    title
    :
    Time
    coordinates
    :
    [ 6.798] min
  • 4: 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.SPC
    author
    :
    docs@891f0bf83b67
    created
    :
    2026-10-05 02:20:11+00:00
    description
    :
    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-10-05 02:20:11+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPC
    Data
    title
    :
    Arbitrary Intensity
    values
    :
    ...
    [[1.592e+04 3352 ... 2.961e+04 4199]]
    shape
    :
    (y:1, x:253)
    Dimension x
    size
    :
    253
    title
    :
    m/z
    coordinates
    :
    [ 39.05 40.05 ... 371.1 372.1] g⋅e⁻¹⋅mol⁻¹
    Dimension y
    size
    :
    1
    title
    :
    Time
    coordinates
    :
    [ 7.067] min
  • 5: 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.SPC
    author
    :
    docs@891f0bf83b67
    created
    :
    2026-10-05 02:20:11+00:00
    description
    :
    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-10-05 02:20:11+00:00> Imported Galactic SPC file DRUG_SAMPLE_PEAKS.SPC
    Data
    title
    :
    Arbitrary Intensity
    values
    :
    ...
    [[ 9301 1.36e+04 ... 1.953e+04 1813]]
    shape
    :
    (y:1, x:80)
    Dimension x
    size
    :
    80
    title
    :
    m/z
    coordinates
    :
    [ 38.05 39.05 ... 196.1 196.9] g⋅e⁻¹⋅mol⁻¹
    Dimension y
    size
    :
    1
    title
    :
    Time
    coordinates
    :
    [ 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.926 seconds)