satpy.dataset.dataid module

Dataset identifying objects.

class satpy.dataset.dataid.DataID(id_keys, **keyval_dict)[source]

Bases: dict

Identifier for all DataArray objects.

DataID is a dict that holds identifying and classifying information about a DataArray.

Init the DataID.

The id_keys dictionary has to be formed as described in Satpy internal workings: having a look under the hood. The other keyword arguments are values to be assigned to the keys. Note that None isn’t a valid value and will simply be ignored.

_immutable(*args, **kws) NoReturn[source]

Raise and error.


Make a new instance with replaced items.

classmethod _unpickle(id_keys, keyval)[source]

Create a new instance of the DataID after pickling.

clear(*args, **kws) NoReturn

Raise and error.


Convert a dictionary’s values to the types defined in this object’s id_keys.


Remove the required fields from query.


Create a query with one less modifier.

static fix_id_keys(id_keys)[source]

Flesh out enums in the id keys as gotten from a config.

classmethod from_dataarray(array, default_keys={'name': {'required': True}, 'resolution': {'transitive': True}})[source]

Get the DataID using the dataarray attributes.


Create a DataID from a dictionary.

property id_keys

Get the id_keys.


Check if this is modified.

classmethod new_id_from_dataarray(array, default_keys={'name': {'required': True}, 'resolution': {'transitive': True}})[source]

Create a new DataID from a dataarray’s attributes.

pop(*args, **kws) NoReturn

Raise and error.

popitem(*args, **kws) NoReturn

Raise and error.

setdefault(*args, **kws) NoReturn

Raise and error.


Convert the ID to a dict.

update(*args, **kws) NoReturn

Raise and error.

class satpy.dataset.dataid.DataQuery(**kwargs)[source]

Bases: object

The data query object.

A DataQuery can be used in Satpy to query for a Dataset. This way a fully qualified DataID can be found even if some DataID elements are unknown. In this case a * signifies something that is unknown or not applicable to the requested Dataset.

Initialize the query.

static _add_absolute_distance(dataid, key, distance)[source]
static _add_distance_from_query(dataid_val, requested_val, distance)[source]

Match the dataid with the current query.

_match_query_value(key, id_val)[source]

Check if dataid shares required keys with the current query.


Create a query with one less modifier.


Filter DataIDs based on this query.

classmethod from_dict(the_dict)[source]

Convert a dict to an ID.

get(key, default=None)[source]

Get an item.


Check if this is modified.


Get the items of this query.


Sort the DataIDs based on this query.

Returns the sorted dataids and the list of distances.

The sorting is performed based on the types of the keys to search on (as they are defined in the DataIDs from dataids). If that type defines a distance method, then it is used to find how ‘far’ the DataID is from the current query. If the type is a number, a simple subtraction is performed. For other types, the distance is 0 if the values are identical, np.inf otherwise.

For example, with the default DataID, we use the following criteria:

  1. Central wavelength is nearest to the key wavelength if specified.

  2. Least modified dataset if modifiers is None in key. Otherwise, the modifiers are ignored.

  3. Highest calibration if calibration is None in key. Calibration priority is the order of the calibration list defined as reflectance, brightness temperature, radiance counts if not overridden in the reader configuration.

  4. Best resolution (smallest number) if resolution is None in key. Otherwise, the resolution is ignored.

sort_dataids_with_preference(all_ids, preference)[source]

Sort all_ids given a sorting preference (DataQuery or None).


Convert the ID to a dict.

class satpy.dataset.dataid.ModifierTuple(iterable=(), /)[source]

Bases: tuple

A tuple holder for modifiers.

classmethod convert(modifiers)[source]

Convert modifiers to this type if possible.

class satpy.dataset.dataid.ValueList(value)[source]

Bases: IntEnum

A static value list.

This class is meant to be used for dynamically created Enums. Due to this it should not be used as a normal Enum class or there may be some unexpected behavior. For example, this class contains custom pickling and unpickling handling that may break in subclasses.

classmethod _unpickle(enum_name, enum_members, enum_member)[source]

Create dynamic class that was previously pickled.

See __reduce_ex__() for implementation details.

classmethod convert(value)[source]

Convert value to an instance of this class.

class satpy.dataset.dataid.WavelengthRange(min, central, max, unit='µm')[source]

Bases: WavelengthRange

A named tuple for wavelength ranges.

The elements of the range are min, central and max values, and optionally a unit (defaults to µm). No clever unit conversion is done here, it’s just used for checking that two ranges are comparable.

Create new instance of WavelengthRange(min, central, max, unit)

classmethod _read_cf_from_string_export(blob)[source]

Read blob as a string created by to_cf.

classmethod _read_cf_from_string_list(blob)[source]

Read blob as a list of strings (legacy formatting).

classmethod convert(wl)[source]

Convert wl to this type if possible.


Get the distance from value.

classmethod from_cf(blob)[source]

Return a WavelengthRange from a cf blob.


Serialize for cf export.


Get a generalize value for comparisons.

satpy.dataset.dataid._update_dict_with_filter_query(ds_dict, filter_query)[source]
satpy.dataset.dataid.create_filtered_query(dataset_key, filter_query)[source]

Create a DataQuery matching dataset_key and filter_query.

If a property is specified in both dataset_key and filter_query, the former has priority.

satpy.dataset.dataid.default_co_keys_config = {'name': {'required': True}, 'resolution': {'transitive': True}}

Default ID keys for coordinate DataArrays.

satpy.dataset.dataid.default_id_keys_config = {'calibration': {'enum': ['reflectance', 'brightness_temperature', 'radiance', 'radiance_wavenumber', 'counts'], 'transitive': True}, 'modifiers': {'default': (), 'type': <class 'satpy.dataset.dataid.ModifierTuple'>}, 'name': {'required': True}, 'resolution': {'transitive': False}, 'wavelength': {'type': <class 'satpy.dataset.dataid.WavelengthRange'>}}

Default ID keys DataArrays.

satpy.dataset.dataid.get_keys_from_config(common_id_keys, config)[source]

Gather keys for a new DataID from the ones available in configured dataset.

satpy.dataset.dataid.minimal_default_keys_config = {'name': {'required': True}, 'resolution': {'transitive': True}}

Minimal ID keys for DataArrays, for example composites.


alias of WavelengthRange