earthkit.data.core.field

Classes

Field

A class to represent a field in Earthkit.

Module Contents

class earthkit.data.core.field.Field(*, data=None, time=None, parameter=None, geography=None, vertical=None, ensemble=None, proc=None, labels=None)

Bases: earthkit.data.core.Base

A class to represent a field in Earthkit.

A Field is a horizontal slice of the atmosphere/hydrosphere at a given time.

A Field object is composed of several components:

  • data: the data values of the field

  • time: the temporal structure of the field (see TimeBase)

  • parameter: the parameter of the field (see: ParameterBase)

  • geography: the geography of the field (see: GeographyBase)

  • vertical: the vertical structure of the field (see: VerticalBase)

  • ensemble: the ensemble component of the field (see: EnsembleBase)

  • proc: the processing component of the field (see: ProcBase)

  • labels: the labels of the field (see: SimpleLabels)

Field is not polymorphic, but its components are. The components are meant to be format independent, but they can have format specific implementations with the same interface. For example, the geography component of a GRIB field can have a different implementation than the geography component of a NetCDF field.

Creating Fields

To create a new Field object use the factory methods: from_dict(), from_field() or from_components().

Values

Metadata

The metadata of a field can be divided into three categories:

  • Core component metadata: the metadata that is stored in the components of the field. Each component can be accessed by the corresponding property of the field, such as time for the time component. The metadata of a component can be accessed by the methods of the component, e.g.

    >>> field.time.valid_datetime()
    

    The same metadata can also be accessed by the get() method of the field with the appropriate key, e.g.

    >>> field.get("time.valid_datetime")  # equivalent to field.time.valid_datetime()
    
  • Labels: the “labels” component of the field is a dictionary-like object that can store any user defined key-value pairs. It can be accessed by the labels property of the field, e.g.

    >>> field.labels # returns the labels component of the field
    >>> field.labels["my_key"] # returns the value of label "my_key"
    >>> field.labels.get("my_key")  # equivalent to field.labels["my_key"]
    >>> field.get("labels.my_key")  # equivalent to field.labels["my_key"]
    
  • Raw metadata: the field can also store raw metadata that is not part of any component or labels. For example if the field is created from a GRIB message the raw metadata can include all the ecCodes GRIB keys. To access the raw metadata use the get() method by prefixing the raw metadata key with “metadata.”, e.g.

    >>> field.get("metadata.shortName")
    

    The same can also be accessed by the metadata method of the field, which is can only access the raw metadata of the field, e.g.

    >>> field.metadata("shortName")
    >>> field.metadata("metadata.shortName")
    

    Please not that while get() has a default argument to specify a default value when the key is not found, the metadata() method does not have this argument and will raise a KeyError if the key is not found in the raw metadata.

    Currently it is not possible to inspect what raw metadata keys are available in a field, but this feature might be added in the future.

Modifying Fields

Field arithmetic

The Field class supports arithmetic operations such as addition, subtraction, multiplication

property array_namespace

Return the array namespace of the field.

Type:

ArrayNamespace

data(keys=('lat', 'lon', 'value'), flatten=False, dtype=None, index=None)

Return the values and/or the geographical coordinates for each grid point.

Parameters:
  • keys (str, list or tuple) – Specifies the type of data to be returned. Any combination of “lat”, “lon” and “value” is allowed here.

  • flatten (bool) – When it is True a flat array per key is returned. Otherwise an array with the field’s shape is returned for each key.

  • dtype (str, array.dtype or None) – Typecode or data-type of the arrays. When it is None the default type used by the underlying data accessor is used. For GRIB it is float64.

  • index (array indexing object, optional) – The index of the values and or the latitudes/longitudes to be extracted. When it is None all the values and/or coordinates are extracted.

Returns:

An multi-dimensional array containing one array per key is returned (following the order in keys). The underlying array format of the field is used. When keys is a single value only the array belonging to the key is returned.

Return type:

array-like

See also

geography, to_numpy, value

Examples

How-to examples for the data() method can be found in the following notebooks:

Other examples:

>>> import earthkit.data as ekd
>>> fl = ekd.from_source("file", "docs/how-tos/test6.grib").to_fieldlist()
>>> d = fl[0].data()
>>> d.shape
(3, 7, 12)
>>> d[0, 0, 0]  # first latitude
90.0
>>> d[1, 0, 0]  # first longitude
0.0
>>> d[2, 0, 0]  # first value
272.56417847
>>> d = fl[0].data(keys="lon")
>>> d.shape
(7, 12)
>>> d[0, 0]  # first longitude
0.0
property default_ls_keys

Return the default keys to be used for the ls() method.

Type:

list

describe(component=all, filter=None, **kwargs)

Generate dump with all the metadata keys belonging to namespace.

In a Jupyter notebook it is represented as a tabbed interface.

Parameters:

component (str, list, tuple, None or all) –

The component(s) to include. The following values have a special meaning:

  • all: all the available components will be used.

**kwargs: dict, optional

Other keyword arguments used for testing only

Returns:

Dict-like object with one item s per component. In a Jupyter notebook represented as a tabbed interface to browse the dump con stents.

Return type:

NamespaceDump

See also

namespace

Examples

GRIB: listing contents

property ensemble

Return the ensemble component of the field.

Type:

Ensemble

classmethod from_components(data=None, values=None, time=None, parameter=None, geography=None, vertical=None, ensemble=None, proc=None, labels=None)

Create a Field from components.

Parameters:
  • data (DataFieldComponent, dict) – The data of the field.

  • time (Time, TimeFieldComponent, dict) – The time of the field.

  • parameter (Parameter, ParameterFieldComponent, dict) – parameter component in the field.

  • geography (Geography, GeographyFieldComponent, dict or None) – The geography of the field.

  • vertical (Vertical, VerticalFieldComponent, dict or None) – The vertical level of the field.

  • ensemble (Ensemble, EnsembleFieldComponent, dict or None) – The ensemble specification of the field.

  • proc (Proc, ProcFieldComponent, dict or None) – The processing specification of the field.

  • labels (SimpleLabels, dict or None) – The labels of the field.

Returns:

A new Field with the components copied from the original field or specified in the keyword arguments.

Return type:

Field

classmethod from_dict(d)

Create a Field from a dictionary.

Parameters:

d (dict) – The dictionary to create the Field from. Keys not used by any component are added to the labels.

Returns:

A new Field created from the dictionary.

Return type:

Field

classmethod from_field(field, data=None, time=None, parameter=None, geography=None, vertical=None, ensemble=None, proc=None, labels=None)

Create a Field from another Field.

Parameters:
  • field (Field) – The field to copy from.

  • data (DataFieldComponent, dict or None) – The new data of the field. When specified it is used instead of the data in the field

  • time (TimeBase, TimeFieldComponentHandler, dict or None) – The new time of the field. When specified it is used instead of the time component in the field. See: TimeBase.

  • parameter (ParameterBase, ParameterFieldComponentHandler, dict or None) – The new parameter of the field. When specified it is used instead of the parameter component in the field.

  • geography (GeographyBase, GeographyFieldComponentHandler, dict or None) – The new geography of the field. When specified it is used instead of the geography component in the field.

  • vertical (VerticalBase, VerticalFieldComponentHandler, dict or None) – The new vertical level of the field. When specified it is used instead of the vertical component in the field.

  • ensemble (EnsembleBase, EnsembleFieldComponentHandler, dict or None) – The new ensemble specification of the field. When specified it is used instead of the ensemble component in the field.

  • proc (ProcBase, dict, ProcFieldComponentHandler or None) – The new processing specification of the field. When specified it is used instead of the processing component in the field.

  • labels (SimpleLabels, dict or None) – The new labels of the field. When specified it is used instead of the labels in the field.

Returns:

A new Field with the components copied from the original field or specified in the keyword arguments.

Return type:

Field

property geography

Return the geography component of the field.

Returns:

The geography component of the field.

Return type:

GeographyBase

get(keys=None, default=None, *, astype=None, raise_on_missing=False, collections=None, output='auto', flatten_dict=False, remapping=None, patch=None)

Return the values for the specified keys.

Parameters:
  • keys (str, list or tuple) – Specify the field metadata keys to extract. Can be a single key (str) or multiple keys as a list/tuple of str. Keys are assumed to be of the form “component.key”. For example, “time.valid_datetime” or “parameter.name”. Keys from the raw metadata (if any) can be accessed using the “metadata.key” syntax. For example, when a Field was created from a GRIB message, the ecCodes GRIB keys can be accessed as “metadata.shortName” or “metadata.level”.

  • 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. It is only applied to keys returning a single value.

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

  • collections (str, list or tuple) – Specify the metadata collections to extract. Can be a single collection (str) or multiple collections as a list/tuple of str. A collection is a component of the field (e.g. “time”, “parameter”, “geography”, etc.) as a dictionary. It can also be a collection within the raw “metadata” component. For example, when a Field was created from a GRIB message, the ecCodes GRIB “namespaces” can be accessed as collections, e.g. “metadata.mars” means the ecCodes GRIB “mars” namespace. The returned value for a collection is a dictionary with the keys and values in the collection. To flatten the returned dictionary for a collection, use the output==dict and flatten_dict=True options.

  • output (type, str) –

    Specify the output type. Can be:

    • ”auto” (default):
      • when keys is a str returns a single value

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

    • list or “list”: returns a list of values.

    • tuple or “tuple”: returns a tuple of values.

    • dict or “dict”: returns a dictionary with keys and their values.

    Other types are not supported.

  • flatten_dict (bool) – When True and output is dict, if any of the values in the returned dict is itself a dict, it is flattened to depth 1 by concatenating the keys with a dot. For example, if the returned dict is {"a": {"x": 1, "y": 2}, "b": 3}, it becomes {"a.x": 1, "a.y": 2, "b": 3}. This option is ignored when output is not dict.

  • remapping (dict, optional) –

    Create new metadata keys from existing ones. E.g. to define a new key “param_level” as the concatenated value of the “parameter.variable” and “vertical.level” keys use:

    remapping={"param_level": "{parameter.variable}{vertical.level}"}
    

  • patch (dict, optional) – A dictionary of patch to be applied to the returned values.

Returns:

The values for the specified keys. The structure of the returned value(s) depends on the output and flatten_dict parameters.

Return type:

single value, list, tuple or dict

Raises:

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

Examples

>>> import earthkit.data as ekd
>>> f = ekd.from_source("sample", "test.grib").to_fieldlist()[0]
>>> f.get("parameter.variable")
'2t'

Get multiple keys as a list/tuple of values:

>>> f.get(["parameter.variable", "parameter.units"])
['2t', 'K']
>>> f.get(("parameter.variable", "parameter.units"))
('2t', 'K')

Get multiple keys as a dictionary:

>>> f.get(["parameter.variable", "parameter.units"], output="dict")
{'parameter.variable': '2t', 'parameter.units': 'K'}

Get collections:

>>> f.get(collections="time")
{'base_datetime': datetime.datetime(2020, 5, 13, 0, 0),
'step': datetime.timedelta(hours=0),
'valid_datetime': datetime.datetime(2020, 5, 13, 0, 0)}
>>> f.get(collections=["time", "parameter"])
[{'base_datetime': datetime.datetime(2020, 5, 13, 0, 0),
'step': datetime.timedelta(hours=0 ),
'valid_datetime': datetime.datetime(2020, 5, 13, 0, 0)},
{'variable': '2t',
'units': 'K'}]
>>> f.get(collections=["time", "parameter"], dict=True)
{'time': {'base_datetime': datetime.datetime(2020, 5, 13, 0, 0),
'step': datetime.timedelta(hours=0 ),
'valid_datetime': datetime.datetime(2020, 5, 13, 0, 0)},
'parameter': {'variable': '2t',
'units': 'K'}}

Use output=dict and flatten_dict=True to flatten the returned dictionary for collections:

>>> f.get(collections=["time"], output="dict", flatten_dict=True)
{'time.base_datetime': datetime.datetime(2020, 5, 13, 0, 0),
'time.step': datetime.timedelta(hours=0),
'time.valid_datetime': datetime.datetime(2020, 5, 13, 0, 0)}

Get the ecCodes GRIB “mars” namespace as a collection from the raw metadata (result trimmed for brevity): >>> f.get(collections=”metadata.mars”, output=”dict”) {“metadata.mars”: {‘class’: ‘od’, ‘date’: 20200513, ‘expver’: ‘0001’}}

Mix keys and collections (result trimmed for brevity):

>>> f.get(keys="metadata.shortName", collections="metadata.mars", output="dict")
{'metadata.shortName': '2t', 'metadata.mars': {'class': 'od', 'date': 20200513, 'expver': '0001'}}
>>> f.get(keys="metadata.shortName", collections="metadata.mars", output="dict", flatten_dict=True)
{'metadata.shortName': '2t',
'metadata.mars.class': 'od',
'metadata.mars.date': 20200513,
'metadata.mars.expver': '0001'}
head(*args, **kwargs)

Generate a one row summary of the Field using a set of metadata keys.

Same as calling ls.

Parameters:
  • *args (tuple) – Positional arguments passed to ls.

  • **kwargs (dict, optional) – Other keyword arguments passed to ls.

Returns:

See ls.

Return type:

Pandas DataFrame

See also

ls, tail

property labels

Return the labels of the field.

Returns:

The labels of the field.

Return type:

SimpleLabels

ls(n=None, keys='default', extra_keys=None, collections=None)

Generate a one row summary of the Field using a set of metadata keys.

Parameters:
  • n (int, None) – This parameter is ignored since the summary is generated for a single field. It is only used for compatibility with the earthkit.data.core.fieldlist.FieldList.ls() method.

  • keys (list of str, dict, None) – The metadata keys to extract. If keys="default", a built-in default set of keys is used. To specify a column title for each key in the output use a dict as a mapping from the keys to the column titles.

  • extra_keys (list of str, dict, None) – List of additional keys on top of keys. To specify a column title for each key in the output use a dict as a mapping from the keys to the column titles.

  • collections (str, list of str, None) – The collections to extract. Can be a single collection (str) or multiple collections as a list of str. A collection is a component of the field (e.g. “time”, “parameter”, “geography”, etc.) as a dictionary. It can also be a collection within the raw “metadata” component. For example, when a Field was created from a GRIB message, the ecCodes GRIB “namespaces” can be accessed as collections, e.g. “metadata.mars” means the ecCodes GRIB “mars” namespace.

Returns:

DataFrame with one row per Field.

Return type:

Pandas DataFrame

See also

head, tail

message()

Return a buffer containing the encoded message associated with the field.

Only available for fields generated from a message based format (e.g. GRIB). Once the field metadata is modified by calling set() the link to the original message is lost and this method will return None.

Return type:

bytes

metadata(keys, *, astype=None, output='auto', remapping=None, patch=None)

Return the raw metadata values.

Parameters:
  • keys (str, list or tuple) – Specify the raw metadata keys to extract. Can be a single key (str) or multiple keys as a list/tuple of str. Keys can be optionally prefixed with “metadata.”. For example, if the raw metadata has the key “shortName”, it can also be specified as “metadata.shortName”.

  • 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. It is only applied to keys returning a single value.

  • output (type, str) –

    Specify the output type. Can be:

    • ”auto” (default):
      • when keys is a str returns a single value

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

    • list or “list”: returns a list of values.

    • tuple or “tuple”: returns a tuple of values.

    • dict or “dict”: returns a dictionary with keys and their values.

    Other types are not supported.

  • remapping (dict, optional) –

    Create new metadata keys from existing ones. E.g. to define a new key “param_level” as the concatenated value of the “param” and “level” keys use:

    remapping={"param_level": "{param}{level}"}
    

  • patch (dict, optional) – A dictionary of patch to be applied to the returned values.

Returns:

The values for the specified keys. The structure of the returned value(s) depends on the output and flatten_dict parameters.

Return type:

single value, list, tuple or dict

Raises:

KeyError – If any of keys is not found in the raw metadata.

Examples

>>> import earthkit.data as ekd
>>> fl = ekd.from_source("sample", "test.grib").to_fieldlist()
>>> f = fl[0]
>>> f.metadata("shortName")
'2t'
>>> f.metadata(["shortName", "units"])
['2t', 'K']
>>> f.metadata(("shortName", "units"))
('2t', 'K')
property parameter

Return the parameter component of the field.

Returns:

The parameter component of the field.

Return type:

ParameterBase

property proc

Return the proc component of the field.

Returns:

The proc component of the field.

Return type:

ProcBase

set(*args, **kwargs)

Return a new field with the specified metadata keys set to the given values.

Parameters:
  • *args (tuple) –

    Positional arguments used to specify the metadata keys and values to set. Each argument can be a dict with keys and values to set. When multiple dicts are given they are merged together with the latter dicts taking precedence over the former ones.

    >>> field.set({"parameter.variable": "t"})
    >>> field.set({"parameter.variable": "t", "vertical.level": 1000})
    

    New data values can be set by using the “data” or “values” key with the new values as a value. For example,

    >>> field.set(data=new_values_array)
    

    will replace the data values in the field with the values in new_values_array.

    Only high-level metadata keys (and “data” or “values”) are allowed here, i.e. keys that belong to a component. Modifying raw metadata keys is not allowed and we cannot use them in set() with or without the “metadata.” prefix. For example, although in fields generated from GRIB we can use the “metadata.shortName” key in the get() method to access the “shortName” key we cannot use it in set().

    Entire components can be set by using the component name as a key and the component object or the equivalent dict as a value. For example,

    >>> field.set(parameter={"variable": "t", "units": "K"})
    

    will replace the entire parameter component.

    Date and time related keys from the “time” field component can take different formats of date/time/duration values as input. For example, when setting by “time.base_datetime” the following calls are equivalent:

    >>> fl.set({ "time.base_datetime": "2018-08-01T12"})
    >>> fl.set({ "time.base_datetime": datetime(2018, 8, 1, 12, 0) })
    

    Similarly, when setting “time.step” the following calls are equivalent.

    >>> fl.set({ "time.step": "6h"})
    >>> fl.set({ "time.step": 6})
    >>> fl.set({ "time.step": "360m"})
    >>> fl.set({ "time.step": timedelta(hours=6)})
    

    Values are assumed to be in hours when the unit is not specified. When the unit is specified it can be either “h”, “m” or “s” for hours, minutes or seconds, respectively.

  • **kwargs (dict) – Keyword arguments used to specify the metadata keys and values to set. They take precedence over the positional arguments. The same rules for the keys and values as for the positional arguments apply here.

Returns:

A new field with the specified metadata keys set to the given values.

Return type:

Field

Notes

When the field is created from a GRIB message, calling set() copies the associated GRIB message into the new field without any modifications. Since it is now out of sync with the new field’s components, the new field will not provide access to any GRIB metadata neither via get() nor via metadata(). Additionally, when calling message() on the new field, None is returned. (Use sync() to synchronize the associated GRIB message to the new field and expose the GRIB metadata keys again).

>>> import earthkit.data as ekd
>>> fl = ekd.from_source("sample", "test.grib").to_fieldlist()
>>> f = fl[0]
>>> f1 = f.set({"parameter.variable": "msl", "parameter.units": "Pa"})
>>> f1.get("metadata.shortName")
None
>>> f1.metadata("shortName")
KeyError: 'metadata.shortName' not found in field
>>> f1.message()
None

However, if only the labels or the values are set (the latter via the “data” or “values” keys), the new field returned by set() is still linked to the original GRIB message and the GRIB specific keys in the raw metadata are still accessible. If the values were modified, message() will return the original GRIB message updated with the modified data values.

>>> import earthkit.data as ekd
>>> fl = ekd.from_source("sample", "test.grib").to_fieldlist()
>>> f = fl[0]
>>> f1 = f.set(values=f.values()+1)
>>> f1.get("metadata.shortName")
"2t"
>>> f1.metadata("shortName")
"2t"
>>> f1.message()
<grib message with modified data values>

Examples

See the how-to examples for the set() method in the following notebook:

Further examples:

>>> import earthkit.data as ekd
>>> fl = ekd.from_source("sample", "test.grib").to_fieldlist()
>>> f = fl[0]
>>> f2 = f.set({"parameter.variable": "10t", "parameter.units": "K"})
>>> f2.get(["parameter.variable", "parameter.units"])
['10t', 'K']
property shape

Return the shape of the field.

Type:

tuple

sync()

Return a field with the raw metadata in sync with the field’s components.

When a field is created from a GRIB message, it stores this associated GRIB message/handle and the raw GRIB metadata is extracted from it e.g. when calling get(). When the field’s components are modified using set(), the GRIB message is copied into the new field but not modified. Since it is now out of sync with the new field’s components, the new field will not provide access to any GRIB metadata either via get() or via metadata(). When sync() is called on such a field the GRIB message is re-encoded using the field’s components and the raw GRIB metadata will become available again and in sync with the field’s components.

Returns:

A field with the raw metadata in sync with the field’s components. If the field is not associated with a GRIB message or if the raw metadata is already in sync, the original field is returned.

Return type:

Field

Examples

>>> import earthkit.data as ekd
>>> fl = ekd.from_source("sample", "test.grib").to_fieldlist()
>>> f = fl[0]
>>> f1 = f.set({"parameter.variable": "msl", "parameter.units": "Pa"})
>>> f1.get("metadata.shortName")
None
>>> f1.metadata("shortName")
KeyError: 'metadata.shortName' not found in field
>>> f2 = f1.sync()
>>> f2.get("metadata.shortName")
'msl'
>>> f2.metadata("shortName")
'msl'
tail(*args, **kwargs)

Generate a one row summary of the Field using a set of metadata keys.

Same as calling ls.

Parameters:
  • *args (tuple) – Positional arguments passed to ls.

  • **kwargs (dict, optional) – Other keyword arguments passed to ls.

Returns:

See ls.

Return type:

Pandas DataFrame

See also

ls, tail

property time

Return the time component of the field.

Returns:

The time component of the field.

Return type:

TimeBase

to_array(flatten=False, dtype=None, copy=True, array_namespace=None, device=None, index=None)

Return the values stored in the field.

Parameters:
  • flatten (bool) – When it is True a flat array is returned. Otherwise an array with the field’s shape is returned.

  • dtype (str, array.dtype or None) – Typecode or data-type of the array. When it is None the default type used by the underlying data accessor is used. For GRIB it is float64.

  • copy (bool) – When it is True a copy of the data is returned. Otherwise a view is returned where possible.

  • array_namespace (str, array_namespace or None) – The array namespace to be used. When it is None the underlying array format of the field is used. New in version 0.19.0.

  • device (str or None) – The device where the array will be allocated. When it is None the default device is used.

  • index (array indexing object, optional) – The index of the values to be extracted. When it is None all the values are extracted.

Returns:

Field values.

Return type:

array-array

to_array_field(array_namespace=None, device=None, flatten=False, dtype=None)
to_field(array=True)

Return the field itself.

to_fieldlist(fields=None)
to_numpy(flatten=False, dtype=None, copy=True, index=None)

Return the values stored in the field as an ndarray.

Parameters:
  • flatten (bool) – When it is True a flat ndarray is returned. Otherwise an ndarray with the field’s shape is returned.

  • dtype (str, numpy.dtype or None) – Typecode or data-type of the array. When it is None the default type used by the underlying data accessor is used. For GRIB it is float64.

  • copy (bool) – When it is True a copy of the data is returned. Otherwise a view is returned where possible.

  • index (ndarray indexing object, optional) – The index of the values to be extracted. When it is None all the values are extracted

Returns:

Field values

Return type:

ndarray

to_pandas(*args, **kwargs)

Convert the Field into a Pandas DataFrame.

Parameters:
  • *args (tuple) – Positional arguments passed to FieldList.to_pandas.

  • **kwargs (dict, optional) – Other keyword arguments passed to FieldList.to_pandas.

Return type:

Pandas DataFrame

to_target(target, *args, **kwargs)

Write the field into a target object.

Parameters:
  • target (object) – The target to write the field into.

  • *args (tuple) – Positional arguments used to specify the target object.

  • **kwargs (dict, optional) – Other keyword arguments used to write the field into the target object.

Examples

How-to examples for the to_target() method can be found in the following notebooks:

to_xarray(*args, **kwargs)

Convert the Field into an Xarray Dataset.

Parameters:
  • *args (tuple) – Positional arguments passed to FieldList.to_xarray.

  • **kwargs (dict, optional) – Other keyword arguments passed to FieldList.to_xarray.

Return type:

Xarray Dataset

property values

Return the values of the fields as a flat array.

Returns:

Flat array containing the field values without performing any copying or conversion. The underlying array format of the field is used. For GRIB it is a numpy array.

Return type:

array-like

See also

to_numpy, to_array

Examples

>>> import earthkit.data as ekd
>>> f = ekd.from_source("sample", "test.grib").to_fieldlist()[0]
>>> v = f.values
>>> v.shape
(209,)
>>> v[0][:3]
array([262.78027344, 267.44726562, 268.61230469])
property vertical

Return the vertical component of the field.

Returns:

The vertical component of the field.

Return type:

VerticalBase