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

Serializing a Dataset to_zarr prints error message for NetCDF #4926

Open
StefanBrand opened this issue Feb 19, 2021 · 0 comments · May be fixed by #9916
Open

Serializing a Dataset to_zarr prints error message for NetCDF #4926

StefanBrand opened this issue Feb 19, 2021 · 0 comments · May be fixed by #9916

Comments

@StefanBrand
Copy link

What happened:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-62e3bddfeac0> in <module>
      2 ds = xr.Dataset()
      3 ds[0] = xr.DataArray()
----> 4 ds.to_zarr()

/opt/conda/envs/eurodatacube-0.22.3/lib/python3.8/site-packages/xarray/core/dataset.py in to_zarr(self, store, chunk_store, mode, synchronizer, group, encoding, compute, consolidated, append_dim, region)
   1743             encoding = {}
   1744 
-> 1745         return to_zarr(
   1746             self,
   1747             store=store,

/opt/conda/envs/eurodatacube-0.22.3/lib/python3.8/site-packages/xarray/backends/api.py in to_zarr(dataset, store, chunk_store, mode, synchronizer, group, encoding, compute, consolidated, append_dim, region)
   1452 
   1453     # validate Dataset keys, DataArray names, and attr keys/values
-> 1454     _validate_dataset_names(dataset)
   1455     _validate_attrs(dataset)
   1456 

/opt/conda/envs/eurodatacube-0.22.3/lib/python3.8/site-packages/xarray/backends/api.py in _validate_dataset_names(dataset)
    205 
    206     for k in dataset.variables:
--> 207         check_name(k)
    208 
    209 

/opt/conda/envs/eurodatacube-0.22.3/lib/python3.8/site-packages/xarray/backends/api.py in check_name(name)
    198                 )
    199         elif name is not None:
--> 200             raise TypeError(
    201                 f"Invalid name {name!r} for DataArray or Dataset key: "
    202                 "must be either a string or None for serialization to netCDF "

TypeError: Invalid name 0 for DataArray or Dataset key: must be either a string or None for serialization to netCDF files

What you expected to happen:

Print error message referring to zarr:

TypeError: Invalid name 0 for DataArray or Dataset key: must be either a string or None for serialization to zarr files

Minimal Complete Verifiable Example:

import xarray as xr
ds = xr.Dataset()
ds[0] = xr.DataArray()
ds.to_zarr()

Environment:

Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.8.6 | packaged by conda-forge | (default, Oct  7 2020, 19:08:05) 
[GCC 7.5.0]
python-bits: 64
OS: Linux
OS-release: 4.14.177-139.253.amzn2.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4

xarray: 0.16.2
pandas: 1.1.5
numpy: 1.19.4
scipy: 1.5.3
netCDF4: 1.5.5
pydap: None
h5netcdf: None
h5py: 2.10.0
Nio: None
zarr: 2.6.1
cftime: 1.3.0
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.5
cfgrib: None
iris: None
bottleneck: 1.3.2
dask: 2.30.0
distributed: 2.30.1
matplotlib: 3.3.3
cartopy: 0.17.0
seaborn: 0.11.0
numbagg: None
pint: None
setuptools: 49.6.0.post20201009
pip: 20.3.2
conda: None
pytest: None
IPython: 7.19.0
sphinx: 3.3.1
VeckoTheGecko added a commit to VeckoTheGecko/xarray that referenced this issue Dec 25, 2024
@VeckoTheGecko VeckoTheGecko linked a pull request Dec 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants