earthkit.data.field.handler.labels¶
Classes¶
Abstract base class for Field component handlers. |
|
dict() -> new empty dictionary |
Module Contents¶
- class earthkit.data.field.handler.labels.Labels¶
Bases:
earthkit.data.field.handler.core.FieldComponentHandlerAbstract base class for Field component handlers.
A FieldComponent represents a component of a Field, such as time, vertical level, or processing information. It stores a specification object, the “spec”, and provides methods to access and manipulate the specification data.
It is meant to be used internally by the Field class and its members.
- KEYS¶
A tuple of keys from the “spec” that can be accessed as properties on the FieldComponent.
- Type:
tuple
- ALIASES¶
An Aliases object that maps alternative key names to their canonical names.
- Type:
Aliases
- ALL_KEYS¶
A tuple of all keys, including aliases, that can be accessed from the FieldComponent.
- Type:
tuple
- NAME¶
The name of the FieldComponent to be used as an identifier in the Field. It is also the name of the corresponding namespace in the Field.
- Type:
str
- DUMP_KEYS¶
A tuple of keys that should be included in the namespace represented by the FieldComponent.
- Type:
tuple
- KEYS = ()¶
- NAME = 'labels'¶
- abstractmethod check(owner)¶
Check the FieldComponent for consistency with the owner Field.
- property component¶
Return the FieldComponent.
- abstractmethod dump(*args, **kwargs)¶
Populate the namespace dictionary for this FieldComponent.
- classmethod from_any(**kwargs)¶
- Abstractmethod:
Create a FieldComponentHandler instance from any allowed input types.
- Parameters:
kwargs (
dict) – Keyword arguments containing specification data.- Returns:
The created FieldComponentHandler instance.
- Return type:
FieldComponentHandler
- classmethod from_dict(d)¶
- Abstractmethod:
Create a FieldComponentHandler instance from a dictionary.
- Parameters:
d (
dict) – Dictionary containing specification data.- Returns:
The created FieldComponentHandler instance.
- Return type:
FieldComponentHandler
- abstractmethod get(key, default=None, *, astype=None, raise_on_missing=False)¶
Return the value for
key.- Parameters:
key (
str) – Keydefault (
value) – Specify the default value forkey. Returned whenkeyis not found or its value is a missing value and raise_on_missing isFalse.astype (
type as str,intorfloat) – Return/access type forkey. When it is supportedastypeis passed to the underlying accessor as an option. Otherwise the value is cast toastypeafter it is taken from the accessor.raise_on_missing (
bool) – When it is True raises an exception ifkeyis not found or it has a missing value.
- Returns:
Returns the
keyvalue. Returnsdefaultifkeyis not found or it has a missing value andraise_on_missingis False.- Return type:
value- Raises:
KeyError – If
raise_on_missingis True andkeyis not found or it has a missing value.
- abstractmethod get_grib_context(context)¶
Populate the GRIB context dictionary for this FieldComponent.
- abstractmethod items()¶
Return the metadata items.
- Return type:
Iterableof(key,value)pairs
- abstractmethod keys()¶
Return the metadata keys.
- Return type:
Iterableofstr
- abstractmethod remove(*args)¶
- abstractmethod set(*args, **kwargs)¶
Create a new FieldComponent instance with updated data.
- Parameters:
*args – Positional arguments.
**kwargs – Keyword arguments.
- Returns:
The created FieldComponent instance.
- Return type:
FieldComponent
- class earthkit.data.field.handler.labels.SimpleLabels¶
Bases:
dict,Labelsdict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- KEYS = ()¶
- NAME = 'labels'¶
- check(owner)¶
Check the FieldComponent for consistency with the owner Field.
- property component¶
Return the FieldComponent.
- abstractmethod dump(*args, **kwargs)¶
Populate the namespace dictionary for this FieldComponent.
- classmethod from_any(data, dict_kwargs=None)¶
Create a SimpleLabels object from any input.
- Parameters:
data (
Any) – The input data from which to create the SimpleLabels instance.dict_kwargs (
dict, optional) – Additional keyword arguments to be passed when creating the instance from a dictionary.
- Returns:
An instance of SimpleLabels. If the input is already an instance of SimpleLabels, it is returned as is. Otherwise, it is assumed to be a specification object and a new SimpleLabels instance is created from it.
- Return type:
- classmethod from_dict(d)¶
Create a SimpleLabels object from a dictionary.
- Parameters:
d (
dict) – Dictionary containing parameter data.- Returns:
The created SimpleLabels instance.
- Return type:
- get(key, default=None, *, astype=None, raise_on_missing=False)¶
Return the value for key if key is in the dictionary, else default.
- get_grib_context(context)¶
Populate the GRIB context dictionary for this FieldComponent.
- pop(key, default=None)¶
D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If the key is not found, return the default if given; otherwise, raise a KeyError.
- remove(*args)¶
- set(*args, **kwargs)¶
Create a new FieldComponent instance with updated data.
- Parameters:
*args – Positional arguments.
**kwargs – Keyword arguments.
- Returns:
The created FieldComponent instance.
- Return type:
FieldComponent
- to_dict()¶