s2-for-algal-bloom: chlorophyll-a regression from Sentinel-2
Neural network (residual blocks with multi-head attention, residual_mha_dnn, width 128) that
estimates chlorophyll-a concentration (µg/L) in lakes and ponds from 14 Sentinel-2 MSI
surface-reflectance features. It was developed for algal bloom identification in the Baltic
states.
- Paper: Grendaitė, D., Petkevičius, L. Identification of algal blooms in lakes in the Baltic states using Sentinel-2 data and artificial neural networks. IEEE Access 12 (2024): 27973–27988.
- Code and data: https://github.com/dfrgttn/s2-for-algal-bloom
Files
| Path | Content |
|---|---|
model/ | Keras SavedModel (architecture + weights) |
predict.py | feature computation, model loading, CLI and predict() function |
data/test_reg_data.csv | held-out test set (437 samples from lakes not used for training): 14 features + chla_ug_L |
tests/test_model.py | unit tests |
requirements.txt | dependencies |
Input and output
Input: Sentinel-2 L2A surface reflectance scaled to 0–1 (DN / 10000) for bands
B2, B3, B4, B5, B6, B7, B8A. predict.py derives the other seven inputs:
B5_B4 = B5/B4 B3_B2 = B3/B2 B3_B4 = B3/B4 B3_B5 = B3/B5
B4_B5_B6 = B5 - (B4 + B6)/2
avw = (B2 + B3 + B4) / (B2/490 + B3/560 + B4/665)
diff_alg = 2054 * (B5 - 1.05*B4) + 17
Output: chlorophyll-a in µg/L, negative values clipped to 0.
Usage
The SavedModel is in Keras 2 format; use TensorFlow ≤ 2.15 with keras-multi-head.
pip install -r requirements.txt
python predict.py data/test_reg_data.csv predictions.csv
import pandas as pd
from predict import predict
df = pd.read_csv("data/test_reg_data.csv") # or a table with columns B2,B3,B4,B5,B6,B7,B8A
df["chla_pred"] = predict(df)
Rows with NaN/inf (e.g. zero reflectance in a band) are rejected; drop them first.
Tests
pytest -q
Checks feature computation against the test set, output shape/finiteness/non-negativity, determinism, batch-size and row-order invariance, error handling, and that the test-set Huber loss (δ = 10) matches the value recorded at training time (48.48, ±0.5).
Training and limitations
- Trained with Adam (lr 0.01), Huber loss (δ = 10) and early stopping on the test split; the train/test split is by lake (70/30, seed 123). Test results are therefore optimistic.
- Trained on lakes and ponds of the Baltic states; transfer to other regions, water types or atmospheric-correction products is untested.
- Inputs must be surface reflectance (Sentinel-2 L2A) processed as in the repository's GEE notebook.
Citation
@article{grendaite2024identification,
title={Identification of algal blooms in lakes in the Baltic states using Sentinel-2 data and artificial neural networks},
author={Grendait{\.e}, Dalia and Petkevi{\v{c}}ius, Linas},
journal={IEEE Access},
volume={12},
pages={27973--27988},
year={2024},
publisher={IEEE}
}