Open and decode a DataTree from a file or file-like object, creating one tree node for each group in the file. Parameters ---------- filename_or_obj : str, Path, file-like, bytes or DataStore Strings and Path objects are interpreted as a path to a netCDF file or Zar
(
filename_or_obj: T_PathFileOrDataStore,
*,
engine: T_Engine = None,
chunks: T_Chunks = None,
cache: bool | None = None,
decode_cf: bool | None = None,
mask_and_scale: bool | Mapping[str, bool] | None = None,
decode_times: (
bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] | None
) = None,
decode_timedelta: (
bool | CFTimedeltaCoder | Mapping[str, bool | CFTimedeltaCoder] | None
) = None,
use_cftime: bool | Mapping[str, bool] | None = None,
concat_characters: bool | Mapping[str, bool] | None = None,
decode_coords: Literal["coordinates", "all"] | bool | None = None,
drop_variables: str | Iterable[str] | None = None,
create_default_indexes: bool = True,
inline_array: bool = False,
chunked_array_type: str | None = None,
from_array_kwargs: dict[str, Any] | None = None,
backend_kwargs: dict[str, Any] | None = None,
**kwargs,
)
| 860 | |
| 861 | |
| 862 | def open_datatree( |
| 863 | filename_or_obj: T_PathFileOrDataStore, |
| 864 | *, |
| 865 | engine: T_Engine = None, |
| 866 | chunks: T_Chunks = None, |
| 867 | cache: bool | None = None, |
| 868 | decode_cf: bool | None = None, |
| 869 | mask_and_scale: bool | Mapping[str, bool] | None = None, |
| 870 | decode_times: ( |
| 871 | bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] | None |
| 872 | ) = None, |
| 873 | decode_timedelta: ( |
| 874 | bool | CFTimedeltaCoder | Mapping[str, bool | CFTimedeltaCoder] | None |
| 875 | ) = None, |
| 876 | use_cftime: bool | Mapping[str, bool] | None = None, |
| 877 | concat_characters: bool | Mapping[str, bool] | None = None, |
| 878 | decode_coords: Literal["coordinates", "all"] | bool | None = None, |
| 879 | drop_variables: str | Iterable[str] | None = None, |
| 880 | create_default_indexes: bool = True, |
| 881 | inline_array: bool = False, |
| 882 | chunked_array_type: str | None = None, |
| 883 | from_array_kwargs: dict[str, Any] | None = None, |
| 884 | backend_kwargs: dict[str, Any] | None = None, |
| 885 | **kwargs, |
| 886 | ) -> DataTree: |
| 887 | """ |
| 888 | Open and decode a DataTree from a file or file-like object, creating one tree node for each group in the file. |
| 889 | |
| 890 | Parameters |
| 891 | ---------- |
| 892 | filename_or_obj : str, Path, file-like, bytes or DataStore |
| 893 | Strings and Path objects are interpreted as a path to a netCDF file or |
| 894 | Zarr store. Bytes and memoryview objects are interpreted as file |
| 895 | contents. |
| 896 | engine : {"netcdf4", "h5netcdf", "zarr", None}, \ |
| 897 | installed backend or xarray.backends.BackendEntrypoint, optional |
| 898 | Engine to use when reading files. If not provided, the default engine |
| 899 | is chosen based on available dependencies, by default preferring |
| 900 | "h5netcdf" over "netcdf4" (customizable via ``netcdf_engine_order`` in |
| 901 | ``xarray.set_options()``). A custom backend class (a subclass of |
| 902 | ``BackendEntrypoint``) can also be used. |
| 903 | chunks : int, dict, 'auto' or None, default: None |
| 904 | If provided, used to load the data into dask arrays. |
| 905 | |
| 906 | - ``chunks="auto"`` will use dask ``auto`` chunking taking into account the |
| 907 | engine preferred chunks. |
| 908 | - ``chunks=None`` skips using dask. This uses xarray's internally private |
| 909 | :ref:`lazy indexing classes <internal design.lazy indexing>`, |
| 910 | but data is eagerly loaded into memory as numpy arrays when accessed. |
| 911 | This can be more efficient for smaller arrays, though results may vary. |
| 912 | - ``chunks=-1`` loads the data with dask using a single chunk for all arrays. |
| 913 | - ``chunks={}`` loads the data with dask using the engine's preferred chunk |
| 914 | size, generally identical to the format's chunk size. If not available, a |
| 915 | single chunk for all arrays. |
| 916 | |
| 917 | See dask chunking for more details. |
| 918 | cache : bool, optional |
| 919 | If True, cache data loaded from the underlying datastore in memory as |
searching dependent graphs…