S1Tiling API

This section is intended for people who want to directly call S1Tiling code from their project instead of using the external programs S1Processor, S1LIAMap, S1IAMap, and S1GammaAreaMap.

Entry points

s1_process

s1tiling.libs.api.s1_process(config_opt: str | Configuration, *, dl_wait: int = 2, dl_timeout: int = 20, searched_items_per_page: int = 20, nb_max_search_retries: int = 5, dryrun: bool = False, debug_otb: bool = False, debug_caches: bool = False, watch_ram: bool = False, debug_tasks: bool = False, cache_before_ortho: bool = False, lia_process=None, gamma_area_process=None) Situation[source]

Entry point to S1Tiling classic scenario and S1Tiling NORMLIM scenario of on demand Ortho-rectification of Sentinel-1 data on Sentinel-2 grid for all calibration kinds.

It performs the following steps:

  1. Download S1 images from S1 data provider (through eodag)

    This step may be ignored if config_opt download option is false;

  2. Calibrate the S1 images according to the calibration option from config_opt;

  3. Orthorectify S1 images and cut their on geometric tiles;

  4. Concatenate images from the same orbit on the same tile;

  5. Build mask files;

  6. Despeckle final images.

Parameters:
  • config_opt – Either a request configuration file or a s1tiling.libs.configuration.Configuration instance.

  • dl_wait – Permits to override EODAG default wait time in minutes between two download tries.

  • dl_timeout – Permits to override EODAG default maximum time in mins before stop retrying to download (default=20)

  • searched_items_per_page – Tells how many items are to be returned by EODAG when searching for S1 images.

  • dryrun – Used for debugging: external (OTB/GDAL) application aren’t executed.

  • debug_otb – Used for debugging: Don’t execute processing tasks in DASK workers but directly in order to be able to analyse OTB/external application through a debugger.

  • debug_caches – Used for debugging: Don’t delete the intermediary files but leave them behind.

  • watch_ram – Used for debugging: Monitoring Python/Dask RAM consumption.

  • debug_tasks – Generate SVG images showing task graphs of the processing flows

  • cache_before_ortho – Cutting, calibration and orthorectification are chained in memory unless this option is true. In that case, Cut and calibrated (aka “OrthoReady”) files are stored in %(tmp)/S1/ directory. Do not forget to regularly clean up this space.

Returns:

A nominal exit code depending of whether everything could have been downloaded and produced.

Return type:

s1tiling.libs.cli.exits.Situation

Raises:

Error – A variety of exceptions. See below (follow the link).

s1_process_lia

s1tiling.libs.api.s1_process_lia(config_opt: str | Configuration, *, dryrun: bool = False, debug_otb: bool = False, debug_caches: bool = False, watch_ram: bool = False, debug_tasks: bool = False) Situation

Entry point to LIA Map production scenario that generates Local Incidence Angle Maps on S2 geometry.

It performs the following steps:

  1. Register the downloading of missing EOF matching the requested (relative) orbit number

  2. Generate the LIA maps

Parameters:
  • config_opt – Either a request configuration file or a s1tiling.libs.configuration.Configuration instance.

  • dryrun – Used for debugging: external (OTB/GDAL) application aren’t executed.

  • debug_otb – Used for debugging: Don’t execute processing tasks in DASK workers but directly in order to be able to analyse OTB/external application through a debugger.

  • debug_caches – Used for debugging: Don’t delete the intermediary files but leave them behind.

  • watch_ram – Used for debugging: Monitoring Python/Dask RAM consumption.

  • debug_tasks – Generate SVG images showing task graphs of the processing flows

Returns:

A nominal exit code depending of whether everything could have been downloaded and produced.

Return type:

s1tiling.libs.cli.exits.Situation

Raises:

Error – A variety of exceptions. See below (follow the link).

s1_process_ia

s1tiling.libs.api.s1_process_ia(config_opt: str | Configuration, *, dryrun: bool = False, debug_otb: bool = False, debug_caches: bool = False, watch_ram: bool = False, debug_tasks: bool = False) Situation[source]

Entry point to IA Map production scenario that generates Incidence Angle Maps on S2 geometry.

It performs the following steps:

  1. Register the downloading of missing EOF matching the requested (relative) orbit number

  2. Generate the IA maps

Parameters:
  • config_opt – Either a request configuration file or a s1tiling.libs.configuration.Configuration instance.

  • dryrun – Used for debugging: external (OTB/GDAL) application aren’t executed.

  • debug_otb – Used for debugging: Don’t execute processing tasks in DASK workers but directly in order to be able to analyse OTB/external application through a debugger.

  • debug_caches – Used for debugging: Don’t delete the intermediary files but leave them behind.

  • watch_ram – Used for debugging: Monitoring Python/Dask RAM consumption.

  • debug_tasks – Generate SVG images showing task graphs of the processing flows

Returns:

A nominal exit code depending of whether everything could have been downloaded and produced.

Return type:

s1tiling.libs.cli.exits.Situation

Raises:

Error – A variety of exceptions. See below (follow the link).

s1_process_gamma_area

s1tiling.libs.api.s1_process_gamma_area(config_opt: str | Configuration, *, dl_wait: int = 2, dl_timeout: int = 20, searched_items_per_page: int = 20, nb_max_search_retries: int = 5, dryrun: bool = False, debug_otb: bool = False, debug_caches: bool = False, watch_ram: bool = False, debug_tasks: bool = False) Situation[source]

Entry point to GAMMA_AREA Map production scenario that generates Gamma Area Maps on S2 geometry.

It performs the following steps:

  1. Determine the S1 products to process

    Given a list of S2 tiles, we first determine the day that’ll the best coverage of each S2 tile in terms of S1 products.

    In case there is no single day that gives the best coverage for all S2 tiles, we try to determine the best solution that minimizes the number of S1 products to download and process.

  2. Process these S1 products

Parameters:
  • config_opt – Either a request configuration file or a s1tiling.libs.configuration.Configuration instance.

  • dl_wait – Permits to override EODAG default wait time in minutes between two download tries.

  • dl_timeout – Permits to override EODAG default maximum time in mins before stop retrying to download (default=20)

  • searched_items_per_page – Tells how many items are to be returned by EODAG when searching for S1 images.

  • dryrun – Used for debugging: external (OTB/GDAL) application aren’t executed.

  • debug_otb – Used for debugging: Don’t execute processing tasks in DASK workers but directly in order to be able to analyse OTB/external application through a debugger.

  • debug_caches – Used for debugging: Don’t delete the intermediary files but leave them behind.

  • watch_ram – Used for debugging: Monitoring Python/Dask RAM consumption.

  • debug_tasks – Generate SVG images showing task graphs of the processing flows

Returns:

A nominal exit code depending of whether everything could have been downloaded and produced.

Return type:

s1tiling.libs.cli.exits.Situation

Raises:

Error – A variety of exceptions. See below (follow the link).

Configuration object

class s1tiling.libs.configuration.Configuration(config_file: PathLike | str, accessor: ConfigAccessor)[source]

This class handles the parameters from the cfg file

property dem_db_filepath: str

Get the DEMShapefile databe filepath

get_dems_covering_s2_tile(tile_name: str) Dict[source]

Retrieve the DEM associated to the specified S2 tile.

product_type

Type of images handled

Workaround that helps caching DEM related information for later use.

sensor_mode

Sensor mode of products transformed

show_configuration() None[source]

Displays the configuration

Result (Situation) object

Exceptions

S1Tiling may raise the following exceptions:

Inheritance diagram of s1tiling.libs.exceptions.CorruptedDataSAFEError, s1tiling.libs.exceptions.DownloadS1FileError, s1tiling.libs.exceptions.NoS2TileError, s1tiling.libs.exceptions.NoS1ImageError, s1tiling.libs.exceptions.MissingDEMError, s1tiling.libs.exceptions.MissingGeoidError, s1tiling.libs.exceptions.InvalidOTBVersionError, s1tiling.libs.exceptions.MissingApplication

class s1tiling.libs.exceptions.Error[source]

Base class for all S1Tiling specific exceptions.

class s1tiling.libs.exceptions.CorruptedDataSAFEError(product: str, details: str | None, *args, **kwargs)[source]

An empty data safe has been found and needs to be removed so it can be fetched again.

class s1tiling.libs.exceptions.DownloadS1FileError(tile_name: str, *args, **kwargs)[source]

Error that signals problems to download images.

class s1tiling.libs.exceptions.NoS2TileError(*args, **kwargs)[source]

Error that signals incorrect Sentinel-2 tile names.

class s1tiling.libs.exceptions.NoS1ImageError(*args, **kwargs)[source]

No Sentinel-1 product has been found that intersects the requested Sentinel-2 tiles within the requested time range

class s1tiling.libs.exceptions.MissingDEMError(*args, **kwargs)[source]

Cannot find all the DEM products that cover the requested Sentinel-2 tiles

class s1tiling.libs.exceptions.MissingGeoidError(geoid_file: str | Path, *args, **kwargs)[source]

The geoid file is missing or the specified path is incorrect.

class s1tiling.libs.exceptions.InvalidOTBVersionError(reason: str, *args, **kwargs)[source]

Error that signals OTB version incompatible with S1Tiling needs.

class s1tiling.libs.exceptions.MissingApplication(missing_apps, contexts: Set[str] | List[str], *args, **kwargs)[source]

Some processing cannot be done because external applications cannot be executed. Likelly OTB and/or NORMLIM related applications aren’t correctly installed.