pyroSAR/ancillary.py
def parse_datasetname(name, parse_date=False):
    """
    Parse the name of a pyroSAR processing product and extract its metadata components as dictionary
    
    Parameters
    ----------
    name: str
        the name of the file to be parsed
    parse_date: bool
        parse the start date to a :class:`~datetime.datetime` object or just return the string?
    
    Returns
    -------
    dict
        the metadata attributes
    
    Examples
    --------
    >>> meta = parse_datasetname('S1A__IW___A_20150309T173017_VV_grd_mli_geo_norm_db.tif')
    >>> print(list(meta.keys()))
    ['sensor', 'acquisition_mode', 'orbit', 'start', 'extensions', 'polarization', 'proc_steps']
    """
    
    filename = os.path.realpath(name)
    
    match = re.match(re.compile(product_pattern), filename)
    if not match:
        return
    out = match.groupdict()
    if out['extensions'] == '':
        out['extensions'] = None
    if len(out['proc_steps']) > 0:
        out['proc_steps'] = out['proc_steps'].split('_')
    else:
        out['proc_steps'] = None
    if parse_date:
        out['start'] = datetime.strptime(out['start'], '%Y%m%dT%H%M%S')
    out['filename'] = filename
    return out

    Parse the name of a pyroSAR processing product and extract its metadata components as dictionary
    
    Parameters
    ----------
    name: str
        the name of the file to be parsed
    parse_date: bool
        parse the start date to a :class:`~datetime.datetime` object or just return the string?
    
    Returns
    -------
    dict
        the metadata attributes
    
    Examples
    --------
    >>> meta = parse_datasetname('S1A__IW___A_20150309T173017_VV_grd_mli_geo_norm_db.tif')
    >>> print(list(meta.keys()))
    ['sensor', 'acquisition_mode', 'orbit', 'start', 'extensions', 'polarization', 'proc_steps']
    
Parse the name of a pyroSAR processing product and extract its metadata components as dictionary
Parameters



Returns

dict
the metadata attributes

Examples


Parse the name of a pyroSAR processing product and extract its metadata components as dictionary Parameters Returns dict the metadata attributes Examples
def parse_datasetname(name, parse_date=False):
    filename = os.path.realpath(name)
    match = re.match(re.compile(product_pattern), filename)
    if not match:
        return
    out = match.groupdict()
    if out['extensions'] == '':
        out['extensions'] = None
    if len(out['proc_steps']) > 0:
        out['proc_steps'] = out['proc_steps'].split('_')
    else:
        out['proc_steps'] = None
    if parse_date:
        out['start'] = datetime.strptime(out['start'], '%Y%m%dT%H%M%S')
    out['filename'] = filename
    return out
def parse_datasetname ( name , parse_date = False ) : filename = os . path . realpath ( name ) match = re . match ( re . compile ( product_pattern ) , filename ) if not match : return out = match . groupdict ( ) if out [ 'extensions' ] == '' : out [ 'extensions' ] = None if len ( out [ 'proc_steps' ] ) > 0 : out [ 'proc_steps' ] = out [ 'proc_steps' ] . split ( '_' ) else : out [ 'proc_steps' ] = None if parse_date : out [ 'start' ] = datetime . strptime ( out [ 'start' ] , '%Y%m%dT%H%M%S' ) out [ 'filename' ] = filename return out
Parse the name of a pyroSAR processing product and extract its metadata components as dictionary
Parameters
Parse the name of a pyroSAR processing product and extract its metadata components as dictionary Parameters
"""
    Parse the name of a pyroSAR processing product and extract its metadata components as dictionary
    
    Parameters
    ----------
    name: str
        the name of the file to be parsed
    parse_date: bool
        parse the start date to a :class:`~datetime.datetime` object or just return the string?
    
    Returns
    -------
    dict
        the metadata attributes
    
    Examples
    --------
    >>> meta = parse_datasetname('S1A__IW___A_20150309T173017_VV_grd_mli_geo_norm_db.tif')
    >>> print(list(meta.keys()))
    ['sensor', 'acquisition_mode', 'orbit', 'start', 'extensions', 'polarization', 'proc_steps']
    """
name
parse_date