pyeo.filesystem_utilities

Contains functions for sorting, creating and comparing images as part of the filesystem. Includes any function that works on a generic pyeo timestamp and sentinel 2 functions.

pyeo.filesystem_utilities.check_for_invalid_l1_data(l1_SAFE_file)

Checks the existance of the specified resolution of imagery. Returns True with a warning if passed an invalid SAFE directory; this will prevent disconnected files from being deleted. Retuns 1 if imagery is valid, 0 if not and 2 if not a safe-file

pyeo.filesystem_utilities.check_for_invalid_l2_data(l2_SAFE_file, resolution='10m')

Checks the existance of the specified resolution of imagery. Returns a True-value with a warning if passed an invalid SAFE directory; this will prevent disconnected files from being deleted. Retuns 1 if imagery is valid, 0 if not and 2 if not a safe-file

pyeo.filesystem_utilities.clean_aoi(aoi_dir, images_to_keep=4, warning=True)

Removes all but the last images_to_keep newest images in the L1, L2, merged, stacked and composite directories. Will not affect the output folder.

pyeo.filesystem_utilities.clean_l2_data(l2_SAFE_file, resolution='10m', warning=True)

Removes any directories that don’t have band 2, 3, 4 or 8 in the specified resolution folder If warning=True, prompts first.

pyeo.filesystem_utilities.clean_l2_dir(l2_dir, resolution='10m', warning=True)

Calls clean_l2_data on every SAFE file in l2_dir

pyeo.filesystem_utilities.create_file_structure(root)

Creates the file structure if it doesn’t exist already

pyeo.filesystem_utilities.get_change_detection_dates(image_name)

Takes the source filepath and extracts the before_date and after_date dates from in, in that order.

pyeo.filesystem_utilities.get_image_acquisition_time(image_name)

Gets the datetime object from a .safe filename of a planet image. No test. Returns None if no timestamp present

pyeo.filesystem_utilities.get_l1_safe_file(image_name, l1_dir)

Returns the path to the L1 .SAFE directory of image. Gets from granule and timestamp. image_name can be a path or a filename

pyeo.filesystem_utilities.get_l2_safe_file(image_name, l2_dir)

Returns the path to the L2 .SAFE directory of image. Gets from granule and timestamp. image_name can be a path or a filename

pyeo.filesystem_utilities.get_mask_path(image_path)

A gdal mask is an image with the same name as the image it’s masking, but with a .msk extension

pyeo.filesystem_utilities.get_preceding_image_path(target_image_name, search_dir)

Gets the path to the image in search_dir preceding the image called image_name

pyeo.filesystem_utilities.get_pyeo_timestamp(image_name)

Returns a list of all timestamps in a Pyeo image.

Gets the paths of all images related to that one in a project, by timestamp

pyeo.filesystem_utilities.get_sen_2_baseline(image_name)

Returns the baseline string of a s2 image

pyeo.filesystem_utilities.get_sen_2_granule_id(safe_dir)

Returns the unique ID of a Sentinel 2 granule from a SAFE directory path

pyeo.filesystem_utilities.get_sen_2_image_orbit(image_name)

Returns the relative orbit number of a Sentinel 2 image

pyeo.filesystem_utilities.get_sen_2_image_tile(image_name)

Returns the tile number of a Sentinel 2 image or path

pyeo.filesystem_utilities.get_sen_2_image_timestamp(image_name)

Returns the timestamps part of a Sentinel 2 image

pyeo.filesystem_utilities.get_sen_2_tiles(image_dir)

gets the list of tiles present in the directory

pyeo.filesystem_utilities.init_log(log_path)

Sets up the log format and log handlers; one for stdout and to write to a file, ‘log_path’. Returns the log for the calling script

pyeo.filesystem_utilities.is_tif(image_string)

Returns True if image ends with .tif

pyeo.filesystem_utilities.sort_by_timestamp(strings, recent_first=True)

Takes a list of strings that contain sen2 timestamps and returns them sorted, most recent first. Does not guarantee ordering of strings with the same timestamp. Removes any string that does not contain a timestamp