lib.vegetation¶
NDVI vegetation index computation and VNIR-based sunlight detection.
Vegetation index computation.
- lib.vegetation.compute_ndvi(red, nir)[source]¶
Compute Normalized Difference Vegetation Index from radiance.
NDVI = (NIR - Red) / (NIR + Red)
Works with radiance because the ratio cancels solar irradiance to first order (same sun angle, same atmospheric path).
- lib.vegetation.has_sunlight(red, nir, threshold=5.0)[source]¶
Check if VNIR bands have meaningful solar signal.
At night or under heavy cloud, reflected-solar bands (Red, NIR) read near zero. Checking actual radiance is more robust than Solar Zenith Angle because SZA only tells you if the sun is geometrically above the horizon — it can’t detect cloud blocking the signal.
- Empirical MASTER NIR radiance ranges:
Daytime: median ~40, min ~7 W/m²/sr/μm Nighttime: median ~0.2, p95 ~0.5 W/m²/sr/μm (sensor noise)
- Parameters:
- Returns:
True if the scene has usable solar illumination.
- Return type:
- lib.vegetation.detect_vegetation_loss(baseline, current, threshold=0.15)[source]¶
Detect significant vegetation loss by comparing NDVI to baseline.
A drop of >= threshold from the first-observed NDVI indicates that vegetation has been consumed (e.g. by fire). Uses absolute drop, not percentage, because a 0.15 drop is physically meaningful regardless of the baseline magnitude.
- Parameters:
- Returns:
Boolean mask, True where baseline - current >= threshold and both values are finite.
- Return type: