earthkit.data.utils.unique¶
Classes¶
Collector for unique values for a given set of metadata keys. |
Functions¶
|
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 standardget()method, or via the_get_fast()method for efficient retrieval of multiple keys at once.keys (
strorlist/ tupleofstr) – 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 forremapping (
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:
dictoftuple
- earthkit.data.utils.unique.build_remapping(remapping, patch)¶