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.

Deprecated since version 2.16.0: Data sources without the DataSource.searchable_facets attribute are deprecated and will no longer be supported in ESMValCore v2.18.0.

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.io.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, FacetValue]#

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() → iris.cube.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.

searchable_facets

Facets that can be used to search for data.

Methods:

find_data(**facets)

Find data.

debug_info: str#

A string containing debug information when no data is found.

find_data(**facets: FacetValue) → Iterable[DataElement][source]#

Find data.

Parameters:

**facets (FacetValue) – 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.

property searchable_facets: frozenset[str]#

Facets that can be used to search for data.

The values of these facets can be passed to find_data() to select data and are available in the facets of the data elements that are found. For example, these are the facets in the templates of a esmvalcore.io.local.LocalDataSource.

Added in version 2.16.0.