home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 770848655

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/4824#issuecomment-770848655 https://api.github.com/repos/pydata/xarray/issues/4824 770848655 MDEyOklzc3VlQ29tbWVudDc3MDg0ODY1NQ== 10194086 2021-02-01T13:15:18Z 2021-02-01T13:15:18Z MEMBER

combine_by_coords does a merge and a concat (in the _combine_1d function). The order of these operations makes a difference to the result. See details.

merge leads to interlaced coords ```python In [2]: xr.merge([da0, da1]) Out[2]: <xarray.Dataset> Dimensions: (lat: 10, t: 2) Coordinates: * lat (lat) float64 0.0 1e-06 1.0 1.0 2.0 2.0 3.0 3.0 4.0 4.0 * t (t) int64 1 2 Data variables: a (t, lat) float64 0.0 nan 1.0 nan 2.0 nan ... 2.0 nan 3.0 nan 4.0 ``` concat leads to - well - concatenated coords ```python xr.concat([da0, da1], dim="lat") Out[5]: <xarray.Dataset> Dimensions: (lat: 10, t: 2) Coordinates: * t (t) int64 1 2 * lat (lat) float64 0.0 1.0 2.0 3.0 4.0 1e-06 1.0 2.0 3.0 4.0 Data variables: a (t, lat) float64 0.0 1.0 2.0 3.0 4.0 nan ... 0.0 1.0 2.0 3.0 4.0 ```

Yes I think I'd be interested to fix this...


One question on the scope of combine_by_coords - consider the following example with 4 arrays ("a" through "d") arranged as follows:

aabbb cccdd

Or as Dataset:

```python ds_a = xr.Dataset({"data": (("y", "x"), [[1, 2]]), "x": [0, 1], "y": [0]}) ds_b = xr.Dataset({"data": (("y", "x"), [[3, 4, 5]]), "x": [2, 3, 4], "y": [0]})

ds_c = xr.Dataset({"data": (("y", "x"), [[11, 12, 14]]), "x": [0, 1, 2], "y": [1]}) ds_d = xr.Dataset({"data": (("y", "x"), [[14, 15]]), "x": [3, 4], "y": [1]})

xr.combine_by_coords([ds_a, ds_b, ds_c, ds_d]).data ```

Should that work or not?

Current behaviour

Currently it yields the following:

python <xarray.DataArray 'data' (y: 2, x: 5)> array([[ 1, 2, 3, 4, 5], [11, 12, 14, 14, 15]]) Coordinates: * x (x) int64 0 1 2 3 4 * y (y) int64 0 1

However, if "x" is renamed to "z" it fails ("resulting coords not monotonic").

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  788534915
Powered by Datasette · Queries took 2.34ms · About: xarray-datasette