home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 272824929

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/1199#issuecomment-272824929 https://api.github.com/repos/pydata/xarray/issues/1199 272824929 MDEyOklzc3VlQ29tbWVudDI3MjgyNDkyOQ== 10050469 2017-01-16T10:27:59Z 2017-01-16T13:37:15Z MEMBER

[edited to remove a less relevant comment, now moved to a separate issue]

After having a look at the doc about coordinates (http://xarray.pydata.org/en/latest/data-structures.html#coordinates), here a few thoughts: - it would be good to have clear semantics about the different coordinates. For example, "positional coordinates" for coords with "*", "auxilliary coordinates" for coords without "*". How do we call the coordinates with a "o" ? - after giving it a second thought: have you considered not to list the coordinates with "o" in the coords repr? After all, what they really are is dimensions, not coordinates (as shown by the test above: 'dim_0' in ds.coords == False). The operations available on them (e.g. isel) really look like operations available on dimensions (similar to axis in numpy), not so much like operations available on coordinates.

I'll go on with a simple example that I just tried out to let you know how I dealt with this new behavior of xarray:

```python In [1]: import xarray as xr

In [2]: a = np.array([[1.1, 2.2, 3.3], [4.4, 5.5, 6.6]])

In [3]: da = xr.DataArray(a, dims=['y', 'x'], coords={'x':[0.1, 1.1, 2.2], 'xy':(['y', 'x'], a)})

In [4]: da Out[4]: <xarray.DataArray (y: 2, x: 3)> array([[ 1.1, 2.2, 3.3], [ 4.4, 5.5, 6.6]]) Coordinates: * x (x) float64 0.1 1.1 2.2 xy (y, x) float64 1.1 2.2 3.3 4.4 5.5 6.6 o y (y) - ```

"OK, I have three types of coordinates here. This makes sense, they are all defined in a different way. y is a dimension of my dataset, so at least I should be able to select along that dimension:".

python In [6]: da.isel(y=1) Out[6]: <xarray.DataArray (x: 3)> array([ 4.4, 5.5, 6.6]) Coordinates: * x (x) float64 0.1 1.1 2.2 xy (x) float64 4.4 5.5 6.6 "so far so good! x is a coordinate, so here I should be able to do more complex selection based on values:"

python In [7]: da.sel(x=2.2) Out[7]: <xarray.DataArray (y: 2)> array([ 3.3, 6.6]) Coordinates: x float64 2.2 xy (y) float64 3.3 6.6 o y (y) -

"That makes sense. However, this is probably not possible with y, which is not defined:"

python In [8]: da.sel(y=0) Out[8]: <xarray.DataArray (x: 3)> array([ 1.1, 2.2, 3.3]) Coordinates: * x (x) float64 0.1 1.1 2.2 xy (x) float64 1.1 2.2 3.3 "wait... So I can select by label on an undefined coordinate? Maybe y is a coordinate after all?"

python In [9]: 'y' in da.coords Out[9]: False "ah, no."

I actually think that .sel() shoud not work on y. I understand that this would break a bunch of existing code, but this is a confusing (if not inconsistent) behavior.

Maybe I'm completely missing the point here: don't hesitate to correct me!

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