| 1 | to_unstacked_dataset broken for single-dim variables |
| 2 | <!-- A short summary of the issue, if appropriate --> |
| 3 | |
| 4 | |
| 5 | #### MCVE Code Sample |
| 6 | |
| 7 | ```python |
| 8 | arr = xr.DataArray( |
| 9 | np.arange(3), |
| 10 | coords=[("x", [0, 1, 2])], |
| 11 | ) |
| 12 | data = xr.Dataset({"a": arr, "b": arr}) |
| 13 | stacked = data.to_stacked_array('y', sample_dims=['x']) |
| 14 | unstacked = stacked.to_unstacked_dataset('y') |
| 15 | # MergeError: conflicting values for variable 'y' on objects to be combined. You can skip this check by specifying compat='override'. |
| 16 | ``` |
| 17 | |
| 18 | #### Expected Output |
| 19 | A working roundtrip. |
| 20 | |
| 21 | #### Problem Description |
| 22 | I need to stack a bunch of variables and later unstack them again, however this doesn't work if the variables only have a single dimension. |
| 23 | |
| 24 | #### Versions |
| 25 | |
| 26 | <details><summary>Output of <tt>xr.show_versions()</tt></summary> |
| 27 | |
| 28 | INSTALLED VERSIONS |
| 29 | ------------------ |
| 30 | commit: None |
| 31 | python: 3.7.3 (default, Mar 27 2019, 22:11:17) |
| 32 | [GCC 7.3.0] |
| 33 | python-bits: 64 |
| 34 | OS: Linux |
| 35 | OS-release: 4.15.0-96-generic |
| 36 | machine: x86_64 |
| 37 | processor: x86_64 |
| 38 | byteorder: little |
| 39 | LC_ALL: None |
| 40 | LANG: en_GB.UTF-8 |
| 41 | LOCALE: en_GB.UTF-8 |
| 42 | libhdf5: 1.10.4 |
| 43 | libnetcdf: 4.6.2 |
| 44 | |
| 45 | xarray: 0.15.1 |
| 46 | pandas: 1.0.3 |
| 47 | numpy: 1.17.3 |
| 48 | scipy: 1.3.1 |
| 49 | netCDF4: 1.4.2 |
| 50 | pydap: None |
| 51 | h5netcdf: None |
| 52 | h5py: 2.10.0 |
| 53 | Nio: None |
| 54 | zarr: None |
| 55 | cftime: 1.0.4.2 |
| 56 | nc_time_axis: None |
| 57 | PseudoNetCDF: None |
| 58 | rasterio: None |
| 59 | cfgrib: None |
| 60 | iris: None |
| 61 | bottleneck: None |
| 62 | dask: 2.10.1 |
| 63 | distributed: 2.10.0 |
| 64 | matplotlib: 3.1.1 |
| 65 | cartopy: None |
| 66 | seaborn: 0.10.0 |
| 67 | numbagg: None |
| 68 | setuptools: 41.0.0 |
| 69 | pip: 19.0.3 |
| 70 | conda: 4.8.3 |
| 71 | pytest: 5.3.5 |
| 72 | IPython: 7.9.0 |
| 73 | sphinx: None |
| 74 | |
| 75 | |
| 76 | </details> |
| 77 | |