Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRD buffering #73

Merged
merged 4 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions S1_NRB/ancillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def set_logging(config, debug=False):
----------
config: dict
Dictionary of the parsed config parameters for the current process.
debug: bool, optional
debug: bool
Set pyroSAR logging level to DEBUG? Default is False.

Returns
Expand Down Expand Up @@ -275,7 +275,7 @@ def _log_process_config(logger, config):

Parameters
----------
logger: Logger
logger: logging.Logger
The logger to which the header is added to.
config: dict
Dictionary of the parsed config parameters for the current process.
Expand Down Expand Up @@ -344,7 +344,7 @@ def log(handler, mode, proc_step, scenes, msg):
scenes: str or list[str]
Scenes that are currently being processed.
msg: Any
The massage that should be logged.
The message that should be logged.
"""
proc_step = proc_step.zfill(7).replace('0', ' ')
message = '[{proc_step}] -- {scenes} -- {msg}'
Expand Down
6 changes: 3 additions & 3 deletions S1_NRB/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ def mosaic(geometry, dem_type, outname, epsg=None, kml_file=None,
The DEM type.
outname: str
The name of the mosaic.
epsg: int
epsg: int or None
The coordinate reference system as an EPSG code.
kml_file: str
kml_file: str or None
The KML file containing the MGRS tile geometries.
dem_dir: str
dem_dir: str or None
The directory containing the DEM MGRS tiles.
username: str or None
The username for accessing the DEM tiles. If None and authentication is required
Expand Down
33 changes: 17 additions & 16 deletions S1_NRB/metadata/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def vec_from_srccoords(coord_list):

Parameters
----------
coord_list: list[list[tuple(float, float)]]
coord_list: list[list[tuple[float]]]
List containing for each source scene a list of coordinate pairs as retrieved from the metadata stored in an
:class:`~pyroSAR.drivers.ID` object.

Expand Down Expand Up @@ -126,13 +126,13 @@ def vec_from_srccoords(coord_list):

def etree_from_sid(sid):
"""
Retrieve the manifest and annotation XML data of a scene as a dictionary using an :class:`~pyroSAR.drivers.ID`
Retrieve the manifest and annotation XML data of a scene as a dictionary using an :class:`pyroSAR.drivers.ID`
object.

Parameters
----------
sid: :class:`pyroSAR.drivers.ID`
A pyroSAR :class:`~pyroSAR.drivers.ID` object generated with :func:`pyroSAR.drivers.identify`.
sid: pyroSAR.drivers.ID
A pyroSAR :class:`~pyroSAR.drivers.ID` object generated with e.g. :func:`pyroSAR.drivers.identify`.

Returns
-------
Expand Down Expand Up @@ -163,13 +163,13 @@ def geometry_from_vec(vectorobject):

Parameters
----------
vectorobject: :class:`spatialist.vector.Vector`
vectorobject: spatialist.vector.Vector
The vector object to extract geometry information from.

Returns
-------
out: dict
A dictionary containing the geometry information extracted from the vectorobject.
A dictionary containing the geometry information extracted from the vector object.
"""
out = {}
vec = vectorobject
Expand Down Expand Up @@ -206,21 +206,21 @@ def find_in_annotation(annotation_dict, pattern, single=False, out_type='str'):
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
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. If the results differ, an error is raised. Default is False.
out_type: str, optional
out_type: str
Output type to convert the results to. Can be one of the following:

- str (default)
- float
- int
- 'str' (default)
- 'float'
- 'int'

Returns
-------
out: dict
A dictionary of the results containing a list for each of the annotation files. E.g.,
{'swath ID': list[str, float or int]}
{'swath ID': list[str or float or int]}
"""
out = {}
for s, a in annotation_dict.items():
Expand Down Expand Up @@ -305,10 +305,11 @@ def extract_pslr_islr(annotation_dict):

Returns
-------
pslr: float
Mean PSLR value for all swaths of the scene.
islr: float
Mean ISLR value for all swaths of the scene.
tuple[float]
a tuple with the following values:

- pslr: Mean PSLR value for all swaths of the scene.
- islr: Mean ISLR value for all swaths of the scene.
"""
swaths = list(annotation_dict.keys())
pslr_dict = find_in_annotation(annotation_dict=annotation_dict, pattern='.//crossCorrelationPslr', out_type='float')
Expand Down
16 changes: 8 additions & 8 deletions S1_NRB/metadata/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def product_json(meta, target, tifs, exist_ok=False):
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
exist_ok: bool
Do not create files if they already exist?
"""
scene_id = os.path.basename(target)
Expand Down Expand Up @@ -308,7 +308,7 @@ def source_json(meta, target, exist_ok=False):
Metadata dictionary generated with :func:`~S1_NRB.metadata.extract.meta_dict`.
target: str
A path pointing to the root directory of a product scene.
exist_ok: bool, optional
exist_ok: bool
Do not create files if they already exist?
"""
metadir = os.path.join(target, 'source')
Expand Down Expand Up @@ -458,7 +458,7 @@ def parse(meta, target, tifs, exist_ok=False):
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
exist_ok: bool
Do not create files if they already exist?
"""
source_json(meta=meta, target=target, exist_ok=exist_ok)
Expand All @@ -478,9 +478,9 @@ def make_catalog(directory, recursive=True, silent=False):
----------
directory: str
Path to a directory that contains Sentinel-1 NRB products.
recursive: bool, optional
recursive: bool
Search for NRB products in `directory` recursively? Default is True.
silent: bool, optional
silent: bool
Should the output during directory reorganization be suppressed? Default is False.

Returns
Expand Down Expand Up @@ -574,11 +574,11 @@ def _reorganize_by_tile(directory, products=None, recursive=True, silent=False):
----------
directory: str
Path to a directory that contains Sentinel-1 NRB products.
products: list[str], optional
products: list[str] or None
List of NRB product paths. Will be created from `directory` if not provided.
recursive: bool, optional
recursive: bool
Search for NRB products in `directory` recursively? Default is True.
silent: bool, optional
silent: bool
If False (default), a message for each NRB product is printed if it has been moved to a new location or not.

Returns
Expand Down
16 changes: 8 additions & 8 deletions S1_NRB/metadata/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _om_time(root, nsmap, scene_id, time_start, time_stop):

Parameters
----------
root: etree.Element
root: lxml.etree.Element
Root XML element.
nsmap: dict
Dictionary listing abbreviation (key) and URI (value) of all necessary XML namespaces.
Expand Down Expand Up @@ -53,17 +53,17 @@ def _om_procedure(root, nsmap, scene_id, meta, uid=None, prod=True):

Parameters
----------
root: etree.Element
root: lxml.etree.Element
Root XML element.
nsmap: dict
Dictionary listing abbreviation (key) and URI (value) of all necessary XML namespaces.
scene_id: str
Scene basename.
meta: dict
Metadata dictionary generated with :func:`~S1_NRB.metadata.extract.meta_dict`
uid: str, optional
uid: str or None
Unique identifier of a source SLC scene.
prod: bool, optional
prod: bool
Return XML subelements for further usage in :func:`~S1_NRB.metadata.xml.product_xml` parsing function?
Default is True. If False, the XML subelements for further usage in the :func:`~S1_NRB.metadata.xml.source_xml`
parsing function will be returned.
Expand Down Expand Up @@ -167,7 +167,7 @@ def _om_feature_of_interest(root, nsmap, scene_id, extent, center):

Parameters
----------
root: etree.Element
root: lxml.etree.Element
Root XML element.
nsmap: dict
Dictionary listing abbreviation (key) and URI (value) of all necessary XML namespaces.
Expand Down Expand Up @@ -213,7 +213,7 @@ def product_xml(meta, target, tifs, nsmap, exist_ok=False):
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
exist_ok: bool
Do not create files if they already exist?
"""
scene_id = os.path.basename(target)
Expand Down Expand Up @@ -484,7 +484,7 @@ def source_xml(meta, target, nsmap, exist_ok=False):
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
exist_ok: bool
Do not create files if they already exist?
"""
metadir = os.path.join(target, 'source')
Expand Down Expand Up @@ -653,7 +653,7 @@ def parse(meta, target, tifs, exist_ok=False):
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
exist_ok: bool
Do not create files if they already exist?
"""
NS_MAP_prod = deepcopy(NS_MAP)
Expand Down
32 changes: 16 additions & 16 deletions S1_NRB/nrb.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def format(config, scenes, datadir, outdir, tile, extent, epsg, wbm=None,
Spatial extent of the MGRS tile, derived from a :class:`~spatialist.vector.Vector` object.
epsg: int
The CRS used for the NRB product; provided as an EPSG code.
wbm: str, optional
wbm: str or None
Path to a water body mask file with the dimensions of an MGRS tile.
multithread: bool, optional
multithread: bool
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
compress: str or None
Compression algorithm to use. See https://gdal.org/drivers/raster/gtiff.html#creation-options for options.
Defaults to 'LERC_DEFLATE'.
overviews: list[int], optional
overviews: list[int] or None
Internal overview levels to be created for each GeoTIFF file. Defaults to [2, 4, 9, 18, 36]

Returns
Expand Down Expand Up @@ -350,22 +350,22 @@ def create_vrt(src, dst, fun, relpaths=False, scale=None, offset=None, args=None
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
relpaths: bool
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
scale: int or None
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
offset: float or None
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'`.
args: dict, optional
args: dict or None
arguments for `fun` passed as `PixelFunctionArguments`. Requires GDAL>=3.5 to be read.
options: dict, optional
options: dict or None
Additional parameters passed to `gdal.BuildVRT`.
overviews: list[int], optional
overviews: list[int] or None
Internal overview levels to be created for each raster file.
overview_resampling: str, optional
overview_resampling: str or None
Resampling method for overview levels.

Examples
Expand Down Expand Up @@ -556,10 +556,10 @@ def calc_product_start_stop(src_ids, extent, epsg):

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.
tuple[str]

- Start time of the NRB product formatted as `%Y%m%dT%H%M%S` in UTC.
- Stop time of the NRB product formatted as `%Y%m%dT%H%M%S` in UTC.
"""
with bbox(extent, epsg) as tile_geom:
tile_geom.reproject(4326)
Expand Down Expand Up @@ -658,7 +658,7 @@ def create_data_mask(outname, datasets, extent, epsg, driver, creation_opt,
Resampling method for overview levels.
dst_nodata: int or str
Nodata value to write to the output raster.
wbm: str, optional
wbm: str or None
Path to a water body mask file with the dimensions of an MGRS tile.
"""
print(outname)
Expand Down
Loading