Skip to content

io.ZarrBackend

Import path: earth2studio.io.ZarrBackend

View source on GitHub

Documentation

A backend that supports the zarr format.

Parameters:

  • file_name (str, default: None ) –

    Optional name to provide to the zarr store, if provided then this function will create a directory store with this file name. If none, will create a in-memory store., by default None

  • chunks (dict[str, int], default: {'ensemble': 1, 'time': 1, 'lead_time': 1, 'variable': 1} ) –

    An ordered dict of chunks to use with the data passed through data/coords, by default {}

  • backend_kwargs (dict[str, Any], default: {'overwrite': False} ) –

    Key word arguments for zarr.Group root object, by default {"overwrite": False}

  • zarr_codecs (CompressorsLike, default: None ) –

    Compression codec to use when creating any new arrays. Only effects Zarr 3.0. If None, will use no compressor, by default None

Note

For keyword argument options see: zarr.readthedocs.io/en/latest/api/zarr/index.html#zarr.group

add_array

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

Add an array to the existing zarr group.

Parameters:

  • coords (CoordSystem) –

    Ordered dict of coordinate information.

  • array_name (str) –

    Name to add to zarr group 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 (zarr 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.

  • kwargs (Any, default: {} ) –

    Optional keyword arguments passed to zarr dataset constructor.

write

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

Write data to the current zarr group using the passed array_name.

Parameters:

  • x (Tensor | list[Tensor]) –

    Tensor(s) to be written to zarr store.

  • coords (OrderedDict) –

    Coordinates of the passed data.

  • array_name (str | list[str]) –

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

Examples using earth2studio.io.ZarrBackend