issue_comments: 1248518310
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/7031#issuecomment-1248518310 | https://api.github.com/repos/pydata/xarray/issues/7031 | 1248518310 | IC_kwDOAMm_X85KauCm | 35968931 | 2022-09-15T19:24:26Z | 2022-09-15T19:51:46Z | MEMBER | Okay I think this design could work for slicing across boundaries: ```python from xarray.core.indexes import PandasIndex, IndexSelResult, _query_slice from xarray.core.indexing import _expand_slice class PeriodicBoundaryIndex(PandasIndex): """ An index representing any 1D periodic numberline.
``` ```python world.sel(lon=slice(60, 120), method="nearest") <xarray.DataArray (lon: 4)>array([-0.71424378, -0.87270922, -0.9701637 , -0.99979417])Coordinates:* lon (lon) float64 60.0 80.0 100.0 120.0``` This works even for slices that cross the dateline ```python world.sel(lon=slice(160, 210), method="nearest") <xarray.DataArray (lon: 4)>array([-0.85218366, -0.68526211, 0.68526211, 0.85218366])Coordinates:* lon (lon) float64 160.0 180.0 -180.0 -160.0``` This isn't general yet, there are lots of edge cases this would fail on, but I think it shows that as long as each case is captured we always could use this approach to remap back to index values that do lie within the range? What do people think? EDIT:
I believe what I've done here is the closest thing to that that is possible with the given interface. |
{ "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1372035441 |