sisppeo package

Subpackages

Submodules

sisppeo.builders module

Contains the ProductBuilder class.

The builder pattern organizes object construction into a set of steps (extract_data, apply_algos, get_products, etc). To create an object, you execute a series of these steps on a builder object (here, a ProductBuilder instance). The important part is that you don’t need to call all of the steps. You can call only the steps that are necessary for producing a particular configuration of an object.

If the client code needs to assemble a special, fine-tuned L3 or L4 product, it can work with the builder directly. Otherwise, the user can delegate the assembly to the generate method (or dictely one of the recipes), which knows how to use a builder to construct several of the most standard products (e.g., L3AlgoProduct, L3MaskProduct, TimeSeries, Matchup, etc).

class sisppeo.builders.ProductBuilder[source]

Bases: object

The builder used to create L3 and L4 objects.

It specifies methods for creating the different parts (or building steps) of the product objects, and provides their implementations.

compute_algos()[source]

Runs every algorithms using extracted data and stores the results.

compute_masks()[source]

Runs every masks using extracted data and stores the results.

create_l3products(product_type)[source]

Creates the wanted products and stores them.

Parameters

product_type – The type of the input satellite product (e.g. “S2_ESA_L2A” or “L8_USGS_L1”).

extract_data(product_type, input_product, geom=None, **kwargs)[source]

Extracts (meta)data from the input product.

Selects the right Reader and use it to extract the needed bands and metadata. Then, creates and returns a xr.Dataset containing these information.

Parameters
  • product_type – The type of the input satellite product (e.g. “S2_ESA_L2A” or “L8_USGS_L1”).

  • input_product – The path of the input product (multispectral spaceborne imagery).

  • geom – Optional; A dict containing geographical information that define the ROI. 4 keys: geom (a shapely.geom object), shp (a path to an ESRI shapefile), wkt (a path to a wkt file) and srid (an EPSG code).

  • kwargs – Args specific to the selected Reader.

get_products()[source]

Returns products and resets itself.

mask_l3algosproduct(masks_types, masks=None, masks_paths=None)[source]

Masks the previously generated products.

Parameters
  • masks_types – The list of the type of the masks to use. Values can either be “IN” (area to include) or “OUT” (area to exclude).

  • masks – Optional; A list of masks to use.

  • masks_paths – Optional; A list of paths (of L3MaskProducts) to use.

set_algos(lst_algo, product_type, lst_band=None, lst_calib=None, lst_design=None)[source]

Creates and inits algo objects.

Parameters
  • lst_algo – A list of algorithms to use.

  • product_type – The type of the input satellite product (e.g. S2_ESA_L2A or L8_USGS_L1GT).

  • lst_band – A list of “requested_band” args (a param used by some algorithms).

  • lst_calib – A list of “calibration” args (a param used by some algorithms).

  • lst_design – A list of “design” args (a param used by some algorithms).

set_masks(lst_masks, product_type)[source]

Creates mask objects.

Parameters
  • lst_masks – A list of masks to use.

  • product_type – The type of the input satellite product (e.g. S2_ESA_L1C).

sisppeo.catalogs module

Defines dicts containing algos, masks and readers.

sisppeo.cli module

Defines the CLI of SISPPEO (powered by click).

sisppeo.main module

Contains “generate” (a function) and some standard recipes.

The “generate” function is the user-friendly way of using SISPPEO. You give the type of products you want, a config dictionary and that’s all: you can then get the products you asked for ! It will automatically call the right recipe, parse parameters (values in the config dict), and save generated products if asked.

Each recipe is responsible for executing the building steps in a particular sequence (while the builder provides the implementation for those steps). Strictly speaking, these recipes are optionals, since the client can control the builder directly.

sisppeo.main.create_algotimeseries(input_products, product_type, lst_algo, lst_l3masks=None, lst_l3masks_paths=None, lst_l3masks_types=None, lst_tsmask=None, lst_tsmask_path=None, lst_tsmask_type=None, geom=None, save=False, dirname=None, filenames=None, **kwargs)[source]

Returns a list of TimeSeries (one per algo in lst_algo).

Parameters
  • input_products – The list of paths of input products (multispectral spaceborne imagery).

  • product_type – The type of input satellite products (e.g. “S2_ESA_L2A” or “L8_USGS_L1GT”).

  • lst_algo – A list of algorithms to use.

  • lst_l3masks – A list of lists of masks (L3MaskProduct) to use.

  • lst_l3masks_paths – A list of lists of paths (of L3MaskProducts) to use.

  • lst_l3masks_types – The list of lists of the type of the masks to use. Values can either be “IN” (area to include) or “OUT” (area to exclude).

  • lst_tsmask – A list of time series of masks to use.

  • lst_tsmask_path – A list of paths (of TimeSeries) to use.

  • lst_tsmask_type – The list of the type of the time series of masks used. Values can either be “IN” (area to include) or “OUT” (area to exclude).

  • geom – A dict containing geographical information that define the ROI. 4 keys: geom (a shapely.geom object), shp (a path to an ESRI shapefile), wkt (a path to a wkt file) and srid (an EPSG code).

  • save – If True, write output products on disk.

  • dirname – The path of the directory in which output products will be written (using automatically generated names).

  • filenames – A list of wanted paths for output products.

  • **kwargs – Args specific to the Reader that will be used.

sisppeo.main.create_batch_l3algoproducts(input_products, product_types, lst_algo, lst_l3masks=None, lst_l3masks_paths=None, lst_l3masks_types=None, num_cpus=None, lst_tb=None, lst_tm=None, lst_gc=None, lst_flags=None, lst_geom=None, lst_res=None, save=False, dirname=None, filenames=None, **kwargs)[source]

Returns a list of lists of L3AlgoProducts.

Parameters
  • input_products – The list of paths of input products (multispectral spaceborne imagery).

  • product_types – The list of types of input satellite products (e.g., [“S2_ESA_L2A”, “L8_USGS_L1GT”]).

  • lst_algo – A list of algorithms to use.

  • lst_l3masks – A list of lists of masks (L3MaskProduct) to use.

  • lst_l3masks_paths – A list of lists of paths (of L3MaskProducts) to use.

  • lst_l3masks_types – The list of lists of the type of the masks to use. Values can either be “IN” (area to include) or “OUT” (area to exclude).

  • num_cpus – The number of central processing units to use.

  • lst_tb – A list of “theia_bands” args (one per input product). See S2THEIAReader.

  • lst_tm – A list of “theia_masks” args (one per input product). See S2THEIAReader.

  • lst_gc – A list of “glint_corrected” args (one per input product). See GRSReader.

  • lst_flags – A list of “flags” args (one per input product). See GRSReader.

  • lst_geom – A list of “geom” args (one per input product). See Reader.

  • lst_res – A list of “out_resolution” args (one per input product). See either S2ESAREader or S2THEIAReader.

  • save – If True, write output products on disk.

  • dirname – The path of the directory in which output products will be written (using automatically generated names).

  • filenames – A list of wanted paths for output products.

  • **kwargs – Args specific to Readers that will be used.

Returns

A list of lists of L3AlgoProducts. Each list corresponds to one input product.

input_products = [<path1>, <path2>] lst_algo = [<algo1>, <algo2>, <algo3>] -> [[res_p1_a1, …, res_p1_a3], [res_p2_a1, …, res_p2_a3]]

sisppeo.main.create_batch_l3maskproducts(input_products, product_types, lst_mask, num_cpus=None, lst_tb=None, lst_tm=None, lst_gc=None, lst_flags=None, lst_geom=None, lst_res=None, lst_proc_res=None, save=False, dirname=None, filenames=None, **kwargs)[source]

Returns a list of lists of L3MaskProducts.

Parameters
  • input_products – The list of paths of input products (multispectral spaceborne imagery).

  • product_types – The list of types of input satellite producs (e.g., [“S2_ESA_L1C”, “S2_GRS”]).

  • lst_mask – A list of masks to use.

  • num_cpus – The number of central processing units to use.

  • lst_tb – A list of “theia_bands” args (one per input product). See S2THEIAReader.

  • lst_tm – A list of “theia_masks” args (one per input product). See S2THEIAReader.

  • lst_gc – A list of “glint_corrected” args (one per input product). See GRSReader.

  • lst_flags – A list of “flags” args (one per input product). See GRSReader.

  • lst_geom – A list of “geom” args (one per input product). See Reader.

  • lst_res – A list of “out_resolution” args (one per input product). See either S2ESAREader or S2THEIAReader.

  • lst_proc_res – A list of “proc_res” args (one per input product). See ProductBuilder.compute_masks.

  • save – If True, write output products on disk.

  • dirname – The path of the directory in which output products will be written (using automatically generated names).

  • filenames – A list of wanted paths for output products.

  • **kwargs – Args specific to Readers that will be used.

Returns

A list of lists of L3AlgoMasks. Each list corresponds to one input product.

input_products = [<path1>, <path2>] lst_mask = [<mask1>, <mask2>, <mask3>] -> [[res_p1_m1, …, res_p1_m3], [res_p2_m1, …, res_p2_m3]]

sisppeo.main.create_l3algoproducts(input_product, product_type, lst_algo, lst_l3mask=None, lst_l3mask_path=None, lst_l3mask_type=None, geom=None, lst_band=None, lst_calib=None, lst_design=None, save=False, dirname=None, filenames=None, **kwargs)[source]

Returns a list of L3AlgoProducts (one per algo in lst_algo).

Parameters
  • input_product – The path of the input product (multispectral spaceborne imagery).

  • product_type – The type of the input satellite product (e.g. “S2_ESA_L2A” or “L8_USGS_L1GT”).

  • lst_algo – A list of algorithms to use.

  • lst_l3mask – A list of masks (L3MaskProduct) to use.

  • lst_l3mask_path – A list of paths (of L3MaskProducts) to use.

  • lst_l3mask_type – The list of the type of the masks used. Values can either be “IN” (area to include) or “OUT” (area to exclude).

  • geom – A dict containing geographical information that define the ROI. 4 keys: geom (a shapely.geom object), shp (a path to an ESRI shapefile), wkt (a path to a wkt file) and srid (an EPSG code).

  • lst_band – A list of “requested_band” args (a param used by some algorithms).

  • lst_calib – A list of “calibration” args (a param used by some algorithms).

  • lst_design – A list of “design” args (a param used by some algorithms).

  • save – If True, write output products on disk.

  • dirname – The path of the directory in which output products will be written (using automatically generated names).

  • filenames – A list of wanted paths for output products.

  • **kwargs – Args specific to the Reader that will be used.

sisppeo.main.create_l3maskproducts(input_product, product_type, lst_mask, geom=None, save=False, dirname=None, filenames=None, **kwargs)[source]

Returns a list of L3MaskProducts (one per mask in lst_mask).

Parameters
  • input_product – The path of the input product (multispectral spaceborne imagery).

  • product_type – The type of the input satellite product (e.g. “S2_ESA_L1C” or “S2_GRS”).

  • lst_mask – A list of masks to use.

  • geom – A dict containing geographical information that define the ROI. 4 keys: geom (a shapely.geom object), shp (a path to an ESRI shapefile), wkt (a path to a wkt file) and srid (an EPSG code).

  • save – If True, write output products on disk.

  • dirname – The path of the directory in which output products will be written (using automatically generated names).

  • filenames – A list of wanted paths for output products.

  • **kwargs – Args specific to the Reader that will be used.

sisppeo.main.create_masktimeseries(input_products, product_type, lst_mask, geom=None, save=False, dirname=None, filenames=None, **kwargs)[source]

Returns a list of TimeSeries (one per mask in lst_mask).

Parameters
  • input_products – The list of paths of input products (multispectral spaceborne imagery).

  • product_type – The type of input satellite products (e.g. “S2_ESA_L2A” or “L8_USGS_L1GT”).

  • lst_mask – A list of masks to use.

  • geom – A dict containing geographical information that define the ROI. 4 keys: geom (a shapely.geom object), shp (a path to an ESRI shapefile), wkt (a path to a wkt file) and srid (an EPSG code).

  • save – If True, write output products on disk.

  • dirname – The path of the directory in which output products will be written (using automatically generated names).

  • filenames – A list of wanted paths for output products.

  • **kwargs – Args specific to Readers that will be used.

sisppeo.main.generate(key, params, save=False, parse_params_=True)[source]

Returns the wanted (L3/L4) products. Can also save them.

Parameters
  • key – What product to generate.

  • params – A dict of params.

  • save – If True, write them on disk.

  • parse_params – If True, the params dict is checked (using the parse_params function).

Module contents