pyroSAR/ancillary.py
def find_datasets(directory, recursive=False, **kwargs):
    """
    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 if only these processing steps are contained in the product name in this exact order.
        See function :func:`parse_productname` for options.
    
    Returns
    -------
    list of str
        the file names found in the directory and filtered by metadata attributes
    
    Examples
    --------
    >>> selection = find_datasets('path/to/files', sensor=('S1A', 'S1B'), polarization='VV')
    """
    files = finder(directory, [product_pattern], regex=True, recursive=recursive)
    selection = []
    for file in files:
        meta = parse_datasetname(file)
        match = True
        for key, val in kwargs.items():
            if isinstance(val, tuple):
                match = meta[key] in val
            else:
                match = meta[key] == val
        if match:
            selection.append(file)
    return selection

    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 if only these processing steps are contained in the product name in this exact order.
        See function :func:`parse_productname` for options.
    
    Returns
    -------
    list of str
        the file names found in the directory and filtered by metadata attributes
    
    Examples
    --------
    >>> selection = find_datasets('path/to/files', sensor=('S1A', 'S1B'), polarization='VV')
    
find pyroSAR datasets in a directory based on their metadata
Parameters

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`.

Returns

list of str
the file names found in the directory and filtered by metadata attributes

Examples


find pyroSAR datasets in a directory based on their metadata Parameters 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 ` . Returns list of str the file names found in the directory and filtered by metadata attributes Examples
def find_datasets(directory, recursive=False, **kwargs):
    files = finder(directory, [product_pattern], regex=True, recursive=recursive)
    selection = []
    for file in files:
        meta = parse_datasetname(file)
        match = True
        for key, val in kwargs.items():
            if isinstance(val, tuple):
                match = meta[key] in val
            else:
                match = meta[key] == val
        if match:
            selection.append(file)
    return selection
def find_datasets ( directory , recursive = False , ** kwargs ) : files = finder ( directory , [ product_pattern ] , regex = True , recursive = recursive ) selection = [ ] for file in files : meta = parse_datasetname ( file ) match = True for key , val in kwargs . items ( ) : if isinstance ( val , tuple ) : match = meta [ key ] in val else : match = meta [ key ] == val if match : selection . append ( file ) return selection
find pyroSAR datasets in a directory based on their metadata
Parameters
find pyroSAR datasets in a directory based on their metadata Parameters
"""
    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 if only these processing steps are contained in the product name in this exact order.
        See function :func:`parse_productname` for options.
    
    Returns
    -------
    list of str
        the file names found in the directory and filtered by metadata attributes
    
    Examples
    --------
    >>> selection = find_datasets('path/to/files', sensor=('S1A', 'S1B'), polarization='VV')
    """
directory
recursive