API Documentation

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 file as a dictionary.

ERS_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

ERS_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

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

Returns the content of a config 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

Ancillary Functions

Metadata

Extraction

calc_performance_estimates

Calculates the performance estimates specified in CARD4L NRB 1.6.9 for all noise power images for the current MGRS tile.

etree_from_sid

Uses a pyroSAR metadata handler to get the parsed manifest and annotation XML data as a dictionary.

find_in_annotation

Find a pattern in each annotation file provided and returns a list of results converted in

get_prod_meta

Returns a metadata dictionary, which is generated from the ID of a product scene using a regular expression pattern and from a measurement GeoTIFF file of the same product scene using spatialist's 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 spatialist.vector.Vector object from a list of footprint coordinates of source scenes.

ERS_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 for the current MGRS tile.

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 product GeoTIFF file, 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

ERS_NRB.metadata.extract.convert_id_coordinates(coords, stac=False)[source]

Converts a list of coordinate pairs as retrieved by pyroSAR’s identify function 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)]) – List of coordinate pairs as retrieved by pyroSAR.drivers.identify from source scenes

  • stac (bool, optional) – If set to True, bbox and geometry are returned for usage in STAC Items. 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 field ‘multiExtentOf’ in ‘eop:Footprint’

  • center (str) – Acquisition center coordinates for the XML field ‘centerOf’ in ‘eop:Footprint’

Notes

If stac=True the following parameters 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: GeoJSON Geometry Object

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

ERS_NRB.metadata.extract.convert_spatialist_extent(extent)[source]

Converts the extent of a spatialist vector object to bbox and geometry as required for the usage in STAC Items: https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#item-fields

Parameters

extent (dict) – The extent of a vector object as returned by spatialist.vector.Vector.extent

Returns

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

Uses a pyroSAR metadata handler to get the parsed manifest and annotation XML data as a dictionary.

Parameters

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

Returns

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

Return type

dict

ERS_NRB.metadata.extract.find_in_annotation(annotation_dict, pattern, single=False, out_type=None)[source]

Find a pattern in each annotation file provided and returns a list of results converted in

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) – 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. 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 dict of the results containing a list for each of the annotation files. I.e., {‘swath ID’: list[str, float or int]}

Return type

dict

ERS_NRB.metadata.extract.get_prod_meta(product_id, tif, src_scenes)[source]

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

Parameters
  • product_id (str) – The product ID (filename) of the product scene.

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

  • src_scenes (list[str]) – A list of paths pointing to the source scenes of the product.

Returns

A dictionary containing metadata for the product scene.

Return type

dict

ERS_NRB.metadata.extract.get_uid_sid(filepath)[source]

Returns the unique identifier of a Sentinel-1 scene and a pyroSAR metadata handler generated using pyroSAR.drivers.identify

Parameters

filepath (str) – Filepath pointing to a Sentinel-1 scene.

Returns

  • uid (str) – The last four characters of a Sentinel-1 filename, which is the unique identifier of the scene.

  • sid (pyroSAR.drivers.ID subclass object) – A pyroSAR metadata handler for the scene generated with pyroSAR.drivers.identify.

ERS_NRB.metadata.extract.meta_dict(config, target, src_scenes, src_files, proc_time)[source]

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

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

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

  • src_scenes (list[str]) – A list of paths pointing to the source scenes of the product.

  • src_files (list[str]) – A list of paths pointing to the SNAP processed datasets of the product.

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

Returns

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

Return type

dict

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

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

Parameters

coord_list (list[list[tuple(float, float)]]) – List containing (for n source scenes) a list of coordinate pairs as retrieved by pyroSAR.drivers.identify

Return type

spatialist.vector.Vector object

STAC

product_json

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

source_json

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

ERS_NRB.metadata.stacparser.main(meta, target, tifs)[source]

Wrapper for source_json and product_json.

Parameters
  • meta (dict) – Metadata dictionary generated with metadata.extract.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.

Return type

None

ERS_NRB.metadata.stacparser.product_json(meta, target, tifs)[source]

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

Parameters
  • meta (dict) – Metadata dictionary generated with metadata.extract.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.

Return type

None

ERS_NRB.metadata.stacparser.source_json(meta, target)[source]

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

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

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

Return type

None