Metadata-Version: 2.4
Name: spectrum-data-loader
Version: 0.1.3
Summary: A library to easily load spectral data from text files.
Author-email: David Ibarra <david.ibarral0798@gmail.com>
Project-URL: Homepage, https://github.com/davidil98/spectrum-data-loader.git
Keywords: spectroscopy,data-loader,uv-vis,ftir,chemistry,physics,scientific-data
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENCE.txt
Requires-Dist: pandas
Dynamic: license-file

# 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

```bash
pip install spectrum-data-loader
```

## Quickstart

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

```python
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.
