earthkit.data.readers.xarray.variable

Classes

FilteredVariable

Represents a filtered variable based on metadata.

Variable

Represents a variable in an xarray dataset.

Module Contents

class earthkit.data.readers.xarray.variable.FilteredVariable(variable, **kwargs)

Represents a filtered variable based on metadata.

variable

The variable to filter.

Type:

Variable

kwargs

Metadata to filter the variable.

Type:

Any

fields()

Filter the fields of a variable based on metadata.

kwargs
property length: int

Return the length of the filtered variable.

variable
class earthkit.data.readers.xarray.variable.Variable(*, ds, variable, coordinates, grid, time, metadata)

Represents a variable in an xarray dataset.

ds

The xarray dataset.

Type:

xr.Dataset

variable

The data array representing the variable.

Type:

xr.DataArray

coordinates

List of coordinates associated with the variable.

Type:

List[Any]

grid

The grid associated with the variable.

Type:

Any

time

The time dimension associated with the variable.

Type:

Any

metadata

Metadata associated with the variable.

Type:

Dict[str, Any]

by_name
coordinates
ds
grid
length
match(**kwargs)

Match the variable based on the given metadata.

Parameters:

**kwargs (Any) – Metadata to match.

Returns:

A tuple containing a boolean indicating if the match was successful and the remaining metadata.

Return type:

Tuple[bool, Optional[Dict[str, Any]]]

property name: str

Return the name of the variable.

names
sel(missing, **kwargs)

Select a subset of the variable based on the given coordinates.

Parameters:
  • missing (Dict[str, Any]) – Dictionary to store missing coordinates.

  • **kwargs (Any) – Coordinates to select.

Returns:

The selected subset of the variable.

Return type:

Optional[Variable]

shape
time
variable