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. |
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.
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 including 'dsf_nbands'. |
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
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 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 | |
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
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 334 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 | |
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
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 434 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 | |
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
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 522 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 | |
compute_pdark
¶
Compute dark spectrum values from an image.
Extracts dark pixel reflectance values for each band using one of three methods: darkest pixels (0th percentile), 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
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | |
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.