swectral.bandquant#

swectral.bandquant(spec_array_2d, band, bins, axis=0)[source]#

Compute quantile values of a specified spectral band from a 2D array-like spectral dataset.

Quantiles may be specified either by the number of bins or by an explicit sequence of quantile levels.

Parameters:
spec_array_2darray_like of real number

Two-dimensional spectral data array.

bandint

Band index used for quantile computation.

binsint or array_like of real number

Number of quantile bins to compute, or an explicit sequence of quantile levels.

Quantile levels must be within the range of [0, 1].

axisint, optional

Axis along which the computation is performed.

  • 0 : treat each array row as a sample

  • 1 : treat each array column as a sample

Default is 0.

Returns:
tuple of float

Quantile values of the specified band at the given bins or quantile levels.

Return type:

tuple[float, ...]

Examples

Basic usage with a fixed number of bins:

>>> import numpy as np
>>> x = np.random.randint(0, 10000, size=(100, 100))

>>> bandquant(x, band=1, bins=10)

Use explicit quantile levels:

>>> bandquant(x, band=1, bins=[500, 1000, 1500, 2000, 2500, 3000])

Compute along a different axis:

>>> bandquant(x, band=1, bins=10, axis=1)