home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 641750522

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/4131#issuecomment-641750522 https://api.github.com/repos/pydata/xarray/issues/4131 641750522 MDEyOklzc3VlQ29tbWVudDY0MTc1MDUyMg== 5821660 2020-06-10T06:18:36Z 2020-06-10T06:18:36Z MEMBER

This doesn't work when it is opened via netCDF4 and NetCDF4DataStore.

python import netCDF4 as nc import xarray as xr ncfile = nc.Dataset("tmp_example.nc") dstore = xr.backends.NetCDF4DataStore(ncfile) data = xr.open_dataset(dstore) print(ncfile.isopen()) data.close() print(ncfile.isopen()) print(data.foo)

``` True False /home/miniconda/envs/xarray/lib/python3.8/site-packages/xarray/backends/netCDF4_.py in _getitem(self, key) 83 with self.datastore.lock: 84 original_array = self.get_array(needs_lock=False) ---> 85 array = getitem(original_array, key) 86 except IndexError: 87 # Catch IndexError in netCDF4 and return a more informative

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.getitem()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.shape.get()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable._getdims()

netCDF4/_netCDF4.pyx in netCDF4._netCDF4._ensure_nc_success()

RuntimeError: NetCDF: Not a valid ID ```

Also in @rsokl's case the data._file_obj is None after closing. First I thought that caching might be involved, but it doesn't seem the case.

Nevertheless it seems unusual, that opening a file outside xarray will be closed inside xarray. At least I would not expect it, to be closed. Should I open another issue for this, @shoyer?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  634869703
Powered by Datasette · Queries took 0.607ms · About: xarray-datasette