cedar.utils module

Common utility functions

class cedar.utils.EE_STATES[source]

Bases: object

CANCELLED = 'CANCELLED'
CANCEL_REQUESTED = 'CANCEL_REQUESTED'
COMPLETED = 'COMPLETED'
EMPTY = 'EMPTY'
FAILED = 'FAILED'
READY = 'READY'
RUNNING = 'RUNNING'
UNSUBMITTED = 'UNSUBMITTED'
cedar.utils.affine_to_str(transform)[source]

Return a string representatin of an affine.Affine transform

cedar.utils.create_filters(filters)[source]

Convert a list of filters/filter descriptions to List[ee.Filter]

Parameters

filters (List[dict]) – Earth Engine filters serialized to dict

Returns

Filters as ee.Filter

Return type

List[ee.Filter]

cedar.utils.dict_to_filter(function, **kwds)[source]

Convert serialized form of filter to a ee.Filter

Parameters
  • function (str) – Name of filter. Should be a (static) method of ee.Filter

  • kwds – Keyword arguments to pass to for the filter construction. These will depend on the filter in question

Returns

Earth Engine filter

Return type

ee.Filter

cedar.utils.get_ee_tasks()[source]

Return GEE tasks (task ID: task)

Returns

GEE tasks

Return type

dict[str, ee.batch.task.Task]

cedar.utils.get_file(*filenames, exists=True)[source]

Return first good filename

Parameters
  • filenames (Sequence[str or Path]) – Filenames to check

  • exists (bool, optional) – Require that the filename correspond to an existing file on disk

Returns

A Path of the first good filename, or None if they’re all bad

Return type

Path or None

cedar.utils.load_ee(initialize=True)[source]

Import and initialize the EE API, handling errors

Parameters

initialize (bool, optional) – Try to initialize the EE API, or not

Returns

Earth Engine API module ee

Return type

object

Raises
  • ImportError – Raised if the Earth Engine cannot be imported

  • ee.ee_exceptions.EEException – Raised if the Earth Engine cannot be initialized, typically because you haven’t authenticated yet.

  • Exception – Passes other exceptions caused by ee.Initialize()

cedar.utils.serialize_filter(ee_filter)[source]

Serialize an Earth Engine filter

cedar.utils.set_file_urw(filename)[source]

Sets a file to user read/write only

Parameters

filename (str) – File to modify