Skip to main content

GRAMS SPC file reader for Python

Project description

SPCfile - An SPC file reader in Python

A modern reader for GRAMS/Thermo-Galactic SPC files - a widely used file format in spectroscopy.

Installation

Requires Python >= 3.9 and NumPy. Install directly from this repository using pip:

pip install git+https://github.com/kogens/spcfile.git

Features

SPCfile focuses on a small, practical API for loading SPC files into NumPy arrays. It aims to make common spectroscopy workflows easy (load → inspect metadata → work with x/y arrays), while keeping the implementation straightforward and well-tested.

Supported SPC formats

Currently supported:

  • New-format SPC (512-byte header): 0x4B (little-endian, tested) and 0x4C (big-endian, supported but not currently tested due to lack of sample files)
  • X modes: implicit evenly-spaced X, explicit global X (TXVALS), and per-subfile X/Y (TXYXYS / "XYXY")
  • Multifile (TMULTI) and minimal 4D metadata: .z / .w expose per-subfile coordinates and .w_planes exposes the plane count
  • Log text block is read when present

Usage examples

from spcfile import SPCFile

# Load multifile with a shared X axis
spc = SPCFile("multifile.spc")
print(spc)
SPC File: multifile.spc
Date: 2021-03-15 09:21:00
Subfiles: 1
Points per subfile: 1776
Experiment type: General
Units: X='Wavenumber (cm^-1)', Y='Transmittance', Z='Arbitrary', W='Arbitrary'

Datapoints and coordinates are easily accessible as attributes of the SPCFile object:

# Access X, Y, Z values (represented as numpy arrays)
x = spc.x
y = spc.y
z = spc.z

# Subfiles can be indexed like a list
subfile0 = spc[0]
y0 = subfile0.y

Limitations

SPCfile currently rejects old-format 0x4D SPC files.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spcfile-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spcfile-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file spcfile-0.1.0.tar.gz.

File metadata

  • Download URL: spcfile-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spcfile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d72c22d9f1951f384e1990ea816f819553a08263ba5ec8fb4bb18e969f2e21b
MD5 9b016bcf875e507c64466b4050ab7387
BLAKE2b-256 5eed60e602c430d852f6ec436bce0a42ce4f1399812b39fc1954516c80cc3f09

See more details on using hashes here.

File details

Details for the file spcfile-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spcfile-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spcfile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e031facb7e242431722619e7f45289f376fe826c2aa4e8d3771731f05ed7c1bd
MD5 c8a61e8a5ab37af4cba77a93b08d87f4
BLAKE2b-256 ed65ca6a019e707289c477d44043d25cc54f668cbeec46398fdcfa31d7611611

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page