xugrid.zeros_like#

xugrid.zeros_like(other: DataArray, dtype: DTypeLikeSave | None = None, *, chunks: T_Chunks = None, chunked_array_type: str | None = None, from_array_kwargs: dict[str, Any] | None = None) DataArray[source]#
xugrid.zeros_like(other: Dataset, dtype: DTypeMaybeMapping | None = None, *, chunks: T_Chunks = None, chunked_array_type: str | None = None, from_array_kwargs: dict[str, Any] | None = None) Dataset
xugrid.zeros_like(other: Variable, dtype: DTypeLikeSave | None = None, *, chunks: T_Chunks = None, chunked_array_type: str | None = None, from_array_kwargs: dict[str, Any] | None = None) Variable
xugrid.zeros_like(other: Dataset | DataArray, dtype: DTypeMaybeMapping | None = None, *, chunks: T_Chunks = None, chunked_array_type: str | None = None, from_array_kwargs: dict[str, Any] | None = None) Dataset | DataArray
xugrid.zeros_like(other: Dataset | DataArray | Variable, dtype: DTypeMaybeMapping | None = None, *, chunks: T_Chunks = None, chunked_array_type: str | None = None, from_array_kwargs: dict[str, Any] | None = None) Dataset | DataArray | Variable

Return a new object of zeros with the same shape and type as a given dataarray or dataset.

Parameters:
  • other (DataArray, Dataset or Variable) – The reference object. The output will have the same dimensions and coordinates as this object.

  • dtype (dtype, optional) – dtype of the new array. If omitted, it defaults to other.dtype.

  • chunks (int, "auto", tuple of int or mapping of Hashable to int, optional) – Chunk sizes along each dimension, e.g., 5, "auto", (5, 5) or {"x": 5, "y": 5}.

  • chunked_array_type (str, optional) – Which chunked array type to coerce the underlying data array to. Defaults to ‘dask’ if installed, else whatever is registered via the ChunkManagerEnetryPoint system. Experimental API that should not be relied upon.

  • from_array_kwargs (dict, optional) – Additional keyword arguments passed on to the ChunkManagerEntrypoint.from_array method used to create chunked arrays, via whichever chunk manager is specified through the chunked_array_type kwarg. For example, with dask as the default chunked array type, this method would pass additional kwargs to dask.array.from_array(). Experimental API that should not be relied upon.

Returns:

out – New object of zeros with the same shape and type as other.

Return type:

DataArray, Dataset or Variable

Examples

>>> x = xr.DataArray(
...     np.arange(6).reshape(2, 3),
...     dims=["lat", "lon"],
...     coords={"lat": [1, 2], "lon": [0, 1, 2]},
... )
>>> x
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[0, 1, 2],
       [3, 4, 5]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
>>> xr.zeros_like(x)
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[0, 0, 0],
       [0, 0, 0]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2
>>> xr.zeros_like(x, dtype=float)
<xarray.DataArray (lat: 2, lon: 3)> Size: 48B
array([[0., 0., 0.],
       [0., 0., 0.]])
Coordinates:
  * lat      (lat) int64 16B 1 2
  * lon      (lon) int64 24B 0 1 2

See also

ones_like, full_like