Skip to content

io.XarrayBackend

Import path: earth2studio.io.XarrayBackend

View source on GitHub

Documentation

An xarray backed IO object.

Parameters:

  • coords (CoordSystem, default: OrderedDict({}) ) –

    Coordinates to initialize the xarray Dataset with. Must be a complete set of coordinates, i.e., the Dataset object should be viewed as (mostly) immutable with the given set of coordinates.

  • xr_kwargs (dict, default: {} ) –

    Optional keyword arguments to pass to the xarray.Dataset constructor.

add_array

add_array(
    coords: CoordSystem,
    array_name: str | list[str],
    data: Tensor | list[Tensor] = None,
    **xr_kwargs: Any
) -> None

Add an array to the existing xarray Dataset.

Parameters:

  • coords (CoordSystem) –

    Ordered dict of coordinate information.

  • array_name (str) –

    Name to add to xarray Dataset for the new array.

  • data (Tensor | list[Tensor], default: None ) –

    Optional data to initialize the array with. If None, then the array is NaN initialized (xarray default). Can also pass a list of tensors, which must match in length to the list of array_names passed. If a list of tensors is passed, it is assumed that each tensor share coords.

  • xr_kwargs (Any, default: {} ) –

    Optional keyword arguments passed to xr.DataArray constructor.

write

write(
    x: Tensor | list[Tensor],
    coords: CoordSystem,
    array_name: str | list[str],
) -> None

Write data to the current xarray Dataset using the passed array_name.

Parameters:

  • x (Tensor | list[Tensor]) –

    Tensor(s) to be written to xarray dataset.

  • coords (OrderedDict) –

    Coordinates of the passed data.

  • array_name (str | list[str]) –

    Name(s) of the array(s) that will be written to.