geopathfinder.naming_conventions namespace

Submodules

geopathfinder.naming_conventions.acube_naming module

ACube file name definition.

class geopathfinder.naming_conventions.acube_naming.ACubeFilename(fields, ext='.tif', convert=False, compact=False)[source]

Bases: SmartFilename

ACube file name definition using SmartFilename class.

decode_date(string)[source]

Decodes a string into a datetime.date object. The format is given by the class.

Parameters:

string (str, object) – String needed to be decoded to a datetime.date object.

Returns:

Original object or datetime.date object parsed from the given string.

Return type:

datetime.date, object

decode_time(string)[source]

Decodes a string into a datetime.time/datetime.date object. The format is given by the class and the conversion follows the ‘single_date’ setting.

Parameters:

string (str, object) – String needed to be decoded to a datetime.time/datetime.date object.

Returns:

Original object, datetime.date or datetime.time object parsed from the given string.

Return type:

datetime.date, datetime.time, object

delimiter = '_'
encode_date(time_obj)[source]

Encodes a datetime.datetime/datetime.date object into a string. The format is given by the class.

Parameters:

time_obj (datetime.datetime, datetime.date or object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

encode_time(time_obj)[source]

Encodes a datetime.datetime/datetime.date object into a string. The format is given by the class.

Parameters:

time_obj (datetime.datetime, datetime.date or object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

property etime

End time.

Returns:

End time.

Return type:

datetime.datetime

fields_def = {'algorithm': {'len': 7}, 'direction': {'len': 1}, 'dtime_1': {'len': 8}, 'dtime_2': {'len': 8}, 'grid_name': {'len': 6}, 'pol': {'delim': '', 'len': 2}, 'product': {'delim': '', 'len': 7}, 'sat_name': {'len': 3}, 'tile_name': {'len': 10}, 'var_name': {'len': 9}}
classmethod from_filename(filename_str, convert=False, compact=False)[source]

Converts a filename given as a string into an ACubeFilename class object.

Parameters:
  • filename_str (str) – Filename without any paths (e.g., “SIG0—–_SGRTA01_S1A_IWGRDH1VHD_20160126_054245–_EU010M_E043N016T1.tif”).

  • convert (bool, optional) – If true, decoding is applied to parts of the filename, where such an operation is available (default is False).

Returns:

Class representing an ACube file name.

Return type:

ACubeFilename

property ftile

Builds the full tile name from other filename attributes (e.g. ‘EU010M_E048N015T1’).

Returns:

ftile – Full tile name consisting of grid name (e.g., ‘EU10M’) and tile name (e.g., ‘E048N015T1’).

Return type:

str

pad = '-'
property stime

Start time.

Returns:

Start time.

Return type:

datetime.datetime

property time

Unified time.

Returns:

Unified time.

Return type:

datetime.datetime

geopathfinder.naming_conventions.bmon_naming module

BMon file name definition.

class geopathfinder.naming_conventions.bmon_naming.BMonFilename(fields, ext='.nc', convert=False, compact=False)[source]

Bases: SmartFilename

BMon file name definition using SmartFilename class.

decode_timestamp(string)[source]

Decodes a string into a datetime.date object. The format is given by the class.

Parameters:

string (str, object) – String needed to be decoded to a datetime.date object.

Returns:

Original object or datetime.date object parsed from the given string.

Return type:

datetime.date, object

delimiter = '_'
encode_timestamp(time_obj)[source]

Encodes a datetime.datetime/datetime.date object into a string. The format is given by the class.

Parameters:

time_obj (datetime.datetime, datetime.date or object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

fields_def = {'sres': {'len': 4, 'start': 17}, 'timestamp': {'len': 14}, 'var_name': {'len': 16}, 'version': {'len': 2}}
classmethod from_filename(filename_str, convert=False, compact=False)[source]

Converts a filename given as a string into a BMonFilename class object.

Parameters:
  • filename_str (str) – Filename without any paths (e.g., “BMON_DM_ENSEMBLE_500m_20160101120000_v1.nc”).

  • convert (bool, optional) – If true, decoding is applied to parts of the filename, where such an operation is available (default is False).

Returns:

Class representing a BMON filename.

Return type:

BMonFilename

pad = '-'

geopathfinder.naming_conventions.eodr_naming module

eoDR file name definition.

class geopathfinder.naming_conventions.eodr_naming.EODRFilename(fields, ext='.vrt', convert=False, compact=False)[source]

Bases: SmartFilename

eoDataReaders file name definition using SmartFilename class.

decode_counter(string)[source]

Decodes a string into an integer.

Parameters:

string (str, object) – String needed to be decoded to an integer.

Returns:

Original object or integer object parsed from the given string.

Return type:

int, object

decode_datetime(string)[source]

Decodes a string into a datetime object. The format is given by the class.

Parameters:

string (str, object) – String needed to be decoded to a datetime object.

Returns:

Original object or datetime object parsed from the given string.

Return type:

datetime.datetime, object

delimiter = '_'
encode_counter(file_counter)[source]

Encodes a file counter into a string.

Parameters:

file_counter (int) – Integer needed to be encoded to a string.

Returns:

Original object or str object parsed from the given integer.

Return type:

str, object

encode_datetime(time_obj)[source]

Encodes a datetime object into a string. The format is given by the class.

Parameters:

time_obj (datetime.datetime, object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

property etime

” End time.

Returns:

End time.

Return type:

datetime.datetime

fields_def = {'band': {}, 'counter': {'len': 5}, 'dt_1': {'len': 15}, 'dt_2': {'len': 15}, 'file_num': {}, 'id': {'len': 12}}
classmethod from_filename(filename_str, convert=False, compact=False)[source]

Converts a filename given as a string into an EODRFilename class object.

Parameters:
  • filename_str (str) – Filename without any paths (e.g., “00001_123456——_20181220T232333_—————_2_B5_34_aug.vrt”).

  • convert (bool, optional) – If true, decoding is applied to parts of the filename, where such an operation is available (default is False).

Returns:

Class representing an EODR filename.

Return type:

EODRFilename

pad = '-'
property stime

Start time.

Returns:

Start time.

Return type:

datetime.datetime

geopathfinder.naming_conventions.sgrt_naming module

SGRT folder and file name definition.

class geopathfinder.naming_conventions.sgrt_naming.SgrtFilename(fields, ext='.tif', convert=False, compact=False)[source]

Bases: SmartFilename

SGRT file name definition using SmartFilename class.

decode_date(string)[source]

Decodes a string into a datetime.date object. The format is given by the class.

Parameters:

string (str, object) – String needed to be decoded to a datetime.date object.

Returns:

Original object or datetime.date object parsed from the given string.

Return type:

datetime.date, object

decode_rel_orbit(string)[source]

Decodes a string into an integer.

Parameters:

string (str, object) – String needed to be decoded to an integer.

Returns:

Original object or integer object parsed from the given string.

Return type:

int, object

decode_time(string)[source]

Decodes a string into a datetime.time/datetime.date object. The format is given by the class and the conversion follows the ‘single_date’ setting.

Parameters:

string (str, object) – String needed to be decoded to a datetime.time/datetime.date object.

Returns:

Original object, datetime.date or datetime.time object parsed from the given string.

Return type:

datetime.date, datetime.time, object

delimiter = '_'
encode_date(time_obj)[source]

Encodes a datetime.datetime/datetime.date object into a string. The format is given by the class.

Parameters:

time_obj (datetime.datetime, datetime.date or object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

encode_rel_orbit(relative_orbit)[source]

Encodes a relative orbit number into a string.

Parameters:

relative_orbit (int or object) – Integer needed to be encoded to a string.

Returns:

Original object or str object parsed from the given integer.

Return type:

str, object

encode_time(time_obj)[source]

Encodes a datetime.datetime/datetime.date object into a string. The format is given by the class.

Parameters:

time_obj (datetime.datetime, datetime.date or object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

property etime

End time.

Returns:

End time.

Return type:

datetime.datetime

fields_def = {'dtime_1': {'len': 8}, 'dtime_2': {'len': 8}, 'grid_name': {'len': 6}, 'level': {'delim': '', 'len': 1}, 'mission_id': {'delim': '', 'len': 2}, 'mode_id': {'delim': '', 'len': 2}, 'orbit_direction': {'len': 1}, 'pflag': {'delim': '', 'len': 1}, 'pol': {'delim': '', 'len': 2}, 'product_type': {'delim': '', 'len': 3}, 'relative_orbit': {'len': 3}, 'res_class': {'delim': '', 'len': 1}, 'spacecraft_id': {'delim': '', 'len': 1}, 'tile_name': {'len': 10}, 'var_name': {'len': 9}, 'workflow_id': {'len': 5}}
classmethod from_filename(filename_str, convert=False, compact=False)[source]

Converts a filename given as a string into an SgrtFilename class object.

Parameters:
  • filename_str (str) – Filename without any paths (e.g., “M20170725_165004–_SIG0—–_S1BIWGRDH1VVA_146_A0104_EU500M_E048N012T6.tif”).

  • convert (bool, optional) – If true, decoding is applied to parts of the filename, where such an operation is available (default is False).

Returns:

Class representing an SGRT filename.

Return type:

SgrtFilename

property ftile

Builds the full tile name from other filename attributes (e.g. ‘EU010M_E048N015T1’).

Returns:

ftile – Full tile name consisting of grid name (e.g., ‘EU10M’) and tile name (e.g., ‘E048N015T1’).

Return type:

str

pad = '-'
property product_id

Builds product id from other filename attributes (e.g. ‘S1AIWGRDH’).

Returns:

product_id – Product id consisting of mission id (e.g., ‘S1’), spacecraft id (e.g., ‘A’), mode id (e.g., ‘IW’), product type (e.g., ‘GRD’) and resolution class (e.g., ‘H’).

Return type:

str

property stime

Start time.

Returns:

Start time.

Return type:

datetime.datetime

property time

Unified time.

Returns:

Unified time.

Return type:

datetime.datetime

geopathfinder.naming_conventions.sgrt_naming.sgrt_path(root, mode=None, group=None, datalog=None, product=None, wflow=None, grid=None, tile=None, var=None, qlook=True, make_dir=False)[source]

Realisation of the full SGRT folder naming convention, yielding a single SmartPath.

Parameters:
  • root (str) – root directory of the path. must contain satellite sensor at toplevel. e.g. “R:Datapool_processedSentinel-1_CSAR”

  • mode (str) – e.g “IWGRDH”

  • group (str, optional) – “preprocessed” or “parameters” or “products”

  • datalog (str, optional) – must be “datasets” or “logfiles”

  • product (str) – e.g. “ssm”

  • wflow (str) – e.g. “C1003”

  • grid (str) – e.g. “EQUI7_EU500M”

  • tile (str) – e.g. “E048N012T6”

  • var (str) – e.g. “ssm”

  • qlook (bool) – if the quicklook subdir should be integrated

  • make_dir (bool) – if the directory should be created on the filesystem

Returns:

Object for the path

Return type:

SmartPath

geopathfinder.naming_conventions.sgrt_naming.sgrt_tree(root, target_level=None, register_file_pattern=None, subset_level=None, subset_pattern=None, subset_unique=False)[source]

Realisation of the full SGRT folder naming convention, yielding a SmartTree(), reflecting all subfolders as SmartPath()

Parameters:
  • root (str) – top level directory of the SGRT dataset, which is the sensor name in the SGRT naming convention. E.g.: “R:Datapool_processedSentinel-1_CSAR”

  • target_level (str, optional) – Can speed up things: Level name of target tree-depth. The SmartTree is only built from directories reaching this level, and only built down to this level. If not set, all directories are built down to deepest depth.

  • register_file_pattern (str tuple, optional) – strings defining search pattern for file search for file_register e.g. (‘C1003’, ‘E048N012T6’). No asterisk is needed (‘*’)! Sequence of strings in given tuple is crucial! Be careful: If the tree is large, this can take a while!

  • subset_level (str tuple, optional) – Name of level in tree’s hierarchy where the subset should be applied e.g. (‘tile’). Default level is (‘grid’)

  • subset_pattern (str tuple, optional) – Strings defining search pattern for subset_level, meaning only paths matching this pattern at “subset_level” will be included in the SmartTree(). Default pattern is (‘EQUI7’). e.g. (‘EQUI7’, ‘500M’), or (‘500M’). No asterisk is needed (‘*’)! Sequence of strings in given tuple is crucial!

  • subset_unique (bool, optional) –

    defines of the subset will deliver…
    True: just one single subtree that matches uniquely the subset_pattern,

    and which is rebased to the subset_level.

    False: all subtrees that match the subset_pattern (Default).

Returns:

Object for the SGRT tree.

Return type:

SmartTree

geopathfinder.naming_conventions.yeoda_naming module

Yeoda folder and file name definition.

class geopathfinder.naming_conventions.yeoda_naming.YeodaFilename(fields, ext='.tif', convert=False)[source]

Bases: SmartFilename

Yeoda file name definition using SmartFilename class.

decode_datetime(string)[source]

Decodes a string into a datetime.datetime object. The format is defined based on the string itself.

Parameters:

string (str, object) – String needed to be decoded to a datetime.date object.

Returns:

Original object or datetime.datetime object parsed from the given string.

Return type:

datetime.datetime, object

decode_extra_field(string)[source]

Decodes a string into an integer if possible.

Parameters:

string (str, object) – String needed to be decoded to an integer.

Returns:

Original object or integer object parsed from the given string.

Return type:

int, object

delimiter = '_'
encode_datetime(datetime_obj)[source]

Encodes a datetime.datetime/datetime.date object into a string. The format is selected by the input type.

Parameters:

time_obj (datetime.datetime, datetime.date or object) – Datetime object needed to be encoded to a string.

Returns:

Original object or str object parsed from the given datetime object.

Return type:

str, object

encode_extra_field(relative_orbit)[source]

Encodes the extra field e.g. a relative orbit number into a string.

Parameters:

relative_orbit (int or object) – Integer needed to be encoded to a string.

Returns:

Original object or str object parsed from the given integer.

Return type:

str, object

property etime

End time.

Returns:

End time.

Return type:

datetime.datetime

fields_def = {'band': {'len': 0}, 'creator': {'len': 0}, 'data_version': {'len': 0}, 'datetime_1': {'len': 0}, 'datetime_2': {'len': 0}, 'extra_field': {'len': 0}, 'grid_name': {'len': 0}, 'sensor_field': {'len': 0}, 'tile_name': {'len': 0}, 'var_name': {'len': 0}}
classmethod from_filename(filename_str, convert=False)[source]

Converts a filename given as a string into an YeodaFilename class object.

Parameters:
  • filename_str (str) – Filename without any paths (e.g., “SIG0_20170725T165004__VV_A146_E048N012T6_EU500M_V04R01_S1BIWG1.tif”).

  • convert (bool, optional) – If true, decoding is applied to parts of the filename, where such an operation is available (default is False).

Returns:

Class representing an Yeoda filename.

Return type:

YeodaFilename

property ftile

Builds the full tile name from other filename attributes (e.g. ‘EU010M_E048N015T1’).

Returns:

ftile – Full tile name consisting of grid name (e.g., ‘EU10M’) and tile name (e.g., ‘E048N015T1’).

Return type:

str

pad = '-'
property stime

Start time.

Returns:

Start time.

Return type:

datetime.datetime

property time

Unified time.

Returns:

Unified time.

Return type:

datetime.datetime

geopathfinder.naming_conventions.yeoda_naming.yeoda_path(root, product, data_version, grid=None, tile=None, qlook=True, make_dir=False)[source]

Realisation of the full yeoda folder naming convention, yielding a single SmartPath. If a keyword is not specified, the yeoda_path is shorthanded, until one level above the missing keyword

Parameters:
  • root (str) – root directory of the path. must contain satellite sensor at toplevel. e.g. “R:Datapool_processedSentinel-1_CSAR”

  • product (str) – e.g. “ssm”

  • data_version (int or str) – e.g. 2 or “V1M3R2”

  • grid (str, optional) – e.g. “EQUI7_EU500M”

  • tile (str, optional) – e.g. “E048N012T6”

  • qlook (bool, optional) – if the quicklook subdir should be integrated

  • make_dir (bool, optional) – if the directory should be created on the filesystem

Returns:

Object for the path

Return type:

SmartPath

geopathfinder.naming_conventions.yeoda_naming.yeoda_tree(root, target_level=None, register_file_pattern=None, subset_level='grid', subset_pattern='EQUI7', subset_unique=False)[source]

Realisation of the full yeoda folder naming convention, yielding a SmartTree(), reflecting all compatible subfolders as SmartPath()

Parameters:
  • root (str) – top level directory of the dataset, which is the sensor name in the SGRT naming convention. E.g.: “R:Datapool_processedSentinel-1_CSAR”

  • target_level (str, optional) – Can speed up things: Level name of target tree-depth. The SmartTree is only built from directories reaching this level, and only built down to this level. If not set, all directories are built down to deepest depth.

  • register_file_pattern (str tuple, optional) – strings defining search pattern for file search for file_register e.g. (‘V01R03’, ‘E048N012T6’). No asterisk is needed (‘*’)! Sequence of strings in given tuple is crucial! Be careful: If the tree is large, this can take a while!

  • subset_level (str tuple, optional) – Name of level in tree’s hierarchy where the subset should be applied e.g. (‘tile’). Default level is (‘grid’)

  • subset_pattern (str tuple, optional) – Strings defining search pattern for subset_level, meaning only paths matching this pattern at “subset_level” will be included in the SmartTree() Default pattern is (‘EQUI7’). e.g. (‘EQUI7’, ‘500M’), or (‘500M’). No asterisk is needed (‘*’)! Sequence of strings in given tuple is crucial!

  • subset_unique (bool, optional) –

    defines of the subset will deliver…
    True: just one single subtree that matches uniquely the subset_pattern,

    and which is rebased to the subset_level.

    False: all subtrees that match the subset_pattern (Default).

Returns:

Tree object for the yeoda dataset.

Return type:

SmartTree