esmvalcore.io.protocol#

Protocols for accessing data.

This module defines the DataSource and DataElement protocols for finding and loading data. A data source can be used to find data elements matching specific facets. A data element represents some data that can be loaded as Iris cubes.

To add support for a new data source, write two classes that implement these protocols and configure the tool to use the newly implemented data source as described in esmvalcore.io.

Classes:

DataElement(*args, **kwargs)

A data element represents some data that can be loaded.

DataSource(*args, **kwargs)

A data source can be used to find data.

class esmvalcore.io.protocol.DataElement(*args, **kwargs)[source]#

Bases: Protocol

A data element represents some data that can be loaded.

An esmvalcore.local.LocalFile is an example of a data element.

Attributes:

attributes

Attributes are key-value pairs describing the data.

facets

Facets are key-value pairs that can be used for searching the data.

name

A unique name identifying the data.

Methods:

prepare()

Prepare the data for access.

to_iris()

Load the data as Iris cubes.

attributes: dict[str, Any]#

Attributes are key-value pairs describing the data.

facets: dict[str, str | Sequence[str] | int]#

Facets are key-value pairs that can be used for searching the data.

name: str#

A unique name identifying the data.

prepare() None[source]#

Prepare the data for access.

Return type:

None

to_iris() CubeList[source]#

Load the data as Iris cubes.

Returns:

The loaded data.

Return type:

iris.cube.CubeList

class esmvalcore.io.protocol.DataSource(*args, **kwargs)[source]#

Bases: Protocol

A data source can be used to find data.

Attributes:

debug_info

A string containing debug information when no data is found.

name

A name identifying the data source.

priority

The priority of the data source.

project

The project that the data source provides data for.

Methods:

find_data(**facets)

Find data.

debug_info: str#

A string containing debug information when no data is found.

find_data(**facets: str | Sequence[str] | int) Iterable[DataElement][source]#

Find data.

Parameters:

**facets (str | Sequence[str] | int) – Find data matching these facets.

Returns:

The data elements that have been found.

Return type:

typing.Iterable of esmvalcore.io.base.DataElement

name: str#

A name identifying the data source.

priority: int#

The priority of the data source. Lower values have priority.

project: str#

The project that the data source provides data for.