satpy.dataset.data_dict module

Classes and functions related to a dictionary with DataID keys.

class satpy.dataset.data_dict.DatasetDict[source]

Bases: dict

Special dictionary object that can handle dict operations based on dataset name, wavelength, or DataID.

Note: Internal dictionary keys are DataID objects.

_create_dataid_key(key, value_info)[source]

Create a DataID key from dictionary.

_create_id_keys_from_dict(value_info_dict)[source]

Create id_keys from dict.

contains(item)[source]

Check contains when we know the exact DataID.

get(key, default=None)[source]

Get value with optional default.

get_key(match_key, num_results=1, best=True, **dfilter)[source]

Get multiple fully-specified keys that match the provided query.

Parameters:
  • key (DataID) – DataID of query parameters to use for searching. Any parameter that is None is considered a wild card and any match is accepted. Can also be a string representing the dataset name or a number representing the dataset wavelength.

  • num_results (int) – Number of results to return. If 0 return all, if 1 return only that element, otherwise return a list of matching keys.

  • **dfilter (dict) – See get_key function for more information.

getitem(item)[source]

Get Node when we know the exact DataID.

keys(names=False, wavelengths=False)[source]

Give currently contained keys.

exception satpy.dataset.data_dict.TooManyResults[source]

Bases: KeyError

Special exception when one key maps to multiple items in the container.

satpy.dataset.data_dict.get_best_dataset_key(key, choices)[source]

Choose the “best” DataID from choices based on key.

To see how the keys are sorted, refer to :meth:satpy.datasets.DataQuery.sort_dataids.

This function assumes choices has already been filtered to only include datasets that match the provided key.

Parameters:
  • key (DataQuery) – Query parameters to sort choices by.

  • choices (iterable) – DataID objects to sort through to determine the best dataset.

Returns: List of best DataID`s from `choices. If there is more

than one element this function could not choose between the available datasets.

satpy.dataset.data_dict.get_key(key, key_container, num_results=1, best=True, query=None, **kwargs)[source]

Get the fully-specified key best matching the provided key.

Only the best match is returned if best is True (default). See get_best_dataset_key for more information on how this is determined.

query is provided as a convenience to filter by multiple parameters at once without having to filter by multiple key inputs.

Parameters:
  • key (DataID) – DataID of query parameters to use for searching. Any parameter that is None is considered a wild card and any match is accepted.

  • key_container (dict or set) – Container of DataID objects that uses hashing to quickly access items.

  • num_results (int) – Number of results to return. Use 0 for all matching results. If 1 then the single matching key is returned instead of a list of length 1. (default: 1)

  • best (bool) – Sort results to get “best” result first (default: True). See get_best_dataset_key for details.

  • query (DataQuery) –

    filter for the key which can contain for example:

    resolution (float, int, or list): Resolution of the dataset in

    dataset units (typically meters). This can also be a list of these numbers.

    calibration (str or list): Dataset calibration

    (ex.’reflectance’). This can also be a list of these strings.

    polarization (str or list): Dataset polarization

    (ex.’V’). This can also be a list of these strings.

    level (number or list): Dataset level (ex. 100). This can also be a

    list of these numbers.

    modifiers (list): Modifiers applied to the dataset. Unlike

    resolution and calibration this is the exact desired list of modifiers for one dataset, not a list of possible modifiers.

Returns:

Matching key(s)

Return type:

list or DataID

Raises: KeyError if no matching results or if more than one result is

found when num_results is 1.