Skip to main content

A Comprehensive Python Package for Near-Infrared Spectroscopy (NIR).

Project description

PioNIR

PioNIR is a Python library designed for the processing and analysis of near-infrared (NIR) spectra. It offers a suite of chemometric tools for preprocessing, modeling, and evaluation, facilitating the development of spectroscopy workflows. The library tightly integrates with the scientific Python ecosystem, with NumPy, SciPy, and scikit-learn.

Installation

The latest release is available on PyPI and can be installed via pip.

pip install pionir

For development purposes, use uv to manage the installation.

uv sync --dev

The project uses ruff for linting and formatting, ty for type checking, and pytest for testing.

uvx ruff check src
uvx ty check src
uv run pytest

Features

Data Representation

PioNIR provides specialized Spectrum and SpectrumCollection classes to handle NIR spectra. These classes serve as the foundation for handling individual measurements and larger datasets within the library.

from pionir import Spectrum, SpectrumCollection, Metadata

# x, y: NumPy ndarrays
s = Spectrum(x=..., y=..., metadata=...)  # Single spectrum
c = SpectrumCollection([s])  # Collection of spectra

Unified Interface with Single Dispatch

PioNIR uses a single dispatch approach, allowing the same function interface to handle both individual Spectrum objects and SpectrumCollection instances as well as plain NumPy ndarray.

from pionir import Spectrum, SpectrumCollection
from pionir.scatter import snv

s = Spectrum(...)
c = SpectrumCollection(...)

# The same function handles both single spectra and collections
s_snv = snv(s)
c_snv = snv(c)

scikit-learn Integration

The library is designed for compatibility with scikit-learn, providing transformers that can be directly incorporated into pipelines.

from sklearn.decomposition import PCA
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import Pipeline

from pionir import SpectrumCollection
from pionir.sklearn.transformer import SNVTransformer

c = SpectrumCollection([...])

pcr_pipeline = Pipeline([
    ("snv", SNVTransformer()),
    ("pca", PCA(n_components=5)),
    ("regression", LinearRegression())
])

pcr_pipeline.fit(c.y, ...)
pcr_pipeline.predict(...)

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

pionir-0.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

pionir-0.1.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pionir-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pionir-0.1.0.tar.gz
Algorithm Hash digest
SHA256 001627f8cb3b06a695ac5f7884649524861a9bc081a580e2c4d4184ae9931510
MD5 836ed150dac6aca7d8e85c1d19e27853
BLAKE2b-256 29c5dca7f80a4eb0113266bc70693ca45693f79e52d53b5762b8b03b2972955a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pionir-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pionir-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 809777fc62c77d94082607e775f787b1ab34321c9d1b7d9187c8ae57d2c8b180
MD5 337e179a938832a680574fa9947fbf64
BLAKE2b-256 50ae59ba8c49c4f391a17de659ebf6f0bdf507db114bcebe2f050f7488ff5916

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