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/1475#issuecomment-457951491,https://api.github.com/repos/pydata/xarray/issues/1475,457951491,MDEyOklzc3VlQ29tbWVudDQ1Nzk1MTQ5MQ==,1217238,2019-01-27T20:30:49Z,2019-01-27T20:30:49Z,MEMBER,"> What matters is how it will interact the indexes, i.e. can we easily select data based on cell bounds?
Either way, we will need to write our own index classes for this (but this is totally doable). This will either be something xarray specific or possibly based on `pandas.Index`.
`pandas.IntervalIndex` is similar, but is much more complex because it handles overlapping cells. We would prefer a `CellIndex` that does not allow for overlap.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,242181620
https://github.com/pydata/xarray/issues/1475#issuecomment-457874348,https://api.github.com/repos/pydata/xarray/issues/1475,457874348,MDEyOklzc3VlQ29tbWVudDQ1Nzg3NDM0OA==,1217238,2019-01-26T23:14:18Z,2019-01-26T23:14:18Z,MEMBER,"> Currently we distinguish between ""dimension coordinates,"" which are converted to indexes, and ""non-dimension coordinates.""
The long term plan in https://github.com/pydata/xarray/issues/1603 (""Explicit indexes"") is to eliminate this distinction -- we'll simply have variables, which can be in the form of data variables or coordinates, and indexes, for look-up along any coordinate.
> What if we added a new type of coordinate called ""cell coordinates""? We could accomodate either (N+1) sized coordinates for quad-mesh geometries or (N,M) sized coordinates for unstructured meshes.
I understand (N+1) sized coordinates for quad-mesh geometries, where N is the number of physical dimensions.
I'm not sure I understand (N,M) sized coordinates for unstructured meshes -- what is M here? The total number of cells? Some arbitrary constant indicating the maximum number of sides for a single cell?
I do.
Logically I see two approaches here:
1. Putting cell bounds into structured dtypes, and adding sugar to make these easier to use (as discussed in https://github.com/pydata/xarray/issues/1475#issuecomment-314844258).
2. Putting cell bounds directly into xarray's data model in some form, so we can deviate from our current rule that ""coordinates dimensions must be a subset of DataArray dimensions.""
(1) feels like the safe approach (from xarray's perpsective). Maybe structured dtypes too annoying to use on a routine basis, but there also are other use cases for them that would benefit from some attention. I worry that solutions in the style of (2) would bake domain specific logic deep into xarray's data model and make the whole library more complex, though I do appreciate that cell bounds are a pretty ubiquitous concept for modeling physical phenomena.
One way of solving (2) would be to allow something like ""isolated"" or ""non-aligned"" dimensions, which aren't shared across a Dataset/DataArray and are allowed to deviate on a per-variable basis. `Dataset.dims` would be a dynamic (rather than computed) part of xarray's data model, and dimensions not found in `dims` would not be required to be aligned/consistent between variables. This is intriguing but is also a much bigger change:
- By default (i.e., `dims=None`), `dims` would get filled in from all the variables in a Dataset. But the aligned dimensions in `dims` could also be set explicitly.
- If a dimension isn't found in `dims`, you can't index or align along it and it's allowed to vary between variables.
- DataArray objects would also need some way to distinguish between ""aligned"" and ""non-aligned"" dimensions. It's less clear what this would be.
- Only aligned dimensions on coordinates of a DataArray are required to be found on the DataArray variable.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,242181620
https://github.com/pydata/xarray/issues/1475#issuecomment-314844258,https://api.github.com/repos/pydata/xarray/issues/1475,314844258,MDEyOklzc3VlQ29tbWVudDMxNDg0NDI1OA==,1217238,2017-07-12T17:44:28Z,2017-07-12T17:44:28Z,MEMBER,"I don't think we need a full `NDIntervalIndex` unless we also want indexing, which is nice but not essential for just storing data. We do need a way to represent interval data in 1D arrays, though.
Probably the simplest option is to use structured dtypes, which should already work with the existing version of xarray, e.g.,
```
import numpy as np
import xarray
interval_dtype = np.dtype([('start', float), ('stop', float)])
coords = {'x': 0.5 + np.arange(3), 'x_bounds': ('x', np.array([(0, 1), (1, 2), (2, 3)], dtype=interval_dtype))}
da = xarray.DataArray(range(3), coords=coords, dims='x')
```
```
>>> da
array([0, 1, 2])
Coordinates:
* x (x) float64 0.5 1.5 2.5
x_bounds (x) [('start', '>> da.x_bounds
array([(0.0, 1.0), (1.0, 2.0), (2.0, 3.0)],
dtype=[('start', '>> da.x_bounds.data['start'], da.x_bounds.data['stop']
(array([ 0., 1., 2.]), array([ 1., 2., 3.]))
```
We could probably do a few things to make these easier to use:
1. Support indexing like `da.x_bounds['start']` to return `da.x_bounds.data['start']` wrapped in an `xarray.DataArray`.
2. Automatically create them as part of netCDF IO.
Conceptually, this is pretty similar to a MultiIndex (see https://github.com/pydata/xarray/pull/1426 for discussion).","{""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,242181620