Skip to main content

Fast processing library for hyperspectral imagery, written in Rust

Project description

hyperspec

Crates.io PyPI License

Fast processing library for hyperspectral imagery. Rust core, Python bindings.

Built by Hyperstate — foundation models for Earth intelligence.

Install

Python:

pip install hyperspec-py
# or
uv add hyperspec-py

Rust:

cargo add hyperspec

or

[dependencies]
hyperspec = "0.5"

Quickstart

import numpy as np
from hyperspec import SpectralCube, sam, continuum_removal, pca, mnf_denoise

# Create a cube (bands, height, width) with wavelengths in nanometers
data = np.random.rand(200, 100, 100)
wavelengths = np.linspace(400, 2500, 200)

cube = SpectralCube(data, wavelengths)

# --- Spectral analysis ---

# Compare every pixel to a reference spectrum
reference = cube.spectrum(50, 50)
angles = sam(cube, reference)

# Isolate absorption features
cr_cube = continuum_removal(cube)

# Denoise using Minimum Noise Fraction
denoised_cube = mnf_denoise(cube, n_components=20)

# --- Dimensionality reduction ---

# Reduce spectral dimensionality
pca_result = pca(cube, n_components=10)

SpectralCube

Category Methods
Dimensions bands, height, width, shape
Data access data(), wavelengths(), fwhm(), nodata
Pixel access spectrum(row, col)
Band access band(index), band_at(nm), band_nearest(nm)
Wavelength lookup wavelength(index), wavelength_index(nm), nearest_band_index(nm)
Statistics mean_spectrum()
Subsetting sel_bands([i, j]), sel_wavelengths(min, max)

Algorithms

Spectral similarity

Operation Function
Spectral Angle Mapper sam(cube, reference)

Spectral preprocessing

Operation Function
Continuum removal continuum_removal(cube)

Spectral indices

Operation Function
Normalized difference normalized_difference(cube, a, b)
Band ratio band_ratio(cube, a, b)
NDVI ndvi(cube, nir, red)

Dimensionality reduction

Operation Function
PCA pca(cube, n_components)
MNF mnf(cube, n_components)
MNF denoise mnf_denoise(cube, n_components)

Spectral utilities

Operation Function
Resample resample(cube, target_wl, method)

Architecture

crates/hyperspec/           # Pure Rust library → crates.io
└── src/
    ├── cube.rs             # SpectralCube type
    ├── error.rs            # HyperspecError
    └── algorithms/
        ├── sam.rs
        ├── continuum.rs
        ├── indices.rs
        ├── pca.rs
        ├── mnf.rs
        └── resample.rs

pyo3-hyperspec/             # PyO3 bindings → PyPI: hyperspec-py
├── src/lib.rs
└── python/hyperspec/
    └── __init__.py
  • Rust 2024 edition, using ndarray, rayon, thiserror
  • Zero system dependencies — no LAPACK, GDAL, or numba
  • Python 3.12+, NumPy bindings via PyO3

Development

uv venv && source .venv/bin/activate
uv pip install maturin pytest
cargo test
maturin develop
pytest

License

Apache-2.0

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

hyperspec_py-0.5.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distributions

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

hyperspec_py-0.5.0-cp313-cp313-win_amd64.whl (339.0 kB view details)

Uploaded CPython 3.13Windows x86-64

hyperspec_py-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl (508.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

hyperspec_py-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (414.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

hyperspec_py-0.5.0-cp313-cp313-macosx_11_0_arm64.whl (438.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

hyperspec_py-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl (464.2 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

Details for the file hyperspec_py-0.5.0.tar.gz.

File metadata

  • Download URL: hyperspec_py-0.5.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hyperspec_py-0.5.0.tar.gz
Algorithm Hash digest
SHA256 47a55feb706059853981c7d55da933230bf35e0fecb3cec5313d99f89e761749
MD5 4526c1762148cadf489d4a9a33f6c175
BLAKE2b-256 91aedd1eecfeca2b4492fc91c059a6baae1a2faccd7aa715171a21b57afb0ed5

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.5.0.tar.gz:

Publisher: publish.yml on hyperstateco/hyperspec

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

File details

Details for the file hyperspec_py-0.5.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bca4c9482a8b44582fc871dff1aca5e1d8ae26059c85309c9161e65bae20138e
MD5 556598c70518099b33db233d17fac39b
BLAKE2b-256 96c5260dd1513a868a6063dc292ab26d44159294634c3a2e732137386c8f44c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.5.0-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on hyperstateco/hyperspec

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

File details

Details for the file hyperspec_py-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5fad61c8e9353a8dd66d4bb60d5038638cc66d37574afcaf1210c9b1983fb3b1
MD5 ec04017cd7d684c466d85d88d8b2a095
BLAKE2b-256 7a82519b179cfceafda0b85f91719846f6607bc0ffc37114e5034ca76b4acca1

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on hyperstateco/hyperspec

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

File details

Details for the file hyperspec_py-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ff2e4b2250c2619836139d5d401cdc74193d7c8969f2050aefba27b8d238e8f0
MD5 959ec238e9d6284548df3e065903b39c
BLAKE2b-256 4c298ea65a47ac87fa1478c1a6691276ff56c1723e11c0a0859fc7ced370792d

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on hyperstateco/hyperspec

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

File details

Details for the file hyperspec_py-0.5.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6cb8822e6c68e974617b895c395f76de9f22e463674e064a47a5c3891308cf1b
MD5 f4e72ade21cf511baf7d2d7a8bf22a8b
BLAKE2b-256 be2fa1d2e6311595ff1476f8e021b6cc79fe7b068ce88b7704dcbba05fa53b94

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.5.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on hyperstateco/hyperspec

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

File details

Details for the file hyperspec_py-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5e2a1c88103d0dc07280fcfa08c681b5bb04d532639ac31e25aefd3fe54f8062
MD5 92af3d1a82aad9d3eb4a349593e35cb8
BLAKE2b-256 34cb161a9dc7cb05693f7619fe3ed8a521db704cb7deb4c4941be78e78b2d5d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.5.0-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: publish.yml on hyperstateco/hyperspec

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