id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 290572700,MDU6SXNzdWUyOTA1NzI3MDA=,1849,passing unlimited_dims to to_netcdf triggers RuntimeError: NetCDF: Invalid argument,500246,closed,0,,,12,2018-01-22T18:43:23Z,2019-06-04T20:41:50Z,2019-06-04T20:41:50Z,CONTRIBUTOR,,,,"For some datafiles with properties I cannot quite reproduce, `.to_netcdf` leads to a `RuntimeError: NetCDF: Invalid argument` if and only if I pass an `unlimited_dims` corresponding to `y`. The problem is hard to reproduce. It happens to this particular dataset, but not to seemingly identical ones created from scratch. I attach `sample.nc` (gzipped so github would let me upload it). ``` $ cat mwe.py #!/usr/bin/env python3.6 import xarray ds = xarray.open_dataset(""sample.nc"") ds.to_netcdf(""sample2.nc"", unlimited_dims=[""y""]) $ ncdump sample.nc netcdf sample { dimensions: y = 6 ; variables: float x(y) ; x:_FillValue = NaNf ; int64 y(y) ; data: x = 0, 0, 0, 0, 0, 0 ; y = 0, 1, 2, 3, 4, 5 ; } $ ./mwe.py Traceback (most recent call last): File ""./mwe.py"", line 5, in ds.to_netcdf(""sample2.nc"", unlimited_dims=[""y""]) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/core/dataset.py"", line 1133, in to_netcdf unlimited_dims=unlimited_dims) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/backends/api.py"", line 627, in to_netcdf unlimited_dims=unlimited_dims) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/core/dataset.py"", line 1070, in dump_to_store unlimited_dims=unlimited_dims) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/backends/common.py"", line 254, in store *args, **kwargs) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/backends/common.py"", line 221, in store unlimited_dims=unlimited_dims) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/backends/netCDF4_.py"", line 339, in set_variables super(NetCDF4DataStore, self).set_variables(*args, **kwargs) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/backends/common.py"", line 233, in set_variables name, v, check, unlimited_dims=unlimited_dims) File ""/dev/shm/gerrit/venv/stable-3.6/lib/python3.6/site-packages/xarray/backends/netCDF4_.py"", line 385, in prepare_variable fill_value=fill_value) File ""netCDF4/_netCDF4.pyx"", line 2437, in netCDF4._netCDF4.Dataset.createVariable File ""netCDF4/_netCDF4.pyx"", line 3439, in netCDF4._netCDF4.Variable.__init__ File ""netCDF4/_netCDF4.pyx"", line 1638, in netCDF4._netCDF4._ensure_nc_success RuntimeError: NetCDF: Invalid argument ``` #### Output of ``xr.show_versions()``
# Paste the output here xr.show_versions() here $ ./mwe.py INSTALLED VERSIONS ------------------ commit: None python: 3.6.1.final.0 python-bits: 64 OS: Linux OS-release: 2.6.32-696.6.3.el6.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 xarray: 0.10.0+dev39.ge31cf43 pandas: 0.22.0 numpy: 1.14.0 scipy: 1.0.0 netCDF4: 1.3.1 h5netcdf: None Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.16.1 distributed: None matplotlib: 2.1.2 cartopy: 0.15.1 seaborn: 0.8.1 setuptools: 38.4.0 pip: 9.0.1 conda: 4.3.16 pytest: 3.1.2 IPython: 6.1.0 sphinx: 1.6.2 [sample.nc.gz](https://github.com/pydata/xarray/files/1653178/sample.nc.gz)
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1849/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue