Python bindings for the Rust-first nirs4all-formats NIRS loader.
Project description
nirs4all-formats (Python)
Python bindings for nirs4all-formats,
the Rust-first low-level reader for NIRS and spectroscopy file formats. It reads
~58 format families, auto-detecting each file by content, and projects the
canonical records into numpy / pandas / polars / sklearn / torch / xarray or a
nirs4all SpectroDataset.
Parsers live entirely in the Rust core — this package is a thin, lossless surface over it.
Install
pip install nirs4all-formats # Python 3.10+
pip install "nirs4all-formats[numpy,pandas,sklearn,torch]" # projection extras
to_polars() needs polars, to_xarray() needs xarray, and
to_spectrodataset() needs nirs4all.
Quick start
import nirs4all_formats as nio
# Probe: which reader will handle this file, and why?
nio.probe_path("spectrum.jdx")
# Lossless object model — every signal, axis, coord, metadata and provenance
rs = nio.open_recordset("spectrum.sed")
rs.signal_names()
# Modelling-ready projections (explicit; may be lossy)
X, axis = rs.to_numpy(signal="reflectance") # (X[n_samples, n_features], axis)
df = rs.to_pandas() # wide: metadata + x_<axis> columns
bunch = rs.to_sklearn(signal="reflectance", target="protein")
API at a glance
Raw access (records exactly as the Rust core emits them, as dicts):
open_records, open_bytes, open_with_sidecars, probe_path, walk_path.
Object model: open_recordset(path) -> SpectralRecordSet with dataclasses
SpectralRecord, SpectralArray, SpectralAxis, SourceFile, Provenance.
Projections on SpectralRecordSet: to_numpy, to_pandas,
to_pandas_long, to_polars, to_sklearn, to_torch, to_spectrodataset;
SpectralArray.to_xarray() for N-dimensional signals (cubes, maps, series).
Image-cube readers accept pixel selection: rows=/cols= (rectangular ROI),
pixels=[(r, c), …] (sparse), or single_record=True to keep the spatial grid.
A native PyO3 extension (nirs4all_formats._native) is used when present; otherwise
the bridge falls back to the nirs4all-formats CLI (NIRS4ALL_FORMATS_CLI can point to a
prebuilt binary).
Documentation
Full reference: https://github.com/GBeurier/nirs4all-formats/blob/main/docs/bindings/python.md. The usage guide, supported-format catalogue and data model live in the project docs.
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nirs4all_formats-0.1.0.tar.gz.
File metadata
- Download URL: nirs4all_formats-0.1.0.tar.gz
- Upload date:
- Size: 656.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16af17fa391e286afe159c1ff6095590f31491e04c7b2f06878242188fba22c8
|
|
| MD5 |
297625786eda8f45aba989791313ce34
|
|
| BLAKE2b-256 |
c3b0859b0a53052d36d1b3d4cb5f6984881b3d7c61ad00f205de4c3324858867
|
Provenance
The following attestation bundles were made for nirs4all_formats-0.1.0.tar.gz:
Publisher:
release.yml on GBeurier/nirs4all-formats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nirs4all_formats-0.1.0.tar.gz -
Subject digest:
16af17fa391e286afe159c1ff6095590f31491e04c7b2f06878242188fba22c8 - Sigstore transparency entry: 1790882600
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-formats@211017cefc79d93eba6780d06ba61174875ae460 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@211017cefc79d93eba6780d06ba61174875ae460 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nirs4all_formats-0.1.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: nirs4all_formats-0.1.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eefd11e26c5613b95d4c32d8d40060e7e8e50d16445d62b9c98c46647992c735
|
|
| MD5 |
f70e66f95ca7e6ca0ce9b91e5ee2173b
|
|
| BLAKE2b-256 |
c29ae18464157066d390f6909bb397d8c19882c0a7acc1eff3ad2cba8d53831f
|
Provenance
The following attestation bundles were made for nirs4all_formats-0.1.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on GBeurier/nirs4all-formats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nirs4all_formats-0.1.0-cp310-abi3-win_amd64.whl -
Subject digest:
eefd11e26c5613b95d4c32d8d40060e7e8e50d16445d62b9c98c46647992c735 - Sigstore transparency entry: 1790882616
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-formats@211017cefc79d93eba6780d06ba61174875ae460 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@211017cefc79d93eba6780d06ba61174875ae460 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nirs4all_formats-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: nirs4all_formats-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 4.8 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d79b4dc3d85e4e96372cc02ddd079c010b2508c93860a3cee0b284d2bea53aea
|
|
| MD5 |
2b672ddf0637d4dd8f2edbf9d8f30f3c
|
|
| BLAKE2b-256 |
c3cb131e5f78632eb0def4dfe003455a7f9f3af66c09bc46a044a21b8b4a3e22
|
Provenance
The following attestation bundles were made for nirs4all_formats-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:
Publisher:
release.yml on GBeurier/nirs4all-formats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nirs4all_formats-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
d79b4dc3d85e4e96372cc02ddd079c010b2508c93860a3cee0b284d2bea53aea - Sigstore transparency entry: 1790882630
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-formats@211017cefc79d93eba6780d06ba61174875ae460 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@211017cefc79d93eba6780d06ba61174875ae460 -
Trigger Event:
push
-
Statement type: