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

Method chunk

xarray/core/dataset.py:2512–2651  ·  view source on GitHub ↗

Coerce all arrays in this dataset into dask arrays with the given chunks. Non-dask arrays in this dataset will be converted to dask arrays. Dask arrays will be rechunked to the given chunk sizes. If neither chunks is not provided for one or more dimensions, chunk

(
        self,
        chunks: T_ChunksFreq = {},  # noqa: B006  # {} even though it's technically unsafe, is being used intentionally here (#4667)
        name_prefix: str = "xarray-",
        token: str | None = None,
        lock: bool = False,
        inline_array: bool = False,
        chunked_array_type: str | ChunkManagerEntrypoint | None = None,
        from_array_kwargs=None,
        **chunks_kwargs: T_ChunkDimFreq,
    )

Source from the content-addressed store, hash-verified

2510 return get_chunksizes(self.variables.values())
2511
2512 def chunk(
2513 self,
2514 chunks: T_ChunksFreq = {}, # noqa: B006 # {} even though it's technically unsafe, is being used intentionally here (#4667)
2515 name_prefix: str = "xarray-",
2516 token: str | None = None,
2517 lock: bool = False,
2518 inline_array: bool = False,
2519 chunked_array_type: str | ChunkManagerEntrypoint | None = None,
2520 from_array_kwargs=None,
2521 **chunks_kwargs: T_ChunkDimFreq,
2522 ) -> Self:
2523 """Coerce all arrays in this dataset into dask arrays with the given
2524 chunks.
2525
2526 Non-dask arrays in this dataset will be converted to dask arrays. Dask
2527 arrays will be rechunked to the given chunk sizes.
2528
2529 If neither chunks is not provided for one or more dimensions, chunk
2530 sizes along that dimension will not be updated; non-dask arrays will be
2531 converted into dask arrays with a single block.
2532
2533 Along datetime-like dimensions, a :py:class:`Resampler` object
2534 (e.g. :py:class:`groupers.TimeResampler` or :py:class:`groupers.SeasonResampler`)
2535 is also accepted.
2536
2537 Parameters
2538 ----------
2539 chunks : int, tuple of int, "auto" or mapping of hashable to int or a Resampler, optional
2540 Chunk sizes along each dimension, e.g., ``5``, ``"auto"``, or
2541 ``{"x": 5, "y": 5}`` or ``{"x": 5, "time": TimeResampler(freq="YE")}`` or
2542 ``{"time": SeasonResampler(["DJF", "MAM", "JJA", "SON"])}``.
2543 name_prefix : str, default: "xarray-"
2544 Prefix for the name of any new dask arrays.
2545 token : str, optional
2546 Token uniquely identifying this dataset.
2547 lock : bool, default: False
2548 Passed on to :py:func:`dask.array.from_array`, if the array is not
2549 already as dask array.
2550 inline_array: bool, default: False
2551 Passed on to :py:func:`dask.array.from_array`, if the array is not
2552 already as dask array.
2553 chunked_array_type: str, optional
2554 Which chunked array type to coerce this datasets' arrays to.
2555 Defaults to 'dask' if installed, else whatever is registered via the `ChunkManagerEntryPoint` system.
2556 Experimental API that should not be relied upon.
2557 from_array_kwargs: dict, optional
2558 Additional keyword arguments passed on to the `ChunkManagerEntrypoint.from_array` method used to create
2559 chunked arrays, via whichever chunk manager is specified through the `chunked_array_type` kwarg.
2560 For example, with dask as the default chunked array type, this method would pass additional kwargs
2561 to :py:func:`dask.array.from_array`. Experimental API that should not be relied upon.
2562 **chunks_kwargs : {dim: chunks, ...}, optional
2563 The keyword arguments form of ``chunks``.
2564 One of chunks or chunks_kwargs must be provided
2565
2566 Returns
2567 -------
2568 chunked : xarray.Dataset
2569

Calls 7

_replaceMethod · 0.95
either_dict_or_kwargsFunction · 0.90
guess_chunkmanagerFunction · 0.90
_maybe_chunkFunction · 0.90
keysMethod · 0.80
itemsMethod · 0.80
copyMethod · 0.45