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.

clear(*args, **kws)

Raise and error.

convert_dict(keyvals)[source]

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

create_filter_query_without_required_fields(query)[source]

Remove the required fields from query.

create_less_modified_query()[source]

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.

from_dict(keyvals)[source]

Create a DataID from a dictionary.

property id_keys

Get the id_keys.

is_modified()[source]

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)

Raise and error.

popitem(*args, **kws)

Raise and error.

setdefault(*args, **kws)

Raise and error.

to_dict()[source]

Convert the ID to a dict.

update(*args, **kws)

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 of the DataID elements are unknown. In this case a * signifies something that is unknown or not applicable to the requested Dataset.

Initialize the query.

create_less_modified_query()[source]

Create a query with one less modifier.

filter_dataids(dataid_container)[source]

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.

is_modified()[source]

Check if this is modified.

items()[source]

Get the items of this query.

sort_dataids(dataids)[source]

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).

to_dict(trim=True)[source]

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: enum.IntEnum

A static value list.

classmethod convert(value)[source]

Convert value to an instance of this class.

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

Bases: satpy.dataset.dataid.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 convert(wl)[source]

Convert wl to this type if possible.

distance(value)[source]

Get the distance from value.

classmethod from_cf(blob)[source]

Return a WavelengthRange from a cf blob.

to_cf()[source]

Serialize for cf export.

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', '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.

satpy.dataset.dataid.wlklass

alias of satpy.dataset.dataid.WavelengthRange