Skip to main content

Fast hyperspectral processing for remote sensing and machine learning

Project description

hyperspec

Crates.io PyPI License

Fast hyperspectral processing for remote sensing and machine learning. Rust core with Python bindings.

Built by Hyperstate — foundation models for Earth intelligence.

Why hyperspec?

Hyperspectral imagery produces hundreds of bands per pixel, orders of magnitude more than RGB or multispectral. Most existing tools are slow, have heavy system dependencies, and were not designed for modern ML training pipelines.

hyperspec provides:

  • Fast Rust implementations of standard hyperspectral algorithms
  • A SpectralCube abstraction that keeps data, wavelengths, and metadata together
  • Zarr V3 storage with chunking optimized for ML dataloaders
  • Python bindings with efficient NumPy interop

Install

Python:

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

Rust:

cargo add hyperspec

or

[dependencies]
hyperspec = "0.8"

Quickstart

from hyperspec import (
    read_envi, write_zarr, read_zarr_window,
    band_stats, covariance,
    mnf_denoise, savitzky_golay, derivative, continuum_removal, normalize_zscore,
    sam, ndvi, pca,
)

# --- I/O ---

cube = read_envi("scene.hdr")

# --- Exploration ---

stats = band_stats(cube)        # .mean, .std, .min, .max, .valid_count
cov = covariance(cube)          # (bands, bands) covariance matrix

# --- Preprocessing ---

clean = mnf_denoise(cube, n_components=20)  # denoise first
smooth = savitzky_golay(clean, window=7, polyorder=2)
d1 = derivative(smooth, order=1)
cr = continuum_removal(clean)
normed = normalize_zscore(clean)

# --- Analysis ---

reference = normed.spectrum(50, 50)
angles = sam(normed, reference)             # spectral similarity
veg = ndvi(normed, nir_band=90, red_band=55)  # vegetation index
pca_result = pca(normed, n_components=10)   # dimensionality reduction

# --- Storage ---

write_zarr(normed, "chips.zarr", chunk_shape=(normed.bands, 256, 256))
tile = read_zarr_window("chips.zarr", bands=(0, normed.bands), rows=(0, 256), cols=(0, 256))

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)

I/O

Read

Format Function
ENVI read_envi(path)
Zarr V3 read_zarr(path)
Zarr V3 read_zarr_with_options(path, ...)
Zarr V3 read_zarr_window(path, bands, rows, cols)
Zarr V3 zarr_cube_shape(path)

Write

Format Function
ENVI write_envi(cube, path)
Zarr V3 write_zarr(cube, path)

Algorithms

Exploration

Operation Function
Per-band stats band_stats(cube)BandStats
Covariance matrix covariance(cube)
Correlation matrix correlation(cube)

Preprocessing

Operation Function
MNF denoise mnf_denoise(cube, n_components)
MNF mnf(cube, n_components)
Savitzky-Golay smoothing savitzky_golay(cube, window, polyorder)
Derivative spectra derivative(cube, order)
Continuum removal continuum_removal(cube)
Min-max normalization normalize_minmax(cube)
Z-score normalization normalize_zscore(cube)
Resample resample(cube, target_wl, method)

Analysis

Operation Function
Spectral Angle Mapper sam(cube, reference)
Normalized difference normalized_difference(cube, a, b)
Band ratio band_ratio(cube, a, b)
NDVI ndvi(cube, nir_band, red_band)
PCA pca(cube, n_components)

Architecture

crates/hyperspec/           # Pure Rust library → crates.io
└── src/
    ├── cube.rs             # SpectralCube type
    ├── error.rs            # HyperspecError
    ├── io/
    │   ├── envi.rs         # ENVI read/write (BSQ, BIL, BIP)
    │   └── zarr.rs         # Zarr V3 read/write/window
    ├── linalg.rs           # Matrix ops (faer): eigen, covariance, tiled GEMM
    └── algorithms/
        ├── sam.rs
        ├── continuum.rs
        ├── indices.rs
        ├── pca.rs
        ├── mnf.rs
        ├── resample.rs
        ├── stats.rs
        ├── normalize.rs
        ├── derivative.rs
        └── smooth.rs

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

Roadmap

  • Cloud-native Zarr stores (Azure, GCS, S3)
  • More algorithms and utilities

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.8.0.tar.gz (81.4 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.8.0-cp313-cp313-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.13Windows x86-64

hyperspec_py-0.8.0-cp313-cp313-manylinux_2_39_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

hyperspec_py-0.8.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

hyperspec_py-0.8.0-cp313-cp313-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

hyperspec_py-0.8.0-cp313-cp313-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: hyperspec_py-0.8.0.tar.gz
  • Upload date:
  • Size: 81.4 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.8.0.tar.gz
Algorithm Hash digest
SHA256 707e34fb3e24a3df895e03e35c9e8db781f940e99c27787b8cc867698f0ca843
MD5 d1baacb9ed965d4e27739be7065e54cc
BLAKE2b-256 c695903aa80c8385b32413d497c2305b591802c48c60c1db116e8d8ca7d6cbcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.8.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.8.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.8.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8f310d33970449cf1abf1ab1471d448c9e517147d5e7ffbe912ca393343444ff
MD5 03d3c9f0747dc42b7c4b2e9fadbb8863
BLAKE2b-256 0fa94965342c7297d990d389b988631ef5c48ebd4c8f4982ae7e6917698be7e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.8.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.8.0-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.8.0-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 b9e3f72556ddb7d77e9888d67cb6728733bec50dcb0fb07a77745d065fd608d7
MD5 5712b7aeb14e3ab07b6dc15e2067e657
BLAKE2b-256 aa0e6190b3042b5b3c4141a4500e076003591391a1e58ce22c8c2403152d0197

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.8.0-cp313-cp313-manylinux_2_39_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.8.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.8.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c8c50aae3d9ca8eb15f1154d2b4acafd90b38a278981c3723428cd88983694b8
MD5 556eccd643673167d7986e59ff88e78f
BLAKE2b-256 522eaefe7f35e5ee349b0ad03343275d3d28fdcda8a4d87d6eaa27c3da99590c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.8.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.8.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce434658429fddb31e76a0384e16bc934b8986a5b09c23a3d89113935ff86a37
MD5 af62ae920cde09841aa48975f293b7fe
BLAKE2b-256 57a4773b4b5157de0055411048ebcc416fa68508ec9f6cbceae09f4f40ac083b

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.8.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.8.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for hyperspec_py-0.8.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 762a964ccb4fce0dc3add207d7fb0a40821edcbf043323f717715690bb31b29a
MD5 c68471945051bbd27df2d3a483866041
BLAKE2b-256 be6f2fcee5d5c966dcbe8c91a44224ad50303ef227357674a51c280c2ca4be3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for hyperspec_py-0.8.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