MCPcopy
hub / github.com/pydata/xarray / open_groups

Function open_groups

xarray/backends/api.py:1103–1348  ·  view source on GitHub ↗

Open and decode a file or file-like object, creating a dictionary containing one xarray Dataset for each group in the file. Useful for an HDF file ("netcdf4" or "h5netcdf") containing many groups that are not alignable with their parents and cannot be opened directly with ``open_datatr

(
    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,
)

Source from the content-addressed store, hash-verified

1101
1102
1103def open_groups(
1104 filename_or_obj: T_PathFileOrDataStore,
1105 *,
1106 engine: T_Engine = None,
1107 chunks: T_Chunks = None,
1108 cache: bool | None = None,
1109 decode_cf: bool | None = None,
1110 mask_and_scale: bool | Mapping[str, bool] | None = None,
1111 decode_times: (
1112 bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] | None
1113 ) = None,
1114 decode_timedelta: (
1115 bool | CFTimedeltaCoder | Mapping[str, bool | CFTimedeltaCoder] | None
1116 ) = None,
1117 use_cftime: bool | Mapping[str, bool] | None = None,
1118 concat_characters: bool | Mapping[str, bool] | None = None,
1119 decode_coords: Literal["coordinates", "all"] | bool | None = None,
1120 drop_variables: str | Iterable[str] | None = None,
1121 create_default_indexes: bool = True,
1122 inline_array: bool = False,
1123 chunked_array_type: str | None = None,
1124 from_array_kwargs: dict[str, Any] | None = None,
1125 backend_kwargs: dict[str, Any] | None = None,
1126 **kwargs,
1127) -> dict[str, Dataset]:
1128 """
1129 Open and decode a file or file-like object, creating a dictionary containing one xarray Dataset for each group in the file.
1130
1131 Useful for an HDF file ("netcdf4" or "h5netcdf") containing many groups that are not alignable with their parents
1132 and cannot be opened directly with ``open_datatree``. It is encouraged to use this function to inspect your data,
1133 then make the necessary changes to make the structure coercible to a `DataTree` object before calling `DataTree.from_dict()` and proceeding with your analysis.
1134
1135 Parameters
1136 ----------
1137 filename_or_obj : str, Path, file-like, bytes, memoryview or DataStore
1138 Strings and Path objects are interpreted as a path to a netCDF file or
1139 Zarr store. Bytes and memoryview objects are interpreted as file
1140 contents.
1141 engine : {"netcdf4", "h5netcdf", "zarr", None}, \
1142 installed backend or xarray.backends.BackendEntrypoint, optional
1143 Engine to use when reading files. If not provided, the default engine
1144 is chosen based on available dependencies, by default preferring
1145 "h5netcdf" over "netcdf4" (customizable via ``netcdf_engine_order`` in
1146 ``xarray.set_options()``). A custom backend class (a subclass of
1147 ``BackendEntrypoint``) can also be used.
1148 can also be used.
1149 chunks : int, dict, 'auto' or None, default: None
1150 If provided, used to load the data into dask arrays.
1151
1152 - ``chunks="auto"`` will use dask ``auto`` chunking taking into account the
1153 engine preferred chunks.
1154 - ``chunks=None`` skips using dask. This uses xarray's internally private
1155 :ref:`lazy indexing classes <internal design.lazy indexing>`,
1156 but data is eagerly loaded into memory as numpy arrays when accessed.
1157 This can be more efficient for smaller arrays, though results may vary.
1158 - ``chunks=-1`` loads the data with dask using a single chunk for all arrays.
1159 - ``chunks={}`` loads the data with dask using the engine&#x27;s preferred chunk
1160 size, generally identical to the format&#x27;s chunk size. If not available, a

Callers 8

test_open_groupsMethod · 0.90
test_open_groupsMethod · 0.90
test_open_groupsMethod · 0.90

Calls 5

_resolve_decoders_kwargsFunction · 0.85
itemsMethod · 0.80
updateMethod · 0.45
open_groups_as_dictMethod · 0.45

Tested by 8

test_open_groupsMethod · 0.72
test_open_groupsMethod · 0.72
test_open_groupsMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…