Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outdated xarray opening of zarr files #51

Open
AJueling opened this issue May 26, 2021 · 0 comments
Open

outdated xarray opening of zarr files #51

AJueling opened this issue May 26, 2021 · 0 comments

Comments

@AJueling
Copy link
Contributor

  • cmip6-object-store version: 26 May 2021 (couldn't find a version number)
  • Python version: 3.7.1
    • xarray version: 0.18.2
    • fsspec version: 2021.05.0
    • intake version: 0.6.2
    • intake_esm version: 2021.1.15
  • Operating System: Linux 3.10.0-1160.15.2.el7.x86_64 (JASMIN)

Description

I wanted to execute the complete notebooks/cmip6-zarr-jasmin.ipynb notebook and an error occured.

What I Did

Calling the function hist_tas = cat_to_ds(hist_cat)['tas'] which is defined one cell up as

def cat_to_ds(cat):
    zarr_path = cat.df['zarr_path'][0]
    fsmap = fsspec.get_mapper(zarr_path)
    return xr.open_zarr(fsmap, consolidated=True, use_cftime=True)

results in this TypeError: TypeError: from_array() got an unexpected keyword argument 'meta'

TypeError
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-107905d5492a> in <module>
----> 1 hist_tas = cat_to_ds(hist_cat)['tas']
      2 ssp_tas = cat_to_ds(ssp_cat)['tas']

<ipython-input-10-7aab0cca2c4f> in cat_to_ds(cat)
      3     fsmap = fsspec.get_mapper(zarr_path)
      4 #     return xr.open_dataset(fsmap, consolidated=True, use_cftime=True, engine='zarr')
----> 5     return xr.open_zarr(fsmap, consolidated=True, use_cftime=True)

~/nb-venvs/venv-cmip6-zarr/lib/python3.7/site-packages/xarray/backends/zarr.py in open_zarr(store, group, synchronizer, chunks, decode_cf, mask_and_scale, decode_times, concat_characters, decode_coords, drop_variables, consolidated, overwrite_encoded_chunks, chunk_store, storage_options, decode_timedelta, use_cftime, **kwargs)
    698         backend_kwargs=backend_kwargs,
    699         decode_timedelta=decode_timedelta,
--> 700         use_cftime=use_cftime,
    701     )
    702     return ds

~/nb-venvs/venv-cmip6-zarr/lib/python3.7/site-packages/xarray/backends/api.py in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, backend_kwargs, *args, **kwargs)
    509         drop_variables=drop_variables,
    510         **decoders,
--> 511         **kwargs,
    512     )
    513     return ds

~/nb-venvs/venv-cmip6-zarr/lib/python3.7/site-packages/xarray/backends/api.py in _dataset_from_backend_dataset(backend_ds, filename_or_obj, engine, chunks, cache, overwrite_encoded_chunks, **extra_tokens)
    322             chunks,
    323             overwrite_encoded_chunks,
--> 324             **extra_tokens,
    325         )
    326 

~/nb-venvs/venv-cmip6-zarr/lib/python3.7/site-packages/xarray/backends/api.py in _chunk_ds(backend_ds, filename_or_obj, engine, chunks, overwrite_encoded_chunks, **extra_tokens)
    293             overwrite_encoded_chunks=overwrite_encoded_chunks,
    294             name_prefix=name_prefix,
--> 295             token=token,
    296         )
    297     return backend_ds._replace(variables)

~/nb-venvs/venv-cmip6-zarr/lib/python3.7/site-packages/xarray/core/dataset.py in _maybe_chunk(name, var, chunks, token, lock, name_prefix, overwrite_encoded_chunks)
    431         token2 = tokenize(name, token if token else var._data, chunks)
    432         name2 = f"{name_prefix}{name}-{token2}"
--> 433         var = var.chunk(chunks, name=name2, lock=lock)
    434 
    435         if overwrite_encoded_chunks and var.chunks is not None:

~/nb-venvs/venv-cmip6-zarr/lib/python3.7/site-packages/xarray/core/variable.py in chunk(self, chunks, name, lock)
   1066                 chunks = tuple(chunks.get(n, s) for n, s in enumerate(self.shape))
   1067 
-> 1068             data = da.from_array(data, chunks, name=name, lock=lock, **kwargs)
   1069 
   1070         return self._replace(data=data)

TypeError: from_array() got an unexpected keyword argument 'meta'

Solution

The xr.open_zarr(fsmap, consolidated=True, use_cftime=True) method is deprecated (intake/intake-xarray#70) and the should be replaced with return xr.open_dataset(fsmap, consolidated=True, use_cftime=True, engine='zarr')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant