-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling of CRS objects in coordinates #8
Comments
Interesting. It appears that the Well, that is the extent of my insight on this one for now. Glad to see this moving forward 👍 |
New discovery tonight while working on something else, xarray makes the coordinates DataArrays no matter what and in the case of an object it becomes an object "scalar" array. So you have to do
|
Another data point on figuring this out: In [27]: b = xr.DataArray(da.zeros((5, 5), chunks=2), dims=('y', 'x'), coords={'y': da.arange(1, 6, chunks=3), 'x': da.arange(2, 7, chunks=3), 'crs': crs2, 'test': 2, 'test2': 2})
In [28]: a = xr.DataArray(da.zeros((5, 5), chunks=2), dims=('y', 'x'), coords={'y': da.arange(1, 6, chunks=3), 'x': da.arange(2, 7, chunks=3), 'crs': crs1, 'test': 1, 'test2': 2})
In [29]: a + b
Out[29]:
<xarray.DataArray 'zeros-e5723e7f9121b7ac546f61c19dabe786' (y: 5, x: 5)>
dask.array<shape=(5, 5), dtype=float64, chunksize=(2, 2)>
Coordinates:
* y (y) int64 1 2 3 4 5
* x (x) int64 2 3 4 5 6
test2 int64 2 Basically, xarray drops any non-dimensional coordinates that are not equal. So, as xarray sits right now, there is no easy way to force the CRS coordinate to be checked as far as I can tell. |
This seems like a bug in xarray. |
@dopplershift Do you know if you've gotten coordinates to behave like this in the past? I created this issue a couple days ago: pydata/xarray#2996 |
No, but I remember the coordinate approach being advocated because it shouldn't disappear like that. |
@dopplershift This page http://xarray.pydata.org/en/stable/computation.html#coordinates seems to match what I'm seeing. Specifically non-dimensional coordinates (like my |
😠 The rationale in the docs makes sense, but that doesn't make me happy about it for this case. |
I'm going to close this. I merged #26 today and it copies the behavior of If you, the user, would like to persist this discovery you can use |
I started looking more at 2D coordinate arrays (especially when they are dask arrays) and using a pyproj
CRS
object as a coordinate and ran in to a weird situation. I'm hoping @snowman2 or someone else can help me decipher what is happening here.I would have expected
a + b
to not be allowed since they differ and are not equal. Thoughts? Is this expected?The text was updated successfully, but these errors were encountered: