Skip to main content

A library to easily load spectral data from text files.

Project description

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.

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

spectrum_data_loader-0.1.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

spectrum_data_loader-0.1.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file spectrum_data_loader-0.1.3.tar.gz.

File metadata

  • Download URL: spectrum_data_loader-0.1.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for spectrum_data_loader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1914b12b6afc5d1b8dcb39fbb26d453e1d89b536634d737b2255c5eeeb0fb202
MD5 934c836c1e970b1221e415f6bfa99e7d
BLAKE2b-256 5407badd636a50b9b65ba5a35e604b673a5e4c087b0f4ddff5c3c971ff64e65a

See more details on using hashes here.

File details

Details for the file spectrum_data_loader-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for spectrum_data_loader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 51688ba1215e6dd77902a32d1aa5da9481214748279485fa26e3d9be12a2e9bd
MD5 a0d23761bf15ae0e388195e5d449576e
BLAKE2b-256 35a5a4d40c03a6d1efc530b4425bc9dbc001dd9187bed246f5cad32123f737ae

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