Skip to content

io.NetCDF4Backend

Import path: earth2studio.io.NetCDF4Backend

View source on GitHub

Documentation

A backend that supports the NetCDF4 format.

Parameters:

  • file_name (str) –

    description

  • backend_kwargs (dict[str, Any], default: {'mode': 'r+', 'diskless': False} ) –

    Key word arguments for netCDF.Dataset root object, by default

Note

For keyword argument options see: unidata.github.io/netcdf4-python/#netCDF4.Dataset

add_array

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

Add an array to the existing netcdf Dataset.

Parameters:

  • coords (CoordSystem) –

    Ordered dict of coordinate information.

  • array_name (str) –

    Name to add to netcdf Dataset for the new array. Can optionally be a list of array_names.

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

    Optional data to initialize the array with. If None, then the netcdf array is initialized with zeros. 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.

write

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

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

Parameters:

  • x (Tensor | list[Tensor]) –

    Tensor(s) to be written to netCDF group.

  • 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.NetCDF4Backend