Skip to main content

Spectrum Data Loader

A simple and robust library for easy loading 2-column (X, Y) spectrum data from text files (.txt). The resulting data can be analyzed as DataFrame for direct plotting, or loaded as two lists for mathematical treatments and post-visualization, or plot method for other visualization modes such as Manim (as demonstrated in the examples).

The output is ready for immediate use with libraries like NumPy, Pandas, and Matplotlib for scientific analysis and visualization.

Key Features

  • Simple Interface: Load any supported spectrum with a single function call: load_xy_data().
  • Versatile: Auto-detects common delimiters like spaces, tabs, and commas.
  • Format Support: Works with standard text-based formats (.txt, .csv, .dat) and the JCAMP-DX (.jdx) format.
  • Seamless Integration: Returns data as two clean NumPy arrays, perfect for the scientific Python ecosystem (SciPy, Pandas, Matplotlib).

Installation

pip install spectrum-data-loader

Quickstart

Here is a minimal example of how to load and plot a spectrum from a text file.

import spectrum_data_loader as sdl
import matplotlib.pyplot as plt

try:
    # Load the data using the library
    wavelength, absorbance = sdl.load_xy_data('my_spectrum.txt')

    # Print a confirmation
    print(f"Successfully loaded {len(wavelength)} data points.")

    # Create a simple plot with Matplotlib
    plt.figure(figsize=(8, 5))
    plt.plot(wavelength, absorbance, label='My Spectrum')
    plt.xlabel("Wavelength (nm)")
    plt.ylabel("Absorbance (a.u.)")
    plt.title("Spectrum Data")
    plt.grid(True)
    plt.legend()
    plt.show()

except FileNotFoundError:
    print("Error: The file 'my_spectrum.txt' was not found.")
except Exception as e:
    print(f"An error occurred: {e}")

Examples

For more advanced use cases, please see the code in the /examples directory of this repository.

Release files for spectrum-data-loader 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spectrum-data-loader 0.1.3
File Size Uploaded
spectrum_data_loader-0.1.3.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spectrum-data-loader 0.1.3
File Interpreter ABI Platform
spectrum_data_loader-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.0 kB

Release files / spectrum_data_loader-0.1.3.tar.gz

Download URL spectrum_data_loader-0.1.3.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1914b12b6afc5d1b8dcb39fbb26d453e1d89b536634d737b2255c5eeeb0fb202
BLAKE2b-256 checksum
How to use checksums
5407badd636a50b9b65ba5a35e604b673a5e4c087b0f4ddff5c3c971ff64e65a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / spectrum_data_loader-0.1.3-py3-none-any.whl

Download URL spectrum_data_loader-0.1.3-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51688ba1215e6dd77902a32d1aa5da9481214748279485fa26e3d9be12a2e9bd
BLAKE2b-256 checksum
How to use checksums
35a5a4d40c03a6d1efc530b4425bc9dbc001dd9187bed246f5cad32123f737ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page