esmvalcore.io.xarray#

Access data using xarray.open_dataset().

To use this module, copy one of the following configuration files to your configuration directory:

  1. data-cds-era5.yml

    Enable access to ERA5 data stored in the Copernicus Climate Data Store (CDS):

    esmvaltool config copy data-cds-era5.yml
    

    The file content is:

    Listing 21 Contents of data-cds-era5.yml#
    # Read ERA5 data in zarr format on Climate Data Store.
    # Go to
    # https://github.com/ecmwf-training/dss-notebooks/blob/main/datasets%2Freanalysis-era5-single-levels%2Farco-access.ipynb
    # for further information.
    projects:
      native6:
        data:
          cds-era5-zarr:
            type: esmvalcore.io.xarray.XarrayDataSource
            # Available stores:
            # - Geo-chunked surface levels data (optimised for time-series at a single location):
            #   https://arco.datastores.ecmwf.int/cadl-arco-geo-002/arco/reanalysis_era5_single_levels/sfc/geoChunked.zarr
            # - Time-chunked surface levels data (optimised for global map at a single time step):
            #   https://arco.datastores.ecmwf.int/cadl-arco-time-002/arco/reanalysis_era5_single_levels/sfc/timeChunked.zarr
            # - Geo-chunked wave data (optimised for time-series at a single location):
            #   https://arco.datastores.ecmwf.int/cadl-arco-geo-003/arco/reanalysis_era5_single_levels/wav/geoChunked.zarr
            # - Time-chunked wave data (optimised for global map at a single time step):
            #   https://arco.datastores.ecmwf.int/cadl-arco-time-003/arco/reanalysis_era5_single_levels/wav/timeChunked.zarr
            store: "https://arco.datastores.ecmwf.int/cadl-arco-time-002/arco/reanalysis_era5_single_levels/sfc/timeChunked.zarr"
            options:
              chunks: "auto"
              consolidated: true
              engine: "zarr"
              storage_options:
                headers:
                  Authorization: "Bearer <INSERT YOUR CDS API KEY HERE>"
            variables:
              t2m: tas
            facets:
              dataset: "ERA5"
              frequency: "1hr"
    

    Then edit the copied file and replace the text <INSERT YOUR CDS API KEY HERE> with your personal CDS API key.

  2. data-gcs-era5.yml

    Enable access to ERA5 data stored in Google Cloud Storage:

    esmvaltool config copy data-gcs-era5.yml
    

    Install gcsfs alongside ESMValCore to use this data source.

Classes:

XarrayDataSource(name, project, priority, ...)

Data source that can find data using xarray.

XarrayDataset(name, facets, store, options, ...)

A dataset that can load data using xarray.

class esmvalcore.io.xarray.XarrayDataSource(name: str, project: str, priority: int, variables: dict[str, str], facets: Facets, store: str, options: dict[str, Any] = <factory>)[source]#

Bases: DataSource

Data source that can find data using xarray.

Attributes:

debug_info

A string containing debug information when no data is found.

facets

Facets that will be added to the data elements found using this data source.

name

A name identifying the data source.

options

Options to use when opening the data store.

priority

The priority of the data source.

project

The project that the data source provides data for.

store

The store used to load the data.

variables

Mapping between the dataset variable name and ESMValCore short_name.

Methods:

find_data(**facets)

Find data.

Parameters:
debug_info: str = ''#

A string containing debug information when no data is found.

facets: Facets#

Facets that will be added to the data elements found using this data source.

find_data(**facets: FacetValue) list[XarrayDataset][source]#

Find data.

Parameters:

**facets (FacetValue) – Find data matching these facets.

Returns:

A list of data elements that have been found.

Return type:

list[XarrayDataset]

name: str#

A name identifying the data source.

options: dict[str, Any]#

Options to use when opening the data store.

priority: int#

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

project: str#

The project that the data source provides data for.

store: str#

The store used to load the data.

variables: dict[str, str]#

Mapping between the dataset variable name and ESMValCore short_name.

class esmvalcore.io.xarray.XarrayDataset(name: str, facets: Facets, store: str, options: dict[str, Any] = <factory>)[source]#

Bases: DataElement

A dataset that can load data using xarray.

Attributes:

attributes

Attributes are key-value pairs describing the data.

facets

Facets are key-value pairs that were used to find this data.

name

A unique name identifying the dataset.

options

Options to use when opening the data.

store

The data store containing the data.

Methods:

prepare()

Prepare the data for access.

to_iris()

Load the data as Iris cubes.

Parameters:
  • name (str)

  • facets (Facets)

  • store (str)

  • options (dict[str, Any])

property attributes: dict[str, Any]#

Attributes are key-value pairs describing the data.

facets: Facets#

Facets are key-value pairs that were used to find this data.

name: str#

A unique name identifying the dataset.

options: dict[str, Any]#

Options to use when opening the data.

prepare() None[source]#

Prepare the data for access.

Return type:

None

store: str#

The data store containing the data.

to_iris() iris.cube.CubeList[source]#

Load the data as Iris cubes.

Returns:

The loaded data.

Return type:

iris.cube.CubeList