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
ofrealnumber Two-dimensional spectral data array.
- band
int Band index used for quantile computation.
- bins
intor array_likeofrealnumber Number of quantile bins to compute, or an explicit sequence of quantile levels.
Quantile levels must be within the range of [0, 1].
- axis
int,optional Axis along which the computation is performed.
0: treat each array row as a sample1: treat each array column as a sample
Default is
0.
- spec_array_2darray_like
- Returns:
- Return type:
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)