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/2410#issuecomment-420447247,https://api.github.com/repos/pydata/xarray/issues/2410,420447247,MDEyOklzc3VlQ29tbWVudDQyMDQ0NzI0Nw==,1217238,2018-09-11T22:26:42Z,2018-09-11T22:26:42Z,MEMBER,"OK, maybe I was premature to copy it here :). But yes, I'm excited about clarifying these definitions in our docs!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,359240638 https://github.com/pydata/xarray/issues/2410#issuecomment-420445485,https://api.github.com/repos/pydata/xarray/issues/2410,420445485,MDEyOklzc3VlQ29tbWVudDQyMDQ0NTQ4NQ==,1217238,2018-09-11T22:19:41Z,2018-09-11T22:19:41Z,MEMBER,"Copying @horta's doc: ------------------------- # Xarray definition A **data array** `a` has `d` dimensions, ordered from `0` to `d`. It contains an array of dimensionality `d`. The first dimension of that array is associated with the first dimension of the data array, and so forth. That array is returned by the data array attribute `values` . A **named data array** is a data array with the `name` attribute of string value. Each data array dimension has an unique `name` attribute of string type and can be accessed via data array `dims` attribute of tuple type. The name of the dimension `i` is `a.dims[i]` . A data array can have zero or more coordinates, represented by a dict-like `coords` attribute. A coordinate is a named data array, referred also as **coordinate data array**. Coordinate data arrays have unique names among other coordinate data arrays. A coordinate data array of name `x` can be retrieved by `a.coords[x]` . A coordinate can have zero or more dimensions associated with. A **dimension data array** is a unidimensional coordinate data array associated with one, and only one, dimension having the same name as the coordinate data array itself. A dimension data array has always one, and only one, coordinate. That coordinate has again a dimension data array associated with. As an example, let `a.coords[name]` be a dimension data array of `a`, associated with dimension `i`. This means, among other things, that * `a.shape[i] == a.coords[name].size` * `a.coords[name].name == name` * `len(a.coords[name].dims) == 1` * `a.coords[name].dims[0] == name` Now lets consider a practical example: ```python >>> import numpy as np >>> import xarray as xr >>> >>> a = xr.DataArray(np.arange(6).reshape((3, 2)), dims=[""x"", ""y""], coords={""x"": list(""abc"")}) >>> a array([[0, 1], [2, 3], [4, 5]]) Coordinates: * x (x) >> a.coords[""x""] array(['a', 'b', 'c'], dtype='>> a.coords[""x""].coords[""x""] array(['a', 'b', 'c'], dtype='>> a = xr.DataArray(np.arange(6).reshape((3, 2)), dims=[""x"", ""y""], coords={""x"": list(""abc""), ""y"": [0, 1]}) >>> i0 = xr.DataArray(['a', 'c'], dims=[""x""]) >>> i0 array(['a', 'c'], dtype='>> i1 = xr.DataArray([0, 1], dims=[""y""]) >>> i1 array([0, 1]) Dimensions without coordinates: y >>> a.sel(x=i0, y=i1) array([[0, 1], [4, 5]]) Coordinates: * x (x) >> a = xr.DataArray([0, 1, 2], dims=[""x""], coords={""x"": list(""abc"")}) >>> a array([0, 1, 2]) Coordinates: * x (x) >> i0 = xr.DataArray([['a', 'c']], dims=[""x0"", ""x1""]) >>> i0 array([['a', 'c']], dtype='>> a.sel(x=i0) array([[0, 2]]) Coordinates: x (x0, x1) object 'a' 'c' Dimensions without coordinates: x0, x1 ``` The resulting data array have the same dimensions as the indexer, not as the original data array. Notice also that the resulting data array has no dimension data array as opposed to the previous example. Instead, it has a bi-dimensional coordinate data array: ```python >>> a.sel(x=i0).coords[""x""] array([['a', 'c']], dtype=object) Coordinates: x (x0, x1) object 'a' 'c' Dimensions without coordinates: x0, x1 ```","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,359240638