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 1352315409,PR_kwDOAMm_X8493rR7,6956,"Expose `memory` argument for ""netcdf4"" engine",30196,open,0,,,12,2022-08-26T14:04:25Z,2023-03-23T15:51:27Z,,FIRST_TIME_CONTRIBUTOR,,0,pydata/xarray/pulls/6956,"This commit exposes the `memory` argument for the ""netcdf4"" engine, allowing one to create a netcdf dataset from a memory buffer, like so: ```python buffer: bytes = ... ds = xr.open_dataset("""", engine=""netcdf4"", memory=buffer) ``` - [x] Closes #6955 - [ ] Tests added - [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst` - [ ] New functions/methods are listed in `api.rst`","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6956/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,pull 1352314936,I_kwDOAMm_X85QmrA4,6955,"Expose ""memory"" argument to the ""netcdf4"" engine",30196,open,0,,,0,2022-08-26T14:04:00Z,2022-08-26T14:04:00Z,,NONE,,,,"### Is your feature request related to a problem? As of today, xarray can't open a netcdf residing in a memory buffer, which is possible in netCDF4 library through the `memory` argument of the `netCDF4.Dataset` class constructor. ### Describe the solution you'd like It would be nice to create an `xarray.Dataset` from a netcdf file in memory like so: ```python buf: bytes = ... ds = xr.open_dataset(""dummy.nc"", engine=""netcdf4"", memory=buf) ``` But this fails with ``` File ~/.asdf/installs/python/3.9.13/lib/python3.9/site-packages/xarray/backends/api.py:531, 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, inline_array, backend_kwargs, **kwargs) 519 decoders = _resolve_decoders_kwargs( 520 decode_cf, 521 open_backend_dataset_parameters=backend.open_dataset_parameters, (...) 527 decode_coords=decode_coords, 528 ) 530 overwrite_encoded_chunks = kwargs.pop(""overwrite_encoded_chunks"", None) --> 531 backend_ds = backend.open_dataset( 532 filename_or_obj, 533 drop_variables=drop_variables, 534 **decoders, 535 **kwargs, 536 ) 537 ds = _dataset_from_backend_dataset( 538 backend_ds, 539 filename_or_obj, (...) 547 **kwargs, 548 ) 549 return ds TypeError: open_dataset() got an unexpected keyword argument 'memory' ``` ### Describe alternatives you've considered An alternative is to save the buffer into a temporary file and open it the usual way, but it feels cumbersome when there is already an argument to open directly from memory. ### Additional context _No response_","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6955/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue