# xarray.open_zarr

### xarray.open_zarr(store, group=None, chunks=Default.token, decode_cf=True, mask_and_scale=True, decode_times=True, concat_characters=True, decode_coords=True, drop_variables=None, consolidated=None, overwrite_encoded_chunks=False, storage_options=None, decode_timedelta=None, use_cftime=None, zarr_format=None, use_zarr_fill_value_as_mask=None, chunked_array_type=None, from_array_kwargs=None, create_default_indexes=True, \*\*kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/backends/zarr.py#L1523-L1721)

Load and decode a dataset from a Zarr store.

The store object should be a valid store for a Zarr group. store
variables must contain dimension metadata encoded in the
\_ARRAY_DIMENSIONS attribute or must have NCZarr format.

* **Parameters:**
  * **store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) or [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – A MutableMapping where a Zarr Group has been stored or a path to a
    directory in file system where a Zarr DirectoryStore has been stored.
  * **group** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – Group path. (a.k.a. path in zarr terminology.)
  * **chunks** ([`int`](https://docs.python.org/3/builtins/functions.html#int), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict), `"auto"` or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – Used to load the data into dask arrays. Default behavior is to use
    `chunks={}` if dask is available, otherwise `chunks=None`.
    - `chunks='auto'` will use dask `auto` chunking taking into account the
      engine preferred chunks.
    - `chunks=None` skips using dask. This uses xarray’s internally private
      [lazy indexing classes](../internals/internal-design.html.md#internal-design-lazy-indexing),
      but data is eagerly loaded into memory as numpy arrays when accessed.
      This can be more efficient for smaller arrays, though results may vary.
    - `chunks=-1` loads the data with dask using a single chunk for all arrays.
    - `chunks={}` loads the data with dask using engine preferred chunks if
      exposed by the backend, otherwise with a single chunk for all arrays.

    See dask chunking for more details.
  * **overwrite_encoded_chunks** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – Whether to drop the zarr chunks encoded for each variable when a
    dataset is loaded with specified chunk sizes (default: False)
  * **decode_cf** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – Whether to decode these variables, assuming they were saved according
    to CF conventions.
  * **mask_and_scale** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, replace array values equal to \_FillValue with NA and scale
    values according to the formula original_values \* scale_factor +
    add_offset, where \_FillValue, scale_factor and add_offset are
    taken from variable attributes (if they exist).  If the \_FillValue or
    missing_value attribute contains multiple values a warning will be
    issued and all array values matching one of the multiple values will
    be replaced by NA.
  * **decode_times** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, decode times encoded in the standard NetCDF datetime format
    into datetime objects. Otherwise, leave them encoded as numbers.
  * **concat_characters** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, concatenate along the last dimension of character arrays to
    form string arrays. Dimensions will only be concatenated over (and
    removed) if they have no corresponding variable and if they are only
    used as the last dimension of character arrays.
  * **decode_coords** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or `{"coordinates", "all"}`, *optional*) – Controls which variables are set as coordinate variables:
    - “coordinates” or True: Set variables referred to in the
      `'coordinates'` attribute of the datasets or individual variables
      as coordinate variables.
    - “all”: Set variables referred to in  `'grid_mapping'`, `'bounds'` and
      other attributes as coordinate variables.

    Only existing variables can be set as coordinates. Missing variables
    will be silently ignored.
  * **drop_variables** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) or [iterable](https://docs.python.org/3/glossary.html#term-iterable), *optional*) – A variable or list of variables to exclude from being parsed from the
    dataset. This may be useful to drop variables with problems or
    inconsistent values.
  * **consolidated** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – Whether to open the store using zarr’s consolidated metadata
    capability. Only works for stores that have already been consolidated.
    By default (consolidate=None), attempts to read consolidated metadata,
    falling back to read non-consolidated metadata if that fails.
  * **storage_options** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict), *optional*) – Any additional parameters for the storage backend (ignored for local
    paths).
  * **decode_timedelta** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, decode variables and coordinates with time units in
    {‘days’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’, ‘microseconds’}
    into timedelta objects. If False, leave them encoded as numbers.
    If None (default), assume the same value of decode_time.
  * **use_cftime** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – Only relevant if encoded dates come from a standard calendar
    (e.g. “gregorian”, “proleptic_gregorian”, “standard”, or not
    specified).  If None (default), attempt to decode times to
    `np.datetime64[ns]` objects; if this is not possible, decode times to
    `cftime.datetime` objects. If True, always decode times to
    `cftime.datetime` objects, regardless of whether or not they can be
    represented using `np.datetime64[ns]` objects.  If False, always
    decode times to `np.datetime64[ns]` objects; if this is not possible
    raise an error.
  * **zarr_format** ([`int`](https://docs.python.org/3/builtins/functions.html#int) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – The desired zarr format to target (currently 2 or 3). The default
    of None will attempt to determine the zarr version from `store` when
    possible, otherwise defaulting to the default version used by
    the zarr-python library installed.
  * **use_zarr_fill_value_as_mask** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *optional*) – If True, use the zarr Array `fill_value` to mask the data, the same as done
    for NetCDF data with `_FillValue` or `missing_value` attributes. If False,
    the `fill_value` is ignored and the data are not masked. If None, this defaults
    to True for `zarr_format=2` and False for `zarr_format=3`.
  * **chunked_array_type** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *optional*) – Which chunked array type to coerce this datasets’ arrays to.
    Defaults to ‘dask’ if installed, else whatever is registered via the ChunkManagerEntryPoint system.
    Experimental API that should not be relied upon.
  * **from_array_kwargs** ([`dict`](https://docs.python.org/3/builtins/stdtypes.html#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.
    Defaults to `{'manager': 'dask'}`, meaning additional kwargs will be passed eventually to
    [`dask.array.from_array()`](https://docs.dask.org/en/latest/generated/dask.array.from_array.html#dask.array.from_array). Experimental API that should not be relied upon.
  * **create_default_indexes** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default*: [`True`](https://docs.python.org/3/builtins/constants.html#True)) – If True, create pandas indexes for [dimension coordinates](../user-guide/terminology.html.md#term-Dimension-coordinate),
    which loads the coordinate data into memory. Set it to False if you want to avoid loading
    data into memory.

    Note that backends can still choose to create other indexes. If you want to control that,
    please refer to the backend’s documentation.
* **Returns:**
  **dataset** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – The newly created dataset.

#### SEE ALSO
[`open_dataset`](xarray.open_dataset.html.md#xarray.open_dataset), [`open_mfdataset`](xarray.open_mfdataset.html.md#xarray.open_mfdataset)

### References

[https://zarr.readthedocs.io/](https://zarr.readthedocs.io/)
