-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
What happened:
combine_by_coords
can succeed when it should not - depending on the name of the dimensions (which determines the order of operations in combine_by_coords
).
What you expected to happen:
- I think it should throw an error in both cases.
Minimal Complete Verifiable Example:
import numpy as np
import xarray as xr
data = np.arange(5).reshape(1, 5)
x = np.arange(5)
x_name = "lat"
da0 = xr.DataArray(data, dims=("t", x_name), coords={"t": [1], x_name: x}).to_dataset(name="a")
x = x + 1e-6
da1 = xr.DataArray(data, dims=("t", x_name), coords={"t": [2], x_name: x}).to_dataset(name="a")
ds = xr.combine_by_coords((da0, da1))
ds
returns:
<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
Thus lat is interlaced - it don't think combine_by_coords
should do this. If you set
x_name = "lat"
and run the example again, it returns:
ValueError: Resulting object does not have monotonic global indexes along dimension x
Anything else we need to know?:
- this is vaguely related to open_mfdataset overwrites variables with different values but overlapping coordinates #4077 but I think it is separate
combine_by_coords
concatenates over all dimensions where the coords are different - thereforecompat="override"
doesn't actually do anything? Or does it?
Line 69 in ba42c08
if not all(index.equals(indexes[0]) for index in indexes[1:]): |
Environment: