earthkit.data.field.component.component

Classes

Functions

Module Contents

class earthkit.data.field.component.component.FieldComponent
abstractmethod aliases()

Return the aliases in the component.

classmethod from_dict(d)
Abstractmethod:

Create a FieldComponent instance from a dictionary.

Parameters:

d (dict) – Dictionary containing specification data.

Returns:

The created FieldComponent instance.

Return type:

FieldComponent

abstractmethod get(key, default=None, *, astype=None, raise_on_missing=False)

Return the values for the specified keys.

Parameters:
  • keys (str, list or tuple) – Specify the metadata keys to extract. Can be a single key (str) or multiple keys as a list/tuple of str.

  • default (Any, None) – Specify the default value(s) for keys. Returned when the given key is not found and raise_on_missing is False. When default is a single value, it is used for all the keys. Otherwise it must be a list/tuple of the same length as keys.

  • astype (type as str, int or float) – Return type for keys. When astype is a single type, it is used for all the keys. Otherwise it must be a list/tuple of the same length as keys.

  • raise_on_missing (bool) – When True, raises KeyError if any of keys is not found.

Returns:

The value(s) for the specified keys:

  • when keys is a str returns a single value

  • when keys is a list/tuple returns a list/tuple of values

Return type:

single value, list, tuple

Raises:

KeyError – If raise_on_missing is True and any of keys is not found.

abstractmethod keys()

Return the available keys in the component.

abstractmethod set(*args, **kwargs)

Create a new instance with updated data.

Parameters:
  • *args – Positional arguments.

  • **kwargs – Keyword arguments.

Returns:

The created FieldComponent instance.

Return type:

FieldComponent

Raises:

KeyError – If any of the keys to be set are not supported.

abstractmethod to_dict()

Convert the object to a dictionary.

Returns:

Dictionary representation of the object.

Return type:

dict

class earthkit.data.field.component.component.SimpleFieldComponent

Bases: FieldComponent

aliases()

Return the aliases in the component.

classmethod from_dict(d)
Abstractmethod:

Create a FieldComponent instance from a dictionary.

Parameters:

d (dict) – Dictionary containing specification data.

Returns:

The created FieldComponent instance.

Return type:

FieldComponent

get(key, default=None, *, astype=None, raise_on_missing=False)

Return the value for the specified key.

Parameters:
  • key (str) – The key to retrieve.

  • default (Any, optional) – The default value to return if the key is not found. Default is None.

  • astype (type, optional) – The type to which the value should be cast. Default is None.

  • raise_on_missing (bool, optional) – If True, raise a KeyError if the key is not found. Default is False.

Returns:

The value for the specified key.

Return type:

Any

Raises:

KeyError – If raise_on_missing is True and the key is not found.

keys()

Return the available keys in the component.

abstractmethod set(*args, **kwargs)

Create a new instance with updated data.

Parameters:
  • *args – Positional arguments.

  • **kwargs – Keyword arguments.

Returns:

The created FieldComponent instance.

Return type:

FieldComponent

Raises:

KeyError – If any of the keys to be set are not supported.

abstractmethod to_dict()

Convert the object to a dictionary.

Returns:

Dictionary representation of the object.

Return type:

dict

earthkit.data.field.component.component.component_keys(cls)
earthkit.data.field.component.component.mark_alias(name)
earthkit.data.field.component.component.mark_get_key(func)