Description
MCVE Code Sample
# Your code here
data_0 = xr.Dataset({'temperature': ('time', [10,20,30])}, coords={'time': [0,1,2]})
data_0.coords['trial'] = 0
data_1 = xr.Dataset({'temperature': ('time', [50,60,70])}, coords={'time': [0,1,2]})
data_1.coords['trial'] = 1
# the following fails with a ValueError:
# all_trials = xr.combine_by_coords([data_0, data_1])
# but this works:
all_trials = xr.combine_by_coords([data_0.expand_dims('trial'), data_1.expand_dims('trial')]) # works
Expected output
Both work and produce the same result.
Problem Description
I found this behavior somewhat unintuitive -- I didn't understand that I needed to call expand_dims
to get combine_by_coords
to work. It might make things a little easier to understand if both behaved the same way -- maybe the code that concatenates dimensions should look for full dimensions first, and point coordinates second.
This would also make code that selects dimensions with sel
and then calls combine_by_coords
more easy to write.
On the other hand, this could be seen as "magic", and it might also be a breaking change to combine_by_coords
; I'm not sure. So I'd understand if isn't implemented.
Output of xr.show_versions()
INSTALLED VERSIONS ------------------ commit: None python: 3.7.6 (default, Jan 8 2020, 19:13:59) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.14.0-115.10.1.el7a.ppc64le machine: ppc64le processor: ppc64le byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 libhdf5: 1.10.2 libnetcdf: Nonexarray: 0.15.0
pandas: 0.25.3
numpy: 1.16.5
scipy: 1.3.0
netCDF4: None
pydap: None
h5netcdf: None
h5py: 2.8.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.10.0
distributed: 2.10.0
matplotlib: 3.1.1
cartopy: None
seaborn: None
numbagg: None
setuptools: 44.0.0.post20200106
pip: 19.3.1
conda: None
pytest: 5.3.2
IPython: 7.11.1
sphinx: None