issue_comments: 1247731386
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-1247731386 | https://api.github.com/repos/pydata/xarray/issues/7031 | 1247731386 | IC_kwDOAMm_X85KXt66 | 4160723 | 2022-09-15T08:03:50Z | 2022-09-15T08:03:50Z | MEMBER | Great @TomNicholas! To avoid copying the body of ```python class PeriodicBoundaryIndex(PandasIndex): """ An index representing any 1D periodic numberline.
``` Note: I also added It should work in most cases I think: ```python lon_coord = xr.DataArray(data=np.linspace(-180, 180, 19), dims="lon") da = xr.DataArray(data=np.random.randn(19), dims="lon", coords={"lon": lon_coord}) note the period set hereworld = da.drop_indexes("lon").set_xindex("lon", index_cls=PeriodicBoundaryIndex, period=360) ``` ```python world.sel(lon=200, method="nearest") <xarray.DataArray ()>array(-0.86583185)Coordinates:lon float64 -160.0world.sel(lon=[200, 200], method="nearest") <xarray.DataArray (lon: 2)>array([-0.86583185, -0.86583185])Coordinates:* lon (lon) float64 -160.0 -160.0world.sel(lon=slice(180, 200), method="nearest") <xarray.DataArray (lon: 2)>array([-1.59829997, -0.86583185])Coordinates:* lon (lon) float64 -180.0 -160.0``` There's likely more things to do for slices as you point out. I don't think either that it's possible to pass two slices to If we really need more flexibility in Or like you suggest we could define some |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1372035441 |