# xarray.backends.NetCDF4DataStore

### *class* xarray.backends.NetCDF4DataStore(manager, group=None, mode=None, lock=CombinedLock([<SerializableLock: xarray-hdf5-lock>, <SerializableLock: xarray-netcdfc-lock>]), autoclose=False)[[source]](https://github.com/pydata/xarray/blob/main/xarray/backends/netCDF4_.py#L429-L784)

Store for reading and writing data via the Python-NetCDF4 library.

This store supports NetCDF3, NetCDF4 and OpenDAP datasets.

#### \_\_init_\_(manager, group=None, mode=None, lock=CombinedLock([<SerializableLock: xarray-hdf5-lock>, <SerializableLock: xarray-netcdfc-lock>]), autoclose=False)[[source]](https://github.com/pydata/xarray/blob/main/xarray/backends/netCDF4_.py#L446-L472)

### Methods

| [`__init__`](#xarray.backends.NetCDF4DataStore.__init__)(manager[, group, mode, lock, autoclose])                                                |                                                                                                                                                                                           |
|---------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`close`](xarray.backends.NetCDF4DataStore.close.html.md#xarray.backends.NetCDF4DataStore.close)(\*\*kwargs)                                         |                                                                                                                                                                                           |
| [`encode`](xarray.backends.NetCDF4DataStore.encode.html.md#xarray.backends.NetCDF4DataStore.encode)(variables, attributes)                            | Encode the variables and attributes in this store                                                                                                                                         |
| [`encode_attribute`](xarray.backends.NetCDF4DataStore.encode_attribute.html.md#xarray.backends.NetCDF4DataStore.encode_attribute)(a)                            | encode one attribute                                                                                                                                                                      |
| [`encode_variable`](xarray.backends.NetCDF4DataStore.encode_variable.html.md#xarray.backends.NetCDF4DataStore.encode_variable)(variable[, name])               | encode one variable                                                                                                                                                                       |
| [`get_attrs`](xarray.backends.NetCDF4DataStore.get_attrs.html.md#xarray.backends.NetCDF4DataStore.get_attrs)()                                           |                                                                                                                                                                                           |
| `get_child_store`(group)                                                                                                                          | Get a store corresponding to the indicated child group.                                                                                                                                   |
| [`get_dimensions`](xarray.backends.NetCDF4DataStore.get_dimensions.html.md#xarray.backends.NetCDF4DataStore.get_dimensions)()                                 |                                                                                                                                                                                           |
| [`get_encoding`](xarray.backends.NetCDF4DataStore.get_encoding.html.md#xarray.backends.NetCDF4DataStore.get_encoding)()                                     |                                                                                                                                                                                           |
| `get_parent_dimensions`()                                                                                                                         |                                                                                                                                                                                           |
| [`get_variables`](xarray.backends.NetCDF4DataStore.get_variables.html.md#xarray.backends.NetCDF4DataStore.get_variables)()                                   |                                                                                                                                                                                           |
| [`load`](xarray.backends.NetCDF4DataStore.load.html.md#xarray.backends.NetCDF4DataStore.load)()                                                     | This loads the variables and attributes simultaneously.                                                                                                                                   |
| [`open`](xarray.backends.NetCDF4DataStore.open.html.md#xarray.backends.NetCDF4DataStore.open)(filename[, mode, format, group, ...])                 |                                                                                                                                                                                           |
| [`open_store_variable`](xarray.backends.NetCDF4DataStore.open_store_variable.html.md#xarray.backends.NetCDF4DataStore.open_store_variable)(name, var)              |                                                                                                                                                                                           |
| [`prepare_variable`](xarray.backends.NetCDF4DataStore.prepare_variable.html.md#xarray.backends.NetCDF4DataStore.prepare_variable)(name, variable[, ...])        |                                                                                                                                                                                           |
| [`set_attribute`](xarray.backends.NetCDF4DataStore.set_attribute.html.md#xarray.backends.NetCDF4DataStore.set_attribute)(key, value)                         |                                                                                                                                                                                           |
| [`set_attributes`](xarray.backends.NetCDF4DataStore.set_attributes.html.md#xarray.backends.NetCDF4DataStore.set_attributes)(attributes)                       | This provides a centralized method to set the dataset attributes on the data store.                                                                                                       |
| [`set_dimension`](xarray.backends.NetCDF4DataStore.set_dimension.html.md#xarray.backends.NetCDF4DataStore.set_dimension)(name, length[, is_unlimited])       |                                                                                                                                                                                           |
| [`set_dimensions`](xarray.backends.NetCDF4DataStore.set_dimensions.html.md#xarray.backends.NetCDF4DataStore.set_dimensions)(variables[, unlimited_dims])      | This provides a centralized method to set the dimensions on the data store.                                                                                                               |
| [`set_variable`](xarray.backends.NetCDF4DataStore.set_variable.html.md#xarray.backends.NetCDF4DataStore.set_variable)(k, v)                                 |                                                                                                                                                                                           |
| [`set_variables`](xarray.backends.NetCDF4DataStore.set_variables.html.md#xarray.backends.NetCDF4DataStore.set_variables)(variables, check_encoding_set, ...) | This provides a centralized method to set the variables on the data store.                                                                                                                |
| [`store`](xarray.backends.NetCDF4DataStore.store.html.md#xarray.backends.NetCDF4DataStore.store)(variables, attributes[, ...])                       | Top level method for putting data on this store, this method:                                                                                                                             |
| [`store_dataset`](xarray.backends.NetCDF4DataStore.store_dataset.html.md#xarray.backends.NetCDF4DataStore.store_dataset)(dataset)                            | in stores, variables are all variables AND coordinates in xarray.Dataset variables are variables NOT coordinates, so here we pass the whole dataset in instead of doing dataset.variables |
| [`sync`](xarray.backends.NetCDF4DataStore.sync.html.md#xarray.backends.NetCDF4DataStore.sync)()                                                     | Write all buffered data to disk.                                                                                                                                                          |

### Attributes

| [`autoclose`](xarray.backends.NetCDF4DataStore.autoclose.html.md#xarray.backends.NetCDF4DataStore.autoclose)   |    |
|---------------------------------------------------------------------------------------------------------|----|
| [`format`](xarray.backends.NetCDF4DataStore.format.html.md#xarray.backends.NetCDF4DataStore.format)         |    |
| [`is_remote`](xarray.backends.NetCDF4DataStore.is_remote.html.md#xarray.backends.NetCDF4DataStore.is_remote)   |    |
| [`lock`](xarray.backends.NetCDF4DataStore.lock.html.md#xarray.backends.NetCDF4DataStore.lock)             |    |
| [`ds`](xarray.backends.NetCDF4DataStore.ds.html.md#xarray.backends.NetCDF4DataStore.ds)                 |    |
