issues: 1168304665
This data as json
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1168304665 | I_kwDOAMm_X85FouoZ | 6355 | ValueError: Resulting object does not have monotonic global indexes along dimension in combine_by_coords call | 24227838 | open | 0 | 2 | 2022-03-14T12:25:18Z | 2022-03-16T15:42:06Z | NONE | What happened?When I try to do a
)
x2 = xr.Dataset(
{
"temperature": (("y", "x"), 20 * np.random.rand(6).reshape(2, 3)),
"precipitation": (("y", "x"), np.random.rand(6).reshape(2, 3)),
},
coords={"y": [2, 3], "x": [10, 20, 30]},
)
```
10 20 30
What did you expect to happen?For me the result of ```shell 3| y y y 2| y y y 1| x x x 0| x x x 10 20 30 40 ``` Minimal Complete Verifiable Example```Python import numpy as np import xarray as xr print(xr.version) x1 = xr.Dataset( {
) x2 = xr.Dataset( { "temperature": (("y", "x"), 20 * np.random.rand(6).reshape(2, 3)), "precipitation": (("y", "x"), np.random.rand(6).reshape(2, 3)), }, coords={"y": [2, 3], "x": [10, 20, 30]}, ) print(x1) print(x2) ds_test = xr.combine_by_coords([x2, x1]) ``` Relevant log output```Python ValueError Traceback (most recent call last) /home/thomas/Work/internal-applications/sungeodata/app-sungeodata/test copy.ipynb Cell 6' in <cell line: 1>() ----> 1 ds_test = xr.combine_by_coords([x2, x1]) File ~/Work/internal-applications/sungeodata/app-sungeodata/.venv/lib/python3.8/site-packages/xarray/core/combine.py:979, in combine_by_coords(data_objects, compat, data_vars, coords, fill_value, join, combine_attrs, datasets) 977 concatenated_grouped_by_data_vars = [] 978 for vars, datasets_with_same_vars in grouped_by_vars: --> 979 concatenated = _combine_single_variable_hypercube( 980 list(datasets_with_same_vars), 981 fill_value=fill_value, 982 data_vars=data_vars, 983 coords=coords, 984 compat=compat, 985 join=join, 986 combine_attrs=combine_attrs, 987 ) 988 concatenated_grouped_by_data_vars.append(concatenated) 990 return merge( 991 concatenated_grouped_by_data_vars, 992 compat=compat, (...) 995 combine_attrs=combine_attrs, 996 ) File ~/Work/internal-applications/sungeodata/app-sungeodata/.venv/lib/python3.8/site-packages/xarray/core/combine.py:653, in _combine_single_variable_hypercube(datasets, fill_value, data_vars, coords, compat, join, combine_attrs) 651 indexes = concatenated.indexes.get(dim) 652 if not (indexes.is_monotonic_increasing or indexes.is_monotonic_decreasing): --> 653 raise ValueError( 654 f"Resulting object does not have monotonic" 655 f" global indexes along dimension {dim}" 659 ) 661 return concatenated ValueError: Resulting object does not have monotonic global indexes along dimension x I add more logs with: ```pythonValueError Traceback (most recent call last) /home/thomas/Work/internal-applications/sungeodata/app-sungeodata/test copy.ipynb Cell 6' in <cell line: 1>() ----> 1 ds_test = xr.combine_by_coords([x2, x1]) File ~/Work/internal-applications/sungeodata/app-sungeodata/.venv/lib/python3.8/site-packages/xarray/core/combine.py:979, in combine_by_coords(data_objects, compat, data_vars, coords, fill_value, join, combine_attrs, datasets) 977 concatenated_grouped_by_data_vars = [] 978 for vars, datasets_with_same_vars in grouped_by_vars: --> 979 concatenated = _combine_single_variable_hypercube( 980 list(datasets_with_same_vars), 981 fill_value=fill_value, 982 data_vars=data_vars, 983 coords=coords, 984 compat=compat, 985 join=join, 986 combine_attrs=combine_attrs, 987 ) 988 concatenated_grouped_by_data_vars.append(concatenated) 990 return merge( 991 concatenated_grouped_by_data_vars, 992 compat=compat, (...) 995 combine_attrs=combine_attrs, 996 ) File ~/Work/internal-applications/sungeodata/app-sungeodata/.venv/lib/python3.8/site-packages/xarray/core/combine.py:653, in _combine_single_variable_hypercube(datasets, fill_value, data_vars, coords, compat, join, combine_attrs) 651 indexes = concatenated.indexes.get(dim) 652 if not (indexes.is_monotonic_increasing or indexes.is_monotonic_decreasing): --> 653 raise ValueError( 654 f"Resulting object does not have monotonic" 655 f" global indexes along dimension {dim} \n" 656 f" indexes.is_monotonic_increasing {indexes.is_monotonic_increasing}" 657 f" indexes.is_monotonic_decreasing {indexes.is_monotonic_decreasing}\n" 658 f" concatenated[{dim}].values {concatenated[dim].values.tolist()}" 659 ) 661 return concatenated ValueError: Resulting object does not have monotonic global indexes along dimension x
indexes.is_monotonic_increasing False indexes.is_monotonic_decreasing False
concatenated[x].values [10, 20, 30, 20, 30, 40]
Anything else we need to know?No response EnvironmentINSTALLED VERSIONScommit: None python: 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.13.0-30-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.0 libnetcdf: 4.7.4 xarray: 2022.3.0 pandas: 1.4.1 numpy: 1.22.3 scipy: 1.6.2 netCDF4: 1.5.5.1 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.6.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: 0.9.8.4 iris: None bottleneck: None dask: 2022.02.1 distributed: 2022.2.1 matplotlib: 3.4.3 cartopy: None seaborn: None numbagg: None fsspec: 2022.02.0 cupy: None pint: None sparse: None setuptools: 44.0.0 pip: 20.0.2 conda: None pytest: 7.0.1 IPython: 8.1.1 sphinx: 3.5.4 |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6355/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |