pyroSAR/ancillary.py
def groupby(images, attribute):
    """
    group a list of images by a metadata attribute
    
    Parameters
    ----------
    images: list of str
        the names of the images to be sorted
    attribute: str
        the name of the attribute used for sorting;
        see :func:`parse_datasetname` for options
    
    Returns
    -------
    list of lists
        a list containing a list with image names ofr each group
    """
    images_sort = sorted(images, key=lambda x: re.search(product_pattern, x).group(attribute))
    out_meta = [[parse_datasetname(images_sort.pop(0))]]
    while len(images_sort) > 0:
        filename = images_sort.pop(0)
        meta = parse_datasetname(filename)

        if out_meta[-1][0][attribute] == meta[attribute]:
            out_meta[-1].append(meta)
        else:
            out_meta.append([meta])
    out = [[x['filename'] for x in y] for y in out_meta]
    return out

    group a list of images by a metadata attribute
    
    Parameters
    ----------
    images: list of str
        the names of the images to be sorted
    attribute: str
        the name of the attribute used for sorting;
        see :func:`parse_datasetname` for options
    
    Returns
    -------
    list of lists
        a list containing a list with image names ofr each group
    
group a list of images by a metadata attribute
Parameters

list of str
the names of the images to be sorted
attribute: str
the name of the attribute used for sorting;
see :func:`parse_datasetname` for options

Returns

list of lists
a list containing a list with image names ofr each group
group a list of images by a metadata attribute Parameters list of str the names of the images to be sorted attribute : str the name of the attribute used for sorting ; see : func : ` parse_datasetname ` for options Returns list of lists a list containing a list with image names ofr each group
def groupby(images, attribute):
    images_sort = sorted(images, key=lambda x: re.search(product_pattern, x).group(attribute))
    out_meta = [[parse_datasetname(images_sort.pop(0))]]
    while len(images_sort) > 0:
        filename = images_sort.pop(0)
        meta = parse_datasetname(filename)
        if out_meta[-1][0][attribute] == meta[attribute]:
            out_meta[-1].append(meta)
        else:
            out_meta.append([meta])
    out = [[x['filename'] for x in y] for y in out_meta]
    return out
def groupby ( images , attribute ) : images_sort = sorted ( images , key = lambda x : re . search ( product_pattern , x ) . group ( attribute ) ) out_meta = [ [ parse_datasetname ( images_sort . pop ( 0 ) ) ] ] while len ( images_sort ) > 0 : filename = images_sort . pop ( 0 ) meta = parse_datasetname ( filename ) if out_meta [ - 1 ] [ 0 ] [ attribute ] == meta [ attribute ] : out_meta [ - 1 ] . append ( meta ) else : out_meta . append ( [ meta ] ) out = [ [ x [ 'filename' ] for x in y ] for y in out_meta ] return out
group a list of images by a metadata attribute
Parameters
group a list of images by a metadata attribute Parameters
"""
    group a list of images by a metadata attribute
    
    Parameters
    ----------
    images: list of str
        the names of the images to be sorted
    attribute: str
        the name of the attribute used for sorting;
        see :func:`parse_datasetname` for options
    
    Returns
    -------
    list of lists
        a list containing a list with image names ofr each group
    """
images
attribute