Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nirs4all_formats-0.2.6.tar.gz (733.2 kB view details)

Uploaded Source

Built Distributions

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

nirs4all_formats-0.2.6-cp310-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

nirs4all_formats-0.2.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

File details

Details for the file nirs4all_formats-0.2.6.tar.gz.

File metadata

  • Download URL: nirs4all_formats-0.2.6.tar.gz
  • Upload date:
  • Size: 733.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for nirs4all_formats-0.2.6.tar.gz
Algorithm Hash digest
SHA256 8f042ccc7eab95813d514518767e47344621938c622984afb6dcbba155e21b9c
MD5 72699b36341702608f668ddcd4a642f3
BLAKE2b-256 416070f3b16b5779da77869724426d69ba943c05f245d3629a44383e85bdd765

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_formats-0.2.6.tar.gz:

Publisher: release.yml on GBeurier/nirs4all-formats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nirs4all_formats-0.2.6-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for nirs4all_formats-0.2.6-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f1e1eedf5b441c9220a7892a0abaa07b7b887d86596b0996e4973a908e38b309
MD5 e523c8d4cadfc69104209703d91a17fa
BLAKE2b-256 6d891fa527f6a422f39b317036b1a727091933590cf6f307b78421da7b2f7950

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_formats-0.2.6-cp310-abi3-win_amd64.whl:

Publisher: release.yml on GBeurier/nirs4all-formats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nirs4all_formats-0.2.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for nirs4all_formats-0.2.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 084b81890c4a0e481dddfaff80e91b3f76f3ad7cf43270363779ea45e1fdb986
MD5 852905e2038a9c71a68633496be1a429
BLAKE2b-256 bf3e31682458eeb7a489c2471c867c70be289d97286fad4831d10150e9836855

See more details on using hashes here.

Provenance

The following attestation bundles were made for nirs4all_formats-0.2.6-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: release.yml on GBeurier/nirs4all-formats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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