cedar.tracker module¶
Tracker to submit and download GEE pre-ARD tasks
- 
class 
cedar.tracker.Tracker(tile_grid, store, name_template='{collection}_h{tile.horizontal:03d}v{tile.vertical:03d}_{date_start}_{date_end}', prefix_template='CEDAR_PREARD', tracking_template='TRACKING_PERIOD{date_start}-{date_end}_TASK{today}', tracking_prefix='CEDAR_TRACKING', filters=None, export_image_kwds=None)[source]¶ Bases:
objectCEDAR “pre-ARD” order tracker
- Parameters
 tile_grid (stems.gis.grids.TileGrid) – Tile Grid to use for ARD
store (cedar.stores.Store) – A Store that can be used to store images & metadata
name_template (str, optional) – Template for “pre-ARD” image and metadata name
prefix_template (str, optional) – Template for “pre-ARD” image and metadata prefix
tracking_template (str, optional) – Template for order tracking file name
tracking_prefix (str, optional) – Order tracking file prefix folder
filters (Dict[str, Sequence[dict or ee.Filter]]) – Earth Engine filters to apply, organized by image collection name. Values should either be
ee.Filterobjects or dictionaries that describe the filter (seecedar.utils.serialize_filter())
- 
clean(self, tracking_info, tracking_name=None, callback=None)[source]¶ Clean “pre-ARD” imagery, metadata, and tracking metadata off GCS
- Parameters
 tracking_info (dict) – JSON tracking info data as a dict
tracking_name (str) – Name of tracking info file (will be deleted if provided)
callback (callable) – Callback function to execute after each file is deleted. Should take arguments “item” and “n_steps”. Use this for progress bars or other download status reporting
- Returns
 Mapping of GEE Task ID to filename(s) cleaned
- Return type
 
- 
download(self, tracking_info, dest, overwrite=True, callback=None)[source]¶ Download “pre-ARD” and metadata to a directory
- Parameters
 tracking_info (dict) – JSON tracking info data as a dict
dest (str or pathlib.Path) – Destination download directory
overwrite (bool, optional) – Overwrite existing downloaded data
callback (callable) – Callback function to execute after each file is downloaded. Should take arguments “item” and “n_steps”. Use this for progress bars or other download status reporting
- Returns
 Key value pairs mapping GEE task IDs to the filenames of downloaded data. Wrap it in a
dictto make it not lazy- Return type
 
- 
submit(self, collections, tile_indices, period_start, period_end, period_freq=None, save_empty_metadata=True, error_if_empty=False)[source]¶ Submit and track GEE pre-ARD tasks
- Parameters
 collections (str or Sequence[str]) – GEE image collection name(s)
tile_indices (Sequence[(int, int)]) – Tuple(s) of rows/columns in TileGrid to process
period_start (dt.datetime) – Starting period date
period_end (dt.datetime) – Ending period date
period_freq (str, optional) – If provided,
period_start,period_end, andperiod_freqare interpeted as the range forpandas.date_range()and one or more Tasks will be submittedsave_empty_metadata (bool, optional) – If True, Pre-ARD image requests that have 0 results (e.g., because of spotty historical record) will store metadata, but will not start the task. If False, will not store this metadata
error_if_empty (bool, optional) – If True, raise an EmptyCollectionError if the image collection result has no images. The default behavior is to log and skip empty search results
- Returns
 str – Task tracking information name
str – Task tracking information identifier (an ID, path, etc)
- 
cedar.tracker.clean_tracked(tracking_info, store)[source]¶ Delete stored “pre-ARD” and metadata described by tracking info
- Parameters
 tracking_info (dict) – Tracking information
store (cedar.stores.gcs.GCSStore or cedar.stores.gdrive.GDriveStore) – cedar store class
- Yields
 id (str) – Order GEE Task ID
names (generator) – Generator that deletes files and returns their names
- 
cedar.tracker.download_tracked(tracking_info, store, dest, overwrite=False)[source]¶ Download stored “pre-ARD” and metadata described by tracking info
- Parameters
 tracking_info (dict) – Tracking information
store (cedar.stores.Store) – cedar store class
dest (str or pathlib.Path) – Destination download directory
overwrite (bool, optional) – Overwrite previously downoaded data, or not
- Yields
 id (str) – Task ID
n_images (int) – Number of images to download if known, otherwise
Nonemetadata (generator) – Generator that downloads metadata and yields filenames
images (generator) – Generator that downloads imagery and yields filenames