Getting started
This page provides a quick introduction to using eotools for atmospheric correction of satellite imagery.
1 Installation
Install from PyPI:
pip install eotoolsor from conda-forge:
conda install -c conda-forge eotoolsThis installs the required dependencies, including hygeos-core (common utilities, imported as hygeos_core) and luts.
The level-1 readers and ancillary data providers come from eoread (version 2 or later), an optional dependency installed with the eoread extra:
pip install "eotools[eoread]"(with conda: conda install -c conda-forge eotools eoread)
eotools relies on auxiliary data (data files, meteo files, etc.) that are fetched automatically.
Data directories are managed by hygeos_core.env. Set the DIR_DATA environment variable to point to your data directory. Other paths (static, ancillary, sample_products) default to subdirectories under it.
export DIR_DATA="$HOME/eo_data"You can also set it in a .env file in your working directory. If undefined, data defaults to ./data.
2 Quick example: Gaseous & Rayleigh correction
2.1 From command line
Process a level1 product with the eoread.readers.planetscope.Level1_PLANETSCOPE reader, and write it to netcdf:
python -m eotools.rayleigh \
/path/to/level1_product \
eoread.readers.planetscope.Level1_PLANETSCOPE \
/path/to/output.ncAvailable readers include all sensors available in eoread:
eoread.readers.msi.Level1C_MSIeoread.readers.olci.Level1_OLCIeoread.readers.oli.Level1_OLIeoread.readers.planetscope.Level1_PLANETSCOPEeoread.readers.pleiades.Level1_PLEIADESeoread.readers.pleiades_neo.Level1_PNEOeoread.readers.geosat.Level1_GEOSAT
2.2 With process_rayleigh
For programmatic use, process_rayleigh handles file I/O and applies the full correction pipeline:
from pathlib import Path
from eotools.rayleigh import process_rayleigh
process_rayleigh(
input_product=Path("/path/to/level1_product"),
reader="eoread.readers.planetscope.Level1_PLANETSCOPE",
output_product=Path("/path/to/output.nc"),
dem="eotools.dem.CopernicusDEM",
)2.3 With process_rayleigh_dataset
To work with an xarray.Dataset directly (e.g., for further custom processing), use process_rayleigh_dataset:
from eoread.readers.planetscope import Level1_PLANETSCOPE
from eotools.rayleigh import process_rayleigh_dataset
from hygeos_core.files.save import to_netcdf
# Load a Level-1 dataset
ds = Level1_PLANETSCOPE("/path/to/level1_product")
# Apply the full Rayleigh correction pipeline
result = process_rayleigh_dataset(
ds,
dem="eotools.dem.GTOPO30",
transmittance_corr=True,
)
# Access corrected reflectance
rho_rc = result["rho_rc"]
# Write the full corrected dataset to a NetCDF file
to_netcdf(result, filename="/path/to/output.nc")3 Output variables
| Variable | Description |
|---|---|
rho_gc |
Gaseous-corrected reflectance |
rho_rc |
Rayleigh-corrected surface reflectance |
rho_r |
Rayleigh reflectance (without glint) |
rho_rg |
Rayleigh + sun glint reflectance |
t_d |
Total atmospheric transmittance |
odr |
Rayleigh optical depth |
4 Next steps
- Rayleigh scattering — Detailed documentation on Rayleigh correction
- Gaseous absorption — Detailed documentation on gaseous correction