Configuration

gdal_conf

Stores GDAL configuration options for the current process.

geocode_conf

Returns a dictionary of additional parameters for pyroSAR.snap.util.geocode() based on processing configurations provided by the config file.

get_config

Returns the content of a config.ini file as a dictionary.

S1_NRB.config.gdal_conf(config)[source]

Stores GDAL configuration options for the current process.

Parameters

config (dict) – Dictionary of the parsed config parameters for the current process.

Returns

Dictionary containing GDAL configuration options for the current process.

Return type

dict

S1_NRB.config.geocode_conf(config)[source]

Returns a dictionary of additional parameters for pyroSAR.snap.util.geocode() based on processing configurations provided by the config file.

Parameters

config (dict) – Dictionary of the parsed config parameters for the current process.

Returns

Dictionary of parameters that can be passed to pyroSAR.snap.util.geocode()

Return type

dict

S1_NRB.config.get_config(config_file, section_name='GENERAL')[source]

Returns the content of a config.ini file as a dictionary.

Parameters
  • config_file (str) – Full path to the config file that should be parsed to a dictionary.

  • section_name (str, optional) – Section name of the config file that parameters should be parsed from. Default is ‘GENERAL’.

Returns

out_dict – Dictionary of the parsed config parameters.

Return type

dict

Processing

main

Main function that initiates and controls the processing workflow.

S1_NRB.processor.main(config_file, section_name='GENERAL', debug=False)[source]

Main function that initiates and controls the processing workflow.

Parameters
  • config_file (str) – Full path to a config.ini file.

  • section_name (str, optional) – Section name of the config.ini file that parameters should be parsed from. Default is ‘GENERAL’.

  • debug (bool, optional) – Set pyroSAR logging level to DEBUG? Default is False.

NRB

calc_product_start_stop

Calculates the start and stop times of the NRB product.

create_acq_id_image

Creation of the Acquisition ID image.

create_data_mask

Creation of the Data Mask image.

create_rgb_vrt

Creation of the color composite VRT file.

create_vrt

Creates a VRT file for the specified source dataset(s) and adds a pixel function that should be applied on the fly when opening the VRT file.

format

Finalizes the generation of Sentinel-1 NRB products after processing steps via pyroSAR.snap.util.geocode() and pyroSAR.snap.util.noise_power() have finished.

get_datasets

Identifies all source SLC scenes, finds matching output files processed with pyroSAR.snap.util.geocode() in datadir and filters both lists depending on the actual overlap of each SLC footprint with the current MGRS tile geometry.

S1_NRB.nrb.calc_product_start_stop(src_ids, extent, epsg)[source]

Calculates the start and stop times of the NRB product. The geolocation grid points including their azimuth time information are extracted first from the metadata of each source SLC. These grid points are then used to interpolate the azimuth time for the lower right and upper left (ascending) or upper right and lower left (descending) corners of the MGRS tile extent.

Parameters
  • src_ids (list[pyroSAR.drivers.ID]) – List of ID objects of all source SLC scenes that overlap with the current MGRS tile.

  • extent (dict) – Spatial extent of the MGRS tile, derived from a Vector object.

  • epsg (int) – The coordinate reference system as an EPSG code.

Returns

  • start (str) – Start time of the NRB product formatted as %Y%m%dT%H%M%S in UTC.

  • stop (str) – Stop time of the NRB product formatted as %Y%m%dT%H%M%S in UTC.

S1_NRB.nrb.create_acq_id_image(outname, ref_tif, snap_datamasks, src_ids, extent, epsg, driver, creation_opt, overviews, dst_nodata)[source]

Creation of the Acquisition ID image.

Parameters
  • outname (str) – Full path to the output data mask file.

  • ref_tif (str) – Full path to any GeoTIFF file of the NRB product.

  • snap_datamasks (list[str]) – List of raster datamask files covering the footprint of each source SLC scene that overlaps with the current MGRS tile.

  • src_ids (list[pyroSAR.drivers.ID]) – List of ID objects of all source SLC scenes that overlap with the current MGRS tile.

  • extent (dict) – Spatial extent of the MGRS tile, derived from a Vector object.

  • epsg (int) – The CRS used for the NRB product; provided as an EPSG code.

  • driver (str) – GDAL driver to use for raster file creation.

  • creation_opt (list[str]) – GDAL creation options to use for raster file creation. Should match specified GDAL driver.

  • overviews (list[int]) – Internal overview levels to be created for each raster file.

  • dst_nodata (int or str) – Nodata value to write to the output raster.

S1_NRB.nrb.create_data_mask(outname, snap_datamasks, snap_datasets, extent, epsg, driver, creation_opt, overviews, overview_resampling, dst_nodata, wbm=None)[source]

Creation of the Data Mask image.

Parameters
  • outname (str) – Full path to the output data mask file.

  • snap_datamasks (list[str]) – List of raster datamask files covering the footprint of each source SLC scene that overlaps with the current MGRS tile.

  • snap_datasets (list[str]) – List of output files processed with pyroSAR.snap.util.geocode() that match the source SLC scenes and overlap with the current MGRS tile.

  • extent (dict) – Spatial extent of the MGRS tile, derived from a Vector object.

  • epsg (int) – The coordinate reference system as an EPSG code.

  • driver (str) – GDAL driver to use for raster file creation.

  • creation_opt (list[str]) – GDAL creation options to use for raster file creation. Should match specified GDAL driver.

  • overviews (list[int]) – Internal overview levels to be created for each raster file.

  • overview_resampling (str) – Resampling method for overview levels.

  • dst_nodata (int or str) – Nodata value to write to the output raster.

  • wbm (str, optional) – Path to a water body mask file with the dimensions of an MGRS tile.

S1_NRB.nrb.create_rgb_vrt(outname, infiles, overviews, overview_resampling)[source]

Creation of the color composite VRT file.

Parameters
  • outname (str) – Full path to the output VRT file.

  • infiles (list[str]) – A list of paths pointing to the linear scaled measurement backscatter files.

  • overviews (list[int]) – Internal overview levels to be defined for the created VRT file.

  • overview_resampling (str) – Resampling method applied to overview pyramids.

S1_NRB.nrb.create_vrt(src, dst, fun, relpaths=False, scale=None, offset=None, options=None, overviews=None, overview_resampling=None)[source]

Creates a VRT file for the specified source dataset(s) and adds a pixel function that should be applied on the fly when opening the VRT file.

Parameters
  • src (str or list[str]) – The input dataset(s).

  • dst (str) – The output dataset.

  • fun (str) – A PixelFunctionType that should be applied on the fly when opening the VRT file. The function is applied to a band that derives its pixel information from the source bands. A list of possible options can be found here: https://gdal.org/drivers/raster/vrt.html#default-pixel-functions Furthermore, the option ‘decibel’ can be specified, which will implement a custom pixel function that uses Python code for decibel conversion (10*log10).

  • relpaths (bool, optional) – Should all SourceFilename XML elements with attribute @relativeToVRT=”0” be updated to be paths relative to the output VRT file? Default is False.

  • scale (int, optional) – The scale that should be applied when computing “real” pixel values from scaled pixel values on a raster band. Will be ignored if fun=’decibel’.

  • offset (float, optional) – The offset that should be applied when computing “real” pixel values from scaled pixel values on a raster band. Will be ignored if fun=’decibel’.

  • options (dict, optional) – Additional parameters passed to gdal.BuildVRT.

  • overviews (list[int], optional) – Internal overview levels to be created for each raster file.

  • overview_resampling (str, optional) – Resampling method for overview levels.

S1_NRB.nrb.format(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None, multithread=True, compress=None, overviews=None)[source]

Finalizes the generation of Sentinel-1 NRB products after processing steps via pyroSAR.snap.util.geocode() and pyroSAR.snap.util.noise_power() have finished. This includes the following: - Creating all measurement and annotation datasets in Cloud Optimized GeoTIFF (COG) format - Creating additional annotation datasets in Virtual Raster Tile (VRT) format - Applying the NRB product directory structure & naming convention - Generating metadata in XML and JSON formats for the NRB product as well as source SLC datasets

Parameters
  • config (dict) – Dictionary of the parsed config parameters for the current process.

  • scenes (list[str]) – List of scenes to process. Either an individual scene or multiple, matching scenes (consecutive acquisitions).

  • datadir (str) – The directory containing the datasets processed from the source scenes using pyroSAR.

  • outdir (str) – The directory to write the final files to.

  • tile (str) – ID of an MGRS tile.

  • extent (dict) – Spatial extent of the MGRS tile, derived from a Vector object.

  • epsg (int) – The CRS used for the NRB product; provided as an EPSG code.

  • wbm (str, optional) – Path to a water body mask file with the dimensions of an MGRS tile.

  • multithread (bool, optional) – Should gdalwarp use multithreading? Default is True. The number of threads used, can be adjusted in the config.ini file with the parameter gdal_threads.

  • compress (str, optional) – Compression algorithm to use. See https://gdal.org/drivers/raster/gtiff.html#creation-options for options. Defaults to ‘LERC_DEFLATE’.

  • overviews (list[int], optional) – Internal overview levels to be created for each GeoTIFF file. Defaults to [2, 4, 9, 18, 36]

Returns

Either the time spent executing the function in seconds or ‘Already processed - Skip!’

Return type

str

S1_NRB.nrb.get_datasets(scenes, datadir, tile, extent, epsg)[source]

Identifies all source SLC scenes, finds matching output files processed with pyroSAR.snap.util.geocode() in datadir and filters both lists depending on the actual overlap of each SLC footprint with the current MGRS tile geometry.

Parameters
  • scenes (list[str]) – List of scenes to process. Either an individual scene or multiple, matching scenes (consecutive acquisitions).

  • datadir (str) – The directory containing the datasets processed from the source scenes using pyroSAR.

  • tile (str) – ID of an MGRS tile.

  • extent (dict) – Spatial extent of the MGRS tile, derived from a Vector object.

  • epsg (int) – The coordinate reference system as an EPSG code.

Returns

  • ids (list[pyroSAR.drivers.ID]) – List of ID objects of all source SLC scenes that overlap with the current MGRS tile.

  • datasets (list[str] or list[list[str]]) – List of output files processed with pyroSAR.snap.util.geocode() that match each ID object of ids. The format is a list of strings if only a single object is stored in ids, else it is a list of lists.

  • datamasks (list[str]) – List of raster datamask files covering the footprint of each source SLC scene that overlaps with the current MGRS tile.

ETAD

process

Apply ETAD correction to a Sentinel-1 SLC product.

S1_NRB.etad.process(scene, etad_dir, out_dir, log)[source]

Apply ETAD correction to a Sentinel-1 SLC product.

Parameters
  • scene (pyroSAR.drivers.ID) – The Sentinel-1 SLC scene.

  • etad_dir (str) – The directory containing ETAD products. This will be searched for products matching the defined SLC.

  • out_dir (str) – The directory to store results. The ETAD product is unpacked to this directory if necessary. Two new sub-directories SLC_original SLC_ETAD and are created, which contain the original unpacked scene and the corrected one respectively.

  • log (logging.Logger) – A logger object to write log info.

Returns

The corrected scene as a pyroSAR ID object.

Return type

pyroSAR.drivers.ID

DEM

mosaic

Create a new mosaic GeoTIFF file from MGRS-tiled DEMs as created by S1_NRB.dem.prepare().

prepare

Downloads DEM tiles and restructures them into the MGRS tiling scheme including re-projection and vertical datum conversion.

S1_NRB.dem.mosaic(geometry, dem_type, outname, epsg, kml_file, dem_dir)[source]

Create a new mosaic GeoTIFF file from MGRS-tiled DEMs as created by S1_NRB.dem.prepare().

Parameters
  • geometry (spatialist.vector.Vector) – The geometry to be covered by the mosaic.

  • dem_type (str) – The DEM type.

  • outname (str) – The name of the mosaic.

  • epsg (int) – The coordinate reference system as an EPSG code.

  • kml_file (str) – The KML file containing the MGRS tile geometries.

  • dem_dir (str) – The directory containing the DEM MGRS tiles.

S1_NRB.dem.prepare(geometries, dem_type, spacing, dem_dir, wbm_dir, kml_file, threads, epsg=None, username=None, password=None)[source]

Downloads DEM tiles and restructures them into the MGRS tiling scheme including re-projection and vertical datum conversion.

Parameters
  • geometries (list[spatialist.vector.Vector]) – A list of geometries for which to prepare the DEM tiles.

  • dem_type (str) – The DEM type.

  • spacing (int) – The target pixel spacing.

  • dem_dir (str) – The DEM target directory.

  • wbm_dir (str) – The WBM target directory.

  • kml_file (str) – The KML file containing the MGRS tile geometries.

  • threads (int) – The number of threads to pass to pyroSAR.auxdata.dem_create().

  • epsg (int, optional) – The coordinate reference system as an EPSG code.

  • username (str or None) – The username for accessing the DEM tiles. If None and authentication is required for the selected DEM type, the environment variable ‘DEM_USER’ is read. If this is not set, the user is prompted interactively to provide credentials.

  • password (str or None) – The password for accessing the DEM tiles. If None: same behavior as for username but with env. variable ‘DEM_PASS’.

Tile Extraction

aoi_from_tiles

Returns the bounding box of a list of MGRS tile IDs as a Vector object.

description2dict

Convert the HTML description field of the MGRS tile KML file to a dictionary.

extract_tile

Extract an MGRS tile from the global Sentinel-2 tiling grid and return it as a Vector object.

get_tile_dict

Creates a dictionary with information for each unique MGRS tile ID that is being processed (extent, epsg code) as well as alignment coordinates that can be passed to the standardGridOriginX and standardGridOriginY parameters of pyroSAR.snap.util.geocode()

tiles_from_aoi

Return a list of unique MGRS tile IDs that overlap with an area of interest (AOI) provided as a Vector object.

S1_NRB.tile_extraction.aoi_from_tiles(kml, tiles)[source]

Returns the bounding box of a list of MGRS tile IDs as a Vector object.

Parameters
  • kml (str) – Path to the Sentinel-2 tiling grid KML file.

  • tiles (list[str]) – A list of unique MGRS tile IDs.

Return type

spatialist.vector.Vector

Notes

The global Sentinel-2 tiling grid can be retrieved from: https://sentinel.esa.int/documents/247904/1955685/S2A_OPER_GIP_TILPAR_MPC__20151209T095117_V20150622T000000_21000101T000000_B00.kml

S1_NRB.tile_extraction.description2dict(description)[source]

Convert the HTML description field of the MGRS tile KML file to a dictionary.

Parameters

description (str) – The plain text of the Description field

Returns

attrib – A dictionary with keys ‘TILE_ID’, ‘EPSG’, ‘MGRS_REF’, ‘UTM_WKT’ and ‘LL_WKT’. The value of field ‘EPSG’ is of type integer, all others are strings.

Return type

dict

S1_NRB.tile_extraction.extract_tile(kml, tile)[source]

Extract an MGRS tile from the global Sentinel-2 tiling grid and return it as a Vector object.

Parameters
  • kml (str) – Path to the Sentinel-2 tiling grid KML file.

  • tile (str) – The MGRS tile ID that should be extracted and returned as a vector object. Can also be expressed as <tile ID>_<EPSG code> (e.g. 33TUN_32632). In this case the geometry of the tile is reprojected to the target EPSG code, its corner coordinates rounded to multiples of 10, and a new Vector object created.

Return type

spatialist.vector.Vector

Notes

The global Sentinel-2 tiling grid can be retrieved from: https://sentinel.esa.int/documents/247904/1955685/S2A_OPER_GIP_TILPAR_MPC__20151209T095117_V20150622T000000_21000101T000000_B00.kml

S1_NRB.tile_extraction.get_tile_dict(config, spacing)[source]

Creates a dictionary with information for each unique MGRS tile ID that is being processed (extent, epsg code) as well as alignment coordinates that can be passed to the standardGridOriginX and standardGridOriginY parameters of pyroSAR.snap.util.geocode()

Parameters
  • config (dict) – Dictionary of the parsed config parameters for the current process.

  • spacing (int) – The target pixel spacing in meters, which is passed to pyroSAR.snap.util.geocode().

Returns

tile_dict – The output dictionary containing information about each unique MGRS tile ID and alignment coordinates.

Return type

dict

S1_NRB.tile_extraction.tiles_from_aoi(vectorobject, kml, epsg=None, strict=True)[source]

Return a list of unique MGRS tile IDs that overlap with an area of interest (AOI) provided as a Vector object.

Parameters
  • vectorobject (spatialist.vector.Vector) – The vector object to read.

  • kml (str) – Path to the Sentinel-2 tiling grid kml file provided by ESA, which can be retrieved from: https://sentinels.copernicus.eu/web/sentinel/missions/sentinel-2/data-products

  • epsg (int or list[int] or None) – Define which EPSG code(s) are allowed for the tile selection. If None, all tile IDs are returned regardless of projection.

  • strict (bool) – Strictly only return the names of the overlapping tiles in the target projection or also allow reprojection of neighbouring tiles? In the latter case a tile name takes the form <tile ID>_<EPSG code>, e.g. 33TUN_32632. Only applies if argument epsg is of type int or a list with one element.

Returns

tiles – A list of unique MGRS tile IDs.

Return type

list[str]

Ancillary Functions

generate_unique_id

Returns a unique product identifier as a hexa-decimal string generated from the time of execution in isoformat.

get_max_ext

Gets the maximum extent from a list of geometries.

log

Format and handle log messages during processing.

set_logging

Set logging for the current process.

S1_NRB.ancillary.generate_unique_id(encoded_str)[source]

Returns a unique product identifier as a hexa-decimal string generated from the time of execution in isoformat. The CRC-16 algorithm used to compute the unique identifier is CRC-CCITT (0xFFFF).

Parameters

encoded_str (bytes) – A string that should be used to generate a unique id from. The string needs to be encoded; e.g.: ‘abc’.encode()

Returns

p_id – The unique product identifier.

Return type

str

S1_NRB.ancillary.get_max_ext(geometries, buffer=None)[source]

Gets the maximum extent from a list of geometries.

Parameters
Returns

max_ext – The maximum extent of the selected Vector geometries including the chosen buffer.

Return type

dict

S1_NRB.ancillary.log(handler, mode, proc_step, scenes, epsg, msg)[source]

Format and handle log messages during processing.

Parameters
  • handler (logging.Logger) – The log handler for the current process.

  • mode (str) – One of [‘info’, ‘warning’, ‘exception’]. Calls the respective logging helper function. E.g., handler.info().

  • proc_step (str) – The processing step for which the message is logged.

  • scenes (str or list[str]) – Scenes that are currently being processed.

  • epsg (int) – The coordinate reference system as an EPSG code.

  • msg (Any) – The massage that should be logged.

S1_NRB.ancillary.set_logging(config, debug=False)[source]

Set logging for the current process.

Parameters
  • config (dict) – Dictionary of the parsed config parameters for the current process.

  • debug (bool, optional) – Set pyroSAR logging level to DEBUG? Default is False.

Returns

log_local – The log handler for the current process.

Return type

logging.Logger

Metadata

Extraction

calc_performance_estimates

Calculates the performance estimates specified in CARD4L NRB 1.6.9 for all noise power images if available.

convert_coordinates

Converts footprint coordinates that have been retrieved from the metadata of source SLC scenes stored in an ID object OR a product extent retrieved using spatialist.vector.Vector.extent() to either envelop and center for usage in the XML metadata files or bbox and geometry for usage in STAC metadata files.

etree_from_sid

Retrieve the manifest and annotation XML data of a scene as a dictionary using an ID object.

extract_pslr_islr

Extracts all values for Peak Side Lobe Ratio (PSLR) and Integrated Side Lobe Ratio (ISLR) from the annotation metadata of a scene and calculates the mean value for all swaths.

find_in_annotation

Search for a pattern in all XML annotation files provided and return a dictionary of results.

get_header_size

Gets the header size of a GeoTIFF file in bytes.

get_prod_meta

Returns a metadata dictionary, which is generated from the name of a product scene using a regular expression pattern and from a measurement GeoTIFF file of the same product scene using the Raster class.

meta_dict

Creates a dictionary containing metadata for a product scene, as well as its source scenes.

vec_from_srccoords

Creates a single Vector object from a list of footprint coordinates of source scenes.

S1_NRB.metadata.extract.calc_performance_estimates(files, ref_tif)[source]

Calculates the performance estimates specified in CARD4L NRB 1.6.9 for all noise power images if available.

Parameters
  • files (list[str]) – List of paths pointing to the noise power images the estimates should be calculated for.

  • ref_tif (str) – A path pointing to a reference product raster, which is used to get spatial information about the current MGRS tile.

Returns

out – Dictionary containing the calculated estimates for each available polarization.

Return type

dict

S1_NRB.metadata.extract.convert_coordinates(coords, stac=False)[source]

Converts footprint coordinates that have been retrieved from the metadata of source SLC scenes stored in an ID object OR a product extent retrieved using spatialist.vector.Vector.extent() to either envelop and center for usage in the XML metadata files or bbox and geometry for usage in STAC metadata files. The latter is returned if the optional parameter stac is set to True, else the former is returned.

Parameters
  • coords (list[tuple(float, float)] or dict) – List of coordinate tuple pairs as retrieved from an ID objects of source SLC scenes OR the product extent retrieved using spatialist.vector.Vector.extent() in the form of a dictionary with keys: xmin, xmax, ymin, ymax

  • stac (bool, optional) – If set to True, bbox and geometry are returned for usage in STAC metadata file. If set to False (default) envelop and center are returned for usage in XML metadata files.

Returns

  • envelop (str) – Acquisition footprint coordinates for the XML element ‘eop:Footprint/multiExtentOf’.

  • center (str) – Acquisition center coordinates for the XML element ‘eop:Footprint/centerOf’.

Notes

If stac=True the following results are returned instead of envelop and center:

bbox: list[float]

Acquisition bounding box for usage in STAC Items. Formatted in accordance with RFC 7946, section 5: https://datatracker.ietf.org/doc/html/rfc7946#section-5

geometry: dict

Acquisition footprint geometry for usage in STAC Items. Formatted in accordance with RFC 7946, section 3.1.: https://datatracker.ietf.org/doc/html/rfc7946#section-3.1

S1_NRB.metadata.extract.etree_from_sid(sid)[source]

Retrieve the manifest and annotation XML data of a scene as a dictionary using an ID object.

Parameters

sid (pyroSAR.drivers.ID) – A pyroSAR ID object generated with pyroSAR.drivers.identify().

Returns

A dictionary containing the parsed etree.ElementTree objects for the manifest and annotation XML files.

Return type

dict

S1_NRB.metadata.extract.extract_pslr_islr(annotation_dict)[source]

Extracts all values for Peak Side Lobe Ratio (PSLR) and Integrated Side Lobe Ratio (ISLR) from the annotation metadata of a scene and calculates the mean value for all swaths.

Parameters

annotation_dict (dict) – A dictionary of annotation files in the form: {‘swath ID’:lxml.etree._Element object}

Returns

  • pslr (float) – Mean PSLR value for all swaths of the scene.

  • islr (float) – Mean ISLR value for all swaths of the scene.

S1_NRB.metadata.extract.find_in_annotation(annotation_dict, pattern, single=False, out_type='str')[source]

Search for a pattern in all XML annotation files provided and return a dictionary of results.

Parameters
  • annotation_dict (dict) – A dict of annotation files in the form: {‘swath ID’: lxml.etree._Element object}

  • pattern (str) – The pattern to search for in each annotation file.

  • single (bool, optional) – If True, the results found in each annotation file are expected to be the same and therefore only a single value will be returned instead of a dict. If the results differ, an error is raised. Default is False.

  • out_type (str, optional) –

    Output type to convert the results to. Can be one of the following:

    • str (default)

    • float

    • int

Returns

out – A dictionary of the results containing a list for each of the annotation files. E.g., {‘swath ID’: list[str, float or int]}

Return type

dict

S1_NRB.metadata.extract.get_header_size(tif)[source]

Gets the header size of a GeoTIFF file in bytes. The code used in this function and its helper function _get_block_offset were extracted from the following source:

https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/samples/validate_cloud_optimized_geotiff.py

Copyright (c) 2017, Even Rouault

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Parameters

tif (str) – A path to a GeoTIFF file of the currently processed NRB product.

Returns

header_size – The size of all IFD headers of the GeoTIFF file in bytes.

Return type

int

S1_NRB.metadata.extract.get_prod_meta(product_id, tif, src_ids, snap_outdir)[source]

Returns a metadata dictionary, which is generated from the name of a product scene using a regular expression pattern and from a measurement GeoTIFF file of the same product scene using the Raster class.

Parameters
  • product_id (str) – The top-level product folder name.

  • tif (str) – The path to a measurement GeoTIFF file of the product scene.

  • src_ids (list[pyroSAR.drivers.ID]) – List of ID objects of all source SLC scenes that overlap with the current MGRS tile.

  • snap_outdir (str) – A path pointing to the SNAP processed datasets of the product.

Returns

A dictionary containing metadata for the product scene.

Return type

dict

S1_NRB.metadata.extract.meta_dict(target, src_ids, snap_datasets, dem_type, proc_time, start, stop, compression)[source]

Creates a dictionary containing metadata for a product scene, as well as its source scenes. The dictionary can then be utilized by parse() and parse() to generate XML and STAC JSON metadata files, respectively.

Parameters
  • target (str) – A path pointing to the NRB product scene being created.

  • src_ids (list[pyroSAR.drivers.ID]) – List of ID objects of all source scenes that overlap with the current MGRS tile.

  • snap_datasets (list[str]) – List of output files processed with pyroSAR.snap.util.geocode() that match the source SLC scenes overlapping with the current MGRS tile.

  • dem_type (str) – The DEM type used for processing.

  • proc_time (datetime.datetime) – The processing time object used to generate the unique product identifier.

  • start (datetime.datetime) – The product start time.

  • stop (datetime.datetime) – The product stop time.

  • compression (str) – The compression type applied to raster files of the product.

Returns

meta – A dictionary containing a collection of metadata for product as well as source scenes.

Return type

dict

S1_NRB.metadata.extract.vec_from_srccoords(coord_list)[source]

Creates a single Vector object from a list of footprint coordinates of source scenes.

Parameters

coord_list (list[list[tuple(float, float)]]) – List containing for each source scene a list of coordinate pairs as retrieved from the metadata stored in an ID object.

Return type

spatialist.vector.Vector

XML

parse

Wrapper for source_xml() and product_xml().

product_xml

Function to generate product-level metadata for an NRB product in OGC 10-157r4 compliant XML format.

source_xml

Function to generate source-level metadata for an NRB product in OGC 10-157r4 compliant XML format.

S1_NRB.metadata.xml.parse(meta, target, tifs, exist_ok=False)[source]

Wrapper for source_xml() and product_xml().

Parameters
  • meta (dict) – Metadata dictionary generated with meta_dict().

  • target (str) – A path pointing to the root directory of a product scene.

  • tifs (list[str]) – List of paths to all GeoTIFF files of the currently processed NRB product.

  • exist_ok (bool, optional) – Do not create files if they already exist?

S1_NRB.metadata.xml.product_xml(meta, target, tifs, nsmap, exist_ok=False)[source]

Function to generate product-level metadata for an NRB product in OGC 10-157r4 compliant XML format.

Parameters
  • meta (dict) – Metadata dictionary generated with meta_dict()

  • target (str) – A path pointing to the root directory of a product scene.

  • tifs (list[str]) – List of paths to all GeoTIFF files of the currently processed NRB product.

  • nsmap (dict) – Dictionary listing abbreviation (key) and URI (value) of all necessary XML namespaces.

  • exist_ok (bool, optional) – Do not create files if they already exist?

S1_NRB.metadata.xml.source_xml(meta, target, nsmap, exist_ok=False)[source]

Function to generate source-level metadata for an NRB product in OGC 10-157r4 compliant XML format.

Parameters
  • meta (dict) – Metadata dictionary generated with meta_dict()

  • target (str) – A path pointing to the root directory of a product scene.

  • nsmap (dict) – Dictionary listing abbreviation (key) and URI (value) of all necessary XML namespaces.

  • exist_ok (bool, optional) – Do not create files if they already exist?

STAC

parse

Wrapper for source_json() and product_json().

product_json

Function to generate product-level metadata for an NRB product in STAC compliant JSON format.

source_json

Function to generate source-level metadata for an NRB product in STAC compliant JSON format.

make_catalog

For a given directory of Sentinel-1 NRB products, this function will create a high-level STAC Catalog object serving as the STAC endpoint and lower-level STAC Collection objects for each subdirectory corresponding to a unique MGRS tile ID.

S1_NRB.metadata.stac.make_catalog(directory, recursive=True, silent=False)[source]

For a given directory of Sentinel-1 NRB products, this function will create a high-level STAC Catalog object serving as the STAC endpoint and lower-level STAC Collection objects for each subdirectory corresponding to a unique MGRS tile ID.

WARNING: The directory content will be reorganized into subdirectories based on unique MGRS tile IDs if this is not yet the case.

Parameters
  • directory (str) – Path to a directory that contains Sentinel-1 NRB products.

  • recursive (bool, optional) – Search for NRB products in directory recursively? Default is True.

  • silent (bool, optional) – Should the output during directory reorganization be suppressed? Default is False.

Returns

nrb_catalog – STAC Catalog object

Return type

pystac.catalog.Catalog

Notes

The returned STAC Catalog object contains Item asset hrefs that are absolute, whereas the actual on-disk files contain relative asset hrefs corresponding to the self-contained Catalog-Type. The returned in-memory STAC Catalog object deviates in this regard to ensure compatibility with the stackstac library: https://github.com/gjoseph92/stackstac/issues/20

S1_NRB.metadata.stac.parse(meta, target, tifs, exist_ok=False)[source]

Wrapper for source_json() and product_json().

Parameters
  • meta (dict) – Metadata dictionary generated with meta_dict()

  • target (str) – A path pointing to the root directory of a product scene.

  • tifs (list[str]) – List of paths to all GeoTIFF files of the currently processed NRB product.

  • exist_ok (bool, optional) – Do not create files if they already exist?

S1_NRB.metadata.stac.product_json(meta, target, tifs, exist_ok=False)[source]

Function to generate product-level metadata for an NRB product in STAC compliant JSON format.

Parameters
  • meta (dict) – Metadata dictionary generated with meta_dict().

  • target (str) – A path pointing to the root directory of a product scene.

  • tifs (list[str]) – List of paths to all GeoTIFF files of the currently processed NRB product.

  • exist_ok (bool, optional) – Do not create files if they already exist?

S1_NRB.metadata.stac.source_json(meta, target, exist_ok=False)[source]

Function to generate source-level metadata for an NRB product in STAC compliant JSON format.

Parameters
  • meta (dict) – Metadata dictionary generated with meta_dict().

  • target (str) – A path pointing to the root directory of a product scene.

  • exist_ok (bool, optional) – Do not create files if they already exist?