How to open a Galactic SPC file (.spc) online, without GRAMS
SPC is the binary spectrum format of Galactic's GRAMS software, now part of Thermo Fisher. Many IR, Raman, NIR and UV-Vis instruments and converters still write it, but without GRAMS or a converter it is hard to open.
What is inside an SPC file
In the current format, an SPC file starts with a 512-byte header (the axis types, the number of points, the date, a comment), followed by one or more subfiles, each holding one spectrum. Some files end with a text log of instrument settings.
- One spectrum or many. A file can hold a single spectrum, or a series: a kinetics run, spectra at several temperatures, a map, or one mass spectrum per GC-MS scan. Each subfile has its own position on that series axis, such as a time or a retention time.
- How x is stored. Either evenly spaced from a first to a last value, as one x array shared by all spectra, or as a separate x array per spectrum (peak lists such as mass spectra).
- How y is stored. As 32-bit floating point numbers, or as 16-bit or 32-bit integers scaled by a power of two. The integer forms are why opening an SPC file in a hex editor or a naive script gives nonsense.
- Old and new format. Files from Spectra Calc and Lab Calc use an older header layout. The second byte of the file tells them apart.
Not every .spc file is Galactic SPC: Shimadzu UVProbe also saves .spc, in a different, unrelated format.
In your browser
- Open Nagura Lab and drop one or more
.spcfiles on the page, or use Open data and pick Files. - The spectrum is plotted on the axis it was recorded on: IR with high wavenumbers on the left, Raman shift, wavelength in nm, or m/z. Mass spectra stored as peak lists are drawn as sticks.
- A file with many spectra lists each one separately, named after its position, for example
#2 · Time 30 s. The first is plotted; tick others to overlay up to eight. - Download CSV gives the plotted spectra in columns, with a header such as
Wavelength (nm); Download PNG gives the figure.
Chromatograms saved as SPC (often with the .cgm extension) open as chromatograms, with time in minutes. Both the new and the old format are read, with every x and y storage form described above. The file is decoded on your computer and never uploaded.
Not supported: Shimadzu UVProbe .spc files (they are recognized and refused with a message) and the rare big-endian variant of SPC.
In Python
The open-source spc-io package (MIT) reads SPC files:
import csv
from spc_io import SPC
with open("spectrum.spc", "rb") as f:
spc = SPC.from_bytes_io(f)
print(len(spc)) # number of spectra in the file
sub = spc[0]
with open("spectrum.csv", "w", newline="") as f:
csv.writer(f).writerows(zip(sub.xarray, sub.yarray))
For files with many spectra, loop over spc to get each one.