Ancillary Functions¶
This module gathers central functions and classes for general pyroSAR applications.
find pyroSAR datasets in a directory based on their metadata |
|
get the arguments of a function |
|
group a list of images by a metadata attribute |
|
function to group images by their acquisition time difference |
|
simple check whether a function takes a parameter as input |
|
compute multi-looking factors to approximate a square pixel with defined target ground range pixel spacing. |
|
Parse the name of a pyroSAR processing product and extract its metadata components as dictionary |
|
function to extract time in seconds from a file name. |
- pyroSAR.ancillary.find_datasets(directory, recursive=False, **kwargs)[source]¶
find pyroSAR datasets in a directory based on their metadata
- Parameters
directory (str) – the name of the directory to be searched
recursive (bool) – search the directory recursively into subdirectories?
kwargs – Metadata attributes for filtering the scene list supplied as key=value. e.g. sensor=’S1A’. Multiple allowed options can be provided in tuples, e.g. sensor=(‘S1A’, ‘S1B’). Any types other than tuples require an exact match, e.g. proc_steps=[‘grd’, ‘mli’, ‘geo’, ‘norm’, ‘db’] will be matched only if these processing steps are contained in the product name in this exact order. The special attributes start and stop can be used for time filtering where start<=value<=stop. See function
parse_datasetname()
for further options.
- Returns
the file names found in the directory and filtered by metadata attributes
- Return type
Examples
>>> selection = find_datasets('path/to/files', sensor=('S1A', 'S1B'), polarization='VV')
- pyroSAR.ancillary.groupby(images, attribute)[source]¶
group a list of images by a metadata attribute
- pyroSAR.ancillary.groupbyTime(images, function, time)[source]¶
function to group images by their acquisition time difference
- Parameters
- Returns
a list of sub-lists containing the grouped images
- Return type
- pyroSAR.ancillary.hasarg(func, arg)[source]¶
simple check whether a function takes a parameter as input
- pyroSAR.ancillary.multilook_factors(source_rg, source_az, target, geometry, incidence)[source]¶
compute multi-looking factors to approximate a square pixel with defined target ground range pixel spacing.
- Parameters
- Returns
the multi-looking factors as (range looks, azimuth looks)
- Return type
Examples
>>> from pyroSAR.ancillary import multilook_factors >>> rlks, azlks = multilook_factors(source_rg=2, source_az=13, target=10, >>> geometry='SLANT_RANGE', incidence=39) >>> print(rlks, azlks) 4 1
- pyroSAR.ancillary.parse_datasetname(name, parse_date=False)[source]¶
Parse the name of a pyroSAR processing product and extract its metadata components as dictionary
- Parameters
- Returns
the metadata attributes
- Return type
Examples
>>> meta = parse_datasetname('S1A__IW___A_20150309T173017_VV_grd_mli_geo_norm_db.tif') >>> print(sorted(meta.keys())) ['acquisition_mode', 'extensions', 'filename', 'orbit', 'outname_base', 'polarization', 'proc_steps', 'sensor', 'start']
- pyroSAR.ancillary.seconds(filename)[source]¶
function to extract time in seconds from a file name. the format must follow a fixed pattern: YYYYmmddTHHMMSS Images processed with pyroSAR functionalities via module snap or gamma will contain this information.
- pyroSAR.ancillary.windows_fileprefix(func, path, exc_info)[source]¶
Helper function for
shutil.rmtree()
to exceed Windows’ file name length limit of 256 characters. See here for details.- Parameters
func (function) – the function to be executed, i.e.
shutil.rmtree()
path (str) – the path to be deleted
exc_info (tuple) – execution info as returned by
sys.exc_info()
Examples
>>> import shutil >>> from pyroSAR.ancillary import windows_fileprefix >>> shutil.rmtree('/path', onerror=windows_fileprefix)