Atmospheric Correction¶
Main module for atmospheric correction using the Dark Spectrum Fitting (DSF) method from ACOLITE.
Overview¶
The gee_acolite.correction module implements the ACOLITE atmospheric correction optimized for Google Earth Engine. It uses the Dark Spectrum Fitting (DSF) method to estimate aerosol optical thickness (AOT) and correct atmospheric effects in Sentinel-2 images.
Correction Flow¶
ACOLITE Class¶
ACOLITE
¶
Bases: object
ACOLITE atmospheric correction for Google Earth Engine.
This class implements the ACOLITE Dark Spectrum Fitting (DSF) atmospheric correction method optimized for Google Earth Engine with Sentinel-2 imagery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
acolite
|
ModuleType
|
ACOLITE module imported from the ACOLITE package. |
required |
settings
|
str or dict
|
Path to settings file or dictionary with processing settings. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
acolite |
ModuleType
|
Reference to ACOLITE module. |
settings |
dict
|
Parsed processing settings. |
Examples:
>>> import acolite as ac
>>> from gee_acolite import ACOLITE
>>> ac_gee = ACOLITE(ac, 'config/settings.txt')
>>> corrected_images, settings = ac_gee.correct(image_collection)
Source code in gee_acolite/correction.py
correct
¶
Apply atmospheric correction to image collection.
Main entry point for atmospheric correction processing. Converts L1C top-of-atmosphere (TOA) reflectance to surface reflectance using the ACOLITE Dark Spectrum Fitting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
ImageCollection
|
Collection of Sentinel-2 L1C images. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
corrected_images |
ImageCollection
|
Atmospherically corrected images with surface reflectance bands. |
settings |
dict
|
Processing settings used for correction. |
Notes
Settings read here: s2_target_res (default 10) and
s2_resampling_method ('nearest' (default) or 'bilinear'),
the interpolation used to bring the 20 m / 60 m bands to the target grid.
Source code in gee_acolite/correction.py
l1_to_l2
¶
Convert L1 TOA reflectance to L2 surface reflectance.
Processes each image in the collection through atmospheric correction and optionally applies residual glint correction and water quality parameter computation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
List
|
List of ee.Image objects (L1C TOA reflectance). |
required |
size
|
int
|
Number of images in the list. |
required |
settings
|
dict
|
Processing settings including correction parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
corrected_images |
ImageCollection
|
Collection of atmospherically corrected images. |
settings |
dict
|
Processing settings used. |
Source code in gee_acolite/correction.py
dask_spectrum_fitting
¶
Perform dark spectrum fitting atmospheric correction.
Main workflow for dark spectrum fitting (DSF). Retrieves ancillary data, selects optimal atmospheric model (LUT), estimates AOT, and computes surface reflectance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with TOA reflectance. |
required |
settings
|
dict
|
Processing settings. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
rhos |
Image
|
Surface reflectance image. |
bands |
list of str
|
List of band names processed. |
glint_ave |
dict
|
Glint correction parameters per band. |
Source code in gee_acolite/correction.py
estimate_aot_per_lut
¶
estimate_aot_per_lut(pdark: dict, lutd: dict, rsrd: dict, ttg: dict, geometry: dict, settings: dict, aot_skip_bands: List[str] = ['9', '10', '11', '12']) -> dict
Estimate aerosol optical thickness (AOT) for each LUT model.
Uses dark spectrum fitting to estimate AOT at 550nm for each atmospheric model in the LUT dictionary. The method finds AOT values that best match observed dark spectrum reflectance with modeled path reflectance.
This follows ACOLITE's fixed AOT estimation:
- a band whose (gas corrected) dark spectrum value falls outside the range
modeled by the LUT gets a NaN AOT and is dropped from the ranking, unless
dsf_allow_lut_boundariesis set, in which case it is clamped to the LUT AOT limits (gee_acolite <= 1.2.x behaviour); - the AOT is taken from the lowest-AOT bands according to
dsf_aot_compute; - if no band yields a valid AOT the AOT is set to 0.01.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pdark
|
dict
|
Dark spectrum values per band (e.g., {'B1': 0.05, 'B2': 0.04, ...}). |
required |
lutd
|
dict
|
Look-up table dictionary with atmospheric models. |
required |
rsrd
|
dict
|
Relative spectral response dictionary for the sensor. |
required |
ttg
|
dict
|
Gas transmittance values per band. |
required |
geometry
|
dict
|
Viewing geometry with keys 'raa', 'vza', 'sza', 'pressure'. |
required |
settings
|
dict
|
Processing settings. Keys read: 'dsf_nbands', 'dsf_aot_compute' ('min' (default), 'mean' or 'median'; mean/median use the 'dsf_nbands' lowest bands) and 'dsf_allow_lut_boundaries' (default False). |
required |
aot_skip_bands
|
list of str
|
Band numbers to skip in AOT estimation (default: ['9', '10', '11', '12']). |
['9', '10', '11', '12']
|
Returns:
| Name | Type | Description |
|---|---|---|
results |
dict
|
Dictionary with AOT estimation results per LUT model. Each entry contains: 'taua', 'taua_std', 'taua_cv', 'taua_bands', 'taua_arr', 'rhot_arr', 'bidx'. |
Source code in gee_acolite/correction.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
select_best_model
¶
select_best_model(results: dict, lutd: dict, geometry: dict, settings: dict) -> Tuple[str, float, str, float]
Select the best atmospheric model from AOT estimation results.
Evaluates multiple atmospheric models and selects the one that best fits the observed data based on the specified selection criterion (e.g., minimum RMSD, minimum delta tau, or coefficient of variation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
dict
|
AOT estimation results per LUT from estimate_aot_per_lut. |
required |
lutd
|
dict
|
Look-up table dictionary with atmospheric models. |
required |
geometry
|
dict
|
Viewing geometry with keys 'raa', 'vza', 'sza', 'pressure'. |
required |
settings
|
dict
|
Processing settings including 'dsf_model_selection' and 'dsf_nbands_fit'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
sel_lut |
str
|
Selected LUT name (e.g., 'ACOLITE-LUT-202110-MOD1'). |
sel_aot |
float
|
Selected AOT value at 550nm. |
sel_par |
str
|
Selection parameter name used ('rmsd', 'dtau', or 'taua_cv'). |
sel_val |
float
|
Value of the selection parameter for the chosen model. |
Source code in gee_acolite/correction.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
select_lut
¶
select_lut(image: Image, settings: dict, aot_skip_bands: List[str] = ['9', '10', '11', '12']) -> Tuple[dict, dict, List[str]]
Select optimal LUT and compute atmospheric correction parameters.
Main orchestration function for the dark spectrum fitting workflow:
- Extracts dark spectrum from the image
- Estimates AOT for each atmospheric model
- Selects the best model based on validation criterion
- Computes atmospheric correction parameters (path reflectance, transmittance, spherical albedo, gas transmittance)
- Computes glint correction parameters
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with TOA reflectance and geometry metadata. |
required |
settings
|
dict
|
Processing settings. |
required |
aot_skip_bands
|
list of str
|
Band numbers to skip in AOT estimation (default: ['9', '10', '11', '12']). |
['9', '10', '11', '12']
|
Returns:
| Name | Type | Description |
|---|---|---|
am |
dict
|
Atmospheric correction parameters with keys 'romix', 'dutott', 'astot', 'tg'. Each contains per-band values. |
glint_ave |
dict
|
Glint correction parameters per band (surface reflectance ratios). |
bands |
list of str
|
List of band names processed. |
Source code in gee_acolite/correction.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
compute_correction_with_fixed_aot
¶
compute_correction_with_fixed_aot(image: Image, aot: float, lut_name: str, settings: dict) -> Tuple[dict, dict, List[str]]
Compute atmospheric correction parameters using fixed AOT and LUT.
Alternative to dark spectrum fitting. Directly computes atmospheric correction parameters for a user-specified AOT value and atmospheric model. Useful for sensitivity analysis or when AOT is known a priori.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with TOA reflectance and geometry metadata. |
required |
aot
|
float
|
Fixed aerosol optical thickness at 550nm. |
required |
lut_name
|
str
|
LUT name (e.g., 'ACOLITE-LUT-202110-MOD2'). |
required |
settings
|
dict
|
Processing settings including pressure, ozone, water vapor. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
am |
dict
|
Atmospheric correction parameters with keys 'romix', 'dutott', 'astot', 'tg'. Each contains per-band values. |
glint_ave |
dict
|
Glint correction parameters per band. |
bands |
list of str
|
List of band names processed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If specified LUT name is not found in available LUTs. |
Source code in gee_acolite/correction.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
compute_glint_ratios
¶
compute_glint_ratios(luti: dict, model: int, geometry: dict, aot: float, rsr_bands: List[str], settings: dict) -> dict
Compute the per-band sky-glint (interface reflectance) ratios used by
:meth:deglint_alternative.
For each band the ratio is rsky(band) / mean(rsky(B11), rsky(B12)) evaluated
with the sky-reflectance LUT at wind speed 20 m/s. As in ACOLITE
(acolite_l2r.py ~1618) the LUT is evaluated at gc_aot = max(floor, aot)
with floor = glint_aot_floor (default 0.1). Only the glint ratios use the
floored AOT; the atmospheric correction keeps the real selected AOT.
Why the floor matters: the rsky LUT is exactly 0 in B11/B12 for AOT <= 0.05, so
the legacy ratio (evaluated at the raw AOT) was infinite and
deglint_alternative skipped every band, i.e. the residual glint correction was
silently disabled. For AOT in (0.05, 0.1) the legacy ratio was exaggerated
(e.g. B2 ratio 4.95 at AOT 0.06 and 1.65 at 0.08 in the real LUT), which removed
too much glint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
luti
|
dict
|
Sky-reflectance LUTs keyed by model number ( |
required |
model
|
int
|
Aerosol model number (1 or 2). |
required |
geometry
|
dict
|
Dict with 'raa', 'vza', 'sza'. |
required |
aot
|
float
|
Selected (or fixed) AOT at 550 nm. |
required |
rsr_bands
|
list of str
|
Band identifiers to evaluate (must include '11' and '12'). |
required |
settings
|
dict
|
Processing settings. Key read: |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Ratio per band. If the SWIR reference mean is not finite or not positive
(degenerate LUT) a |
Source code in gee_acolite/correction.py
compute_pdark
¶
Compute dark spectrum values from an image.
Extracts dark pixel reflectance values for each band using one of three methods: darkest pixels (minimum over all valid pixels), percentile-based, or linear intercept method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with TOA reflectance. |
required |
settings
|
dict
|
Processing settings including 'dsf_spectrum_option', 'dsf_percentile', 'dsf_intercept_pixels'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pdark_by_band |
dict
|
Dictionary with dark spectrum values per band (e.g., {'B1': 0.05, ...}). |
Source code in gee_acolite/correction.py
compute_rhos
¶
Compute surface reflectance from TOA reflectance.
Applies atmospheric correction using computed atmospheric parameters to derive surface reflectance. Also adds TOA reflectance bands to the output image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with TOA reflectance bands. |
required |
am
|
dict
|
Atmospheric correction parameters with keys 'romix' (path reflectance), 'dutott' (total upward transmittance), 'astot' (spherical albedo), 'tg' (gas transmittance). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
l2r_rrs |
Image
|
Image with both TOA reflectance (rhot_) and surface reflectance (rhos_) bands. |
Source code in gee_acolite/correction.py
get_ancillary_data
¶
Retrieve ancillary atmospheric data from NASA Earthdata.
Fetches ozone, water vapor, wind speed, and surface pressure data from NASA GMAO or NCEP reanalysis products for the image location and acquisition time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with geometry and timestamp. |
required |
settings
|
dict
|
Processing settings including Earthdata credentials and default values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
settings |
dict
|
Updated settings with ancillary data values. |
Source code in gee_acolite/correction.py
prepare_query
¶
Extract location and timestamp from image for ancillary data query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Input image with geometry and timestamp metadata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
iso_date |
str
|
ISO formatted date string. |
lon |
float
|
Longitude of image centroid. |
lat |
float
|
Latitude of image centroid. |
Source code in gee_acolite/correction.py
prepare_earthdata_credentials
¶
Set NASA Earthdata credentials as environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
dict
|
Settings dictionary potentially containing 'EARTHDATA_u' and 'EARTHDATA_p'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
settings |
dict
|
Input settings dictionary (unchanged). |
Source code in gee_acolite/correction.py
deglint_alternative
¶
deglint_alternative(image: Image, bands: List[str], glint_ave: dict, glint_min: float = 0, glint_max: float = 0.08) -> Image
Remove residual sun glint from surface reflectance image.
Alternative glint correction method based on ACOLITE's implementation. Uses SWIR bands (B11, B12) as reference to estimate and remove glint contamination. The glint signal is spectrally scaled based on modeled surface reflectance ratios.
Workflow: 1. Computes observed glint as average of SWIR reference bands (B11, B12) 2. Calculates average modeled surface reflectance for reference bands 3. For each band, scales observed glint by ratio of modeled reflectances 4. Subtracts scaled glint from surface reflectance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Image
|
Image with surface reflectance (rhos_*) bands. |
required |
bands
|
list of str
|
List of band numbers to correct (as strings, e.g., ['1', '2', ...]). |
required |
glint_ave
|
dict
|
Modeled surface reflectance ratios per band. |
required |
glint_min
|
float
|
Minimum threshold for glint mask (default: 0). |
0
|
glint_max
|
float
|
Maximum threshold for glint mask (default: 0.08). |
0.08
|
Returns:
| Name | Type | Description |
|---|---|---|
deglinted |
Image
|
Image with glint-corrected surface reflectance bands. |
Source code in gee_acolite/correction.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | |
Usage Example¶
import sys
sys.path.append('/path/to/acolite')
import ee
import acolite as ac
from gee_acolite import ACOLITE
from gee_acolite.utils.search import search
ee.Initialize(project='your-cloud-project-id')
ac_gee = ACOLITE(ac, {'s2_target_res': 10, 'dsf_spectrum_option': 'darkest'})
# Search for Sentinel-2 images
roi = ee.Geometry.Rectangle([-0.5, 39.3, -0.1, 39.7])
images = search(roi, '2023-06-01', '2023-06-30', tile='30SYJ')
# Apply atmospheric correction
corrected_images, settings = ac_gee.correct(images)
# Access corrected bands
first_image = corrected_images.first()
rrs_bands = ['Rrs_B1', 'Rrs_B2', 'Rrs_B3', 'Rrs_B4', 'Rrs_B5',
'Rrs_B6', 'Rrs_B7', 'Rrs_B8', 'Rrs_B8A', 'Rrs_B11', 'Rrs_B12']
Configuration¶
The method accepts a configuration file or dictionary with the following main parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
s2_target_res |
int | Target spatial resolution in metres (10, 20, or 60) | 10 |
dsf_spectrum_option |
str | Dark spectrum method: 'darkest', 'percentile', 'intercept' |
'darkest' |
dsf_percentile |
float | Percentile when dsf_spectrum_option='percentile' |
1 |
dsf_nbands |
int | Number of darkest bands used for AOT fitting | 2 |
dsf_model_selection |
str | Model selection criterion: 'min_drmsd', 'min_dtau', 'taua_cv' |
'min_drmsd' |
dsf_fixed_aot |
float | Fixed AOT at 550 nm — skips DSF entirely if set | None |
dsf_fixed_lut |
str | LUT model name — required when dsf_fixed_aot is set |
None |
pressure |
float | Atmospheric pressure (hPa) | 1013.25 |
wind |
float | Wind speed (m/s) | 3.0 |
uoz |
float | Total ozone column (cm-atm) | 0.3 |
uwv |
float | Atmospheric water vapour (g/cm²) | 1.5 |
l2w_parameters |
list[str] | Water quality products to compute after correction | [] |
Technical Notes¶
AOT Estimation¶
The DSF method estimates aerosol optical thickness (AOT) assuming that:
- Dark pixels: There are pixels with very low surface reflectance (deep clear waters)
- Spectral relationship: The reflectance of these pixels has a known spectral shape
- Least squares fitting: The AOT that minimizes the difference between observed and modeled spectrum is found
Look-Up Tables (LUTs)¶
ACOLITE uses pre-calculated LUTs with radiative transfer for:
- Downward atmospheric transmittance
- Upward atmospheric transmittance
- Atmospheric path reflectance
- Diffuse radiance
The LUTs consider:
- Viewing geometry (solar and sensor angles)
- Aerosol properties (maritime/continental models)
- Atmospheric pressure
- Atmospheric gases (O₃, H₂O, O₂, etc.)
References¶
- Vanhellemont, Q., & Ruddick, K. (2018). Atmospheric correction of metre-scale optical satellite data for inland and coastal water applications. Remote Sensing of Environment, 216, 586-597.
- Vanhellemont, Q. (2019). Adaptation of the dark spectrum fitting atmospheric correction for aquatic applications of the Landsat and Sentinel-2 archives. Remote Sensing of Environment, 225, 175-192.