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

Function open_mfdataset

xarray/backends/api.py:1373–1708  ·  view source on GitHub ↗

Open multiple files as a single dataset. If combine='by_coords' then the function ``combine_by_coords`` is used to combine the datasets into one before returning the result, and if combine='nested' then ``combine_nested`` is used. The filepaths must be structured according to which

(
    paths: (
        str | os.PathLike | ReadBuffer | NestedSequence[str | os.PathLike | ReadBuffer]
    ),
    chunks: T_Chunks = None,
    concat_dim: (
        str
        | DataArray
        | Index
        | Sequence[str]
        | Sequence[DataArray]
        | Sequence[Index]
        | None
    ) = None,
    compat: CompatOptions | CombineKwargDefault = _COMPAT_DEFAULT,
    preprocess: Callable[[Dataset], Dataset] | None = None,
    engine: T_Engine = None,
    data_vars: (
        Literal["all", "minimal", "different"] | None | list[str] | CombineKwargDefault
    ) = _DATA_VARS_DEFAULT,
    coords=_COORDS_DEFAULT,
    combine: Literal["by_coords", "nested"] = "by_coords",
    parallel: bool = False,
    join: JoinOptions | CombineKwargDefault = _JOIN_DEFAULT,
    attrs_file: str | os.PathLike | None = None,
    combine_attrs: CombineAttrsOptions = "override",
    errors: ErrorOptionsWithWarn = "raise",
    **kwargs,
)

Source from the content-addressed store, hash-verified

1371
1372
1373def open_mfdataset(
1374 paths: (
1375 str | os.PathLike | ReadBuffer | NestedSequence[str | os.PathLike | ReadBuffer]
1376 ),
1377 chunks: T_Chunks = None,
1378 concat_dim: (
1379 str
1380 | DataArray
1381 | Index
1382 | Sequence[str]
1383 | Sequence[DataArray]
1384 | Sequence[Index]
1385 | None
1386 ) = None,
1387 compat: CompatOptions | CombineKwargDefault = _COMPAT_DEFAULT,
1388 preprocess: Callable[[Dataset], Dataset] | None = None,
1389 engine: T_Engine = None,
1390 data_vars: (
1391 Literal["all", "minimal", "different"] | None | list[str] | CombineKwargDefault
1392 ) = _DATA_VARS_DEFAULT,
1393 coords=_COORDS_DEFAULT,
1394 combine: Literal["by_coords", "nested"] = "by_coords",
1395 parallel: bool = False,
1396 join: JoinOptions | CombineKwargDefault = _JOIN_DEFAULT,
1397 attrs_file: str | os.PathLike | None = None,
1398 combine_attrs: CombineAttrsOptions = "override",
1399 errors: ErrorOptionsWithWarn = "raise",
1400 **kwargs,
1401) -> Dataset:
1402 """Open multiple files as a single dataset.
1403
1404 If combine='by_coords' then the function ``combine_by_coords`` is used to combine
1405 the datasets into one before returning the result, and if combine='nested' then
1406 ``combine_nested`` is used. The filepaths must be structured according to which
1407 combining function is used, the details of which are given in the documentation for
1408 ``combine_by_coords`` and ``combine_nested``. By default ``combine='by_coords'``
1409 will be used. Requires dask to be installed. See documentation for
1410 details on dask [1]_. Global attributes from the ``attrs_file`` are used
1411 for the combined dataset.
1412
1413 Parameters
1414 ----------
1415 paths : str or nested sequence of paths
1416 Either a string glob in the form ``"path/to/my/files/*.nc"`` or an explicit list of
1417 files to open. Paths can be given as strings or as pathlib Paths. If
1418 concatenation along more than one dimension is desired, then ``paths`` must be a
1419 nested list-of-lists (see ``combine_nested`` for details). (A string glob will
1420 be expanded to a 1-dimensional list.)
1421 chunks : int, dict, 'auto' or None, optional
1422 Dictionary with keys given by dimension names and values given by chunk sizes.
1423 In general, these should divide the dimensions of each dataset. If int, chunk
1424 each dimension by ``chunks``. By default, chunks will be chosen to match the
1425 chunks on disk. This may impact performance: please see the full documentation
1426 for more details [2]_. This argument is evaluated on a per-file basis, so chunk
1427 sizes that span multiple files will be ignored.
1428 concat_dim : str, DataArray, Index or a Sequence of these or None, optional
1429 Dimensions to concatenate files along. You only need to provide this argument
1430 if ``combine='nested'``, and if any of the dimensions along which you want to

Calls 13

_find_absolute_pathsFunction · 0.90
emit_user_level_warningFunction · 0.90
_nested_combineFunction · 0.90
combine_by_coordsFunction · 0.90
_remove_pathFunction · 0.85
keysMethod · 0.80
valuesMethod · 0.45
addMethod · 0.45
computeMethod · 0.45
closeMethod · 0.45
set_closeMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…