plots.sources.xarray

Classes

XarraySource

A data source for xarray-like inputs, extending Source with additional support

Module Contents

class plots.sources.xarray.XarraySource(dataarray, x=None, y=None, z=None, **kwargs)

Bases: earthkit.plots.sources.single.SingleSource

A data source for xarray-like inputs, extending Source with additional support for identifying x, y, and z dimensions within an xarray Dataset or DataArray.

Parameters:
  • dataarray (xarray.Dataset or xarray.DataArray) – The xarray data to use as the source.

  • x (str or array-like, optional) – The x-coordinate name or values of the data.

  • y (str or array-like, optional) – The y-coordinate name or values of the data.

  • z (str or array-like, optional) – The z-coordinate name or values of the data.

  • u (array-like, optional) – The u-component of the data.

  • v (array-like, optional) – The v-component of the data.

  • crs (cartopy.crs.CRS, optional) – The CRS of the data.

  • style (str, optional) – The style to use when plotting the data.

  • metadata (dict, optional) – Metadata to attach to this Source.

  • **kwargs – Additional metadata keys and values to attach to this Source.

property crs

The CRS of the data.

property data

Return the original xarray data, if provided.

datetime()

Get the datetime of the data.

static extract_u(data, u=None)

Return the u-component values of the data, if found.

static extract_v(data, v=None)

Return the v-component values of the data, if found.

metadata(key, default=None)

Extract metadata from the data.

Parameters:
  • key (str) – The metadata key to extract.

  • default (any, optional) – The default value to return if the key is not found.

to_earthkit()

Convert the data to an earthkit.data.core.Base object.

property z_values

Returns the inferred or provided z values (or color values).