- Home
- Documentation
- API reference
- Core
- hyperproc.features
hyperproc.features¶
Source-derived reference
Generated from the current hyperproc 0.1.2 checkout.
Implementation: hyperproc/features.py. Signatures, defaults, docstrings, and expandable source are extracted statically; the module is not imported or executed. Names beginning with _ are implementation details, not a stable public API.
Use the function signature as the authority for individual parameter defaults and return annotations. Original docstrings sometimes group parameter names or wrap return descriptions across lines; these descriptions are preserved rather than inferred or rewritten.
Exported entry points¶
| Importable name | Definition |
|---|---|
hyperproc.features.band_at |
hyperproc.spectral.bands.band_at |
hyperproc.features.index |
hyperproc.features.index |
hyperproc.features.INDICES |
hyperproc.features.INDICES |
hyperproc.features.band_depth |
hyperproc.features.band_depth |
hyperproc.features.FEATURES |
hyperproc.features.FEATURES |
hyperproc.features.describe_indices |
hyperproc.features.describe_indices |
Spectral features: indices and absorption depths.
What separates these from :mod:hyperproc.spectral is what comes out. Those
transform a cube into a cube; these reduce each spectrum to one number per
pixel, so the result is a map.
Both halves address bands by wavelength, never by band number, which is what lets one call run unchanged on EMIT at 285 bands, PACE at 122 and AVIRIS at 425::
import hyperproc as hp
hp.spectral_index(ds, "NDVI") # a named index
hp.spectral_index(ds, "(R800 - R670) / (R800 + R670)") # or write your own
hp.band_depth(ds, "cellulose")
print(hp.describe_indices(ds)) # which indices this sensor can compute
Fit these on the unsmoothed cube: :func:hyperproc.smooth_spectra is
cosmetic and correlates neighbouring bands, which biases exactly the narrow
features measured here.
INDICES: dict[str, dict] = {'NDVI': {'formula': '(R860 - R660) / (R860 + R660)', 'name': 'normalised difference vegetation index', 'reference': 'Rouse et al. 1974'}, 'EVI': {'formula': '2.5 * (R860 - R660) / (R860 + 6*R660 - 7.5*R480 + 1)', 'name': 'enhanced vegetation index', 'reference': 'Huete et al. 2002'}, 'NDWI': {'formula': '(R860 - R1240) / (R860 + R1240)', 'name': 'normalised difference water index', 'reference': 'Gao 1996'}, 'NDII': {'formula': '(R820 - R1650) / (R820 + R1650)', 'name': 'normalised difference infrared index', 'reference': 'Hunt and Rock 1989'}, 'PRI': {'formula': '(R531 - R570) / (R531 + R570)', 'name': 'photochemical reflectance index', 'reference': 'Gamon et al. 1992'}, 'NDNI': {'formula': '(log(1/R1510) - log(1/R1680)) / (log(1/R1510) + log(1/R1680))', 'name': 'normalised difference nitrogen index', 'reference': 'Serrano et al. 2002'}, 'CAI': {'formula': '0.5 * (R2020 + R2220) - R2100', 'name': 'cellulose absorption index', 'reference': 'Nagler et al. 2003'}, 'MCARI': {'formula': '((R700 - R670) - 0.2 * (R700 - R550)) * (R700 / R670)', 'name': 'modified chlorophyll absorption ratio index', 'reference': 'Daughtry et al. 2000'}, 'ARI1': {'formula': '1/R550 - 1/R700', 'name': 'anthocyanin reflectance index', 'reference': 'Gitelson et al. 2001'}, 'CRI1': {'formula': '1/R510 - 1/R550', 'name': 'carotenoid reflectance index', 'reference': 'Gitelson et al. 2002'}, 'PSRI': {'formula': '(R680 - R500) / R750', 'name': 'plant senescence reflectance index', 'reference': 'Merzlyak et al. 1999'}, 'NDSI': {'formula': '(R550 - R1640) / (R550 + R1640)', 'name': 'normalised difference snow index', 'reference': 'Hall et al. 1995'}}
module-attribute
¶
FEATURES: dict[str, tuple] = {'chlorophyll': (550.0, 750.0), 'water_970': (900.0, 1050.0), 'water_1200': (1100.0, 1300.0), 'lignin_1730': (1650.0, 1850.0), 'cellulose': (2000.0, 2300.0), 'clay_2200': (2100.0, 2300.0)}
module-attribute
¶
_TOKEN = re.compile('\\bR(\\d+(?:\\.\\d+)?)\\b')
module-attribute
¶
_FUNCS = {'log': np.log, 'log10': np.log10, 'sqrt': np.sqrt, 'exp': np.exp, 'abs': np.abs}
module-attribute
¶
_evaluate(node, names: dict)
¶
Evaluate a whitelisted arithmetic AST. No attribute access, no calls but _FUNCS.
Source code in hyperproc/features.py
index(ds: xr.Dataset, formula: str, var: str | None = None, tolerance: float = TOLERANCE, good_only: bool = True, name: str | None = None) -> xr.DataArray
¶
Evaluate a spectral index written over wavelengths.
| PARAMETER | DESCRIPTION |
|---|---|
ds
|
dataset with a wavelength cube.
TYPE:
|
formula
|
a name from :data:
TYPE:
|
var
|
variable name; the main cube by default.
TYPE:
|
tolerance
|
how far each band may sit from its requested wavelength.
TYPE:
|
good_only
|
ignore bands flagged unusable.
TYPE:
|
name
|
name for the result; the index name or
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataArray
|
A lazy 2-D DataArray recording the formula and the wavelengths it |
DataArray
|
actually used in |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
the formula names no bands, uses something not allowed, or asks for a wavelength this sensor does not cover. |
Source code in hyperproc/features.py
describe_indices(ds: xr.Dataset | None = None, tolerance: float = TOLERANCE) -> str
¶
The named indices, and which ones a given sensor can actually compute.
Source code in hyperproc/features.py
_argmin_wavelength(a: np.ndarray, wl: np.ndarray) -> np.ndarray
¶
Wavelength of the smallest value in each spectrum, NaN where all are missing.
Source code in hyperproc/features.py
band_depth(ds: xr.Dataset, feature, var: str | None = None, good_only: bool = True) -> xr.Dataset
¶
Depth, position and area of an absorption feature.
The continuum is the upper hull fitted inside the feature window, so the depth is measured against the shoulders rather than against an absolute reflectance, which is what makes it comparable between scenes.
| PARAMETER | DESCRIPTION |
|---|---|
ds
|
dataset with a wavelength cube.
TYPE:
|
feature
|
a name from :data:
|
var
|
variable name; the main cube by default.
TYPE:
|
good_only
|
fit only within runs of usable bands.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dataset
|
A Dataset with |
Dataset
|
spectrum), |
Dataset
|
(integral of 1 - CR over the window, nm). |