earthkit.data.utils.unique

Classes

UniqueValuesCache

UniqueValuesCollector

Collector for unique values for a given set of metadata keys.

Functions

build_remapping(remapping, patch)

Module Contents

class earthkit.data.utils.unique.UniqueValuesCache(index=None)
collect(keys)
index(key, maker=None)
class earthkit.data.utils.unique.UniqueValuesCollector(cache=False)

Collector for unique values for a given set of metadata keys.

Parameters:

cache (bool, optional) – Whether to use a cache for previously collected unique values. Default is False.

collect(data, keys, sort=False, drop_none=True, squeeze=False, unwrap_single=False, remapping=None, patch=None, progress_bar=False)

Collect unique values for the given keys from data.

Parameters:
  • data (iterable) – The data to collect unique values from. It must be an iterable of objects supporting metadata access either via the standard get() method, or via the _get_fast() method for efficient retrieval of multiple keys at once.

  • keys (str or list/ tuple of str) – The metadata keys for which to collect unique values. This can be a single string key or a list/tuple of string keys.

  • sort (bool, optional) – Whether to sort the collected unique values. Default is False.

  • drop_none (bool, optional) – Whether to drop None values from the collected unique values. Default is True.

  • squeeze (bool, optional) – Whether to return a single value instead of a list if there is only one unique value for

  • remapping (dict, optional) – A dictionary for remapping keys or values during collection. Default is None.

  • patch (dict, optional) – A dictionary for patching key values during collection. Default is None.

  • progress_bar (bool, optional) – Whether to display a progress bar during collection. Default is False.

Returns:

A dictionary where each key is one of the input keys and the corresponding value is a tuple of unique values collected for that key from the data.

Return type:

dict of tuple

earthkit.data.utils.unique.build_remapping(remapping, patch)