issues: 83000406
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
83000406 | MDU6SXNzdWU4MzAwMDQwNg== | 411 | unexpected positional indexing behavior with Dataset and DataArray "isel" | 2443309 | closed | 0 | 5 | 2015-05-31T04:48:10Z | 2015-06-01T05:03:38Z | 2015-06-01T05:03:29Z | MEMBER | I may be missing something here but I think the indexing behavior in From the
My example below uses two 1d ``` python import numpy as np import xray import sys print('python version:', sys.version) print('numpy version:', np.version.full_version) print('xray version:', xray.version.version) ```
``` python A few numpy arraystime = np.arange(100) lons = np.arange(40, 60) lats = np.arange(25, 70) np_data = np.random.random(size=(len(time), len(lats), len(lons))) pick some random points to selectys, xs = np.nonzero(np_data[0] > 0.8) print(len(ys)) ```
``` python create a xray.DataArray and xray.Datasetxr_data = xray.DataArray(np_data, [('time', time), ('y', lats), ('x', lons)]) # DataArray xr_ds = xr_data.to_dataset(name='data') # Dataset numpy indexingprint('numpy: ', np_data[:, ys, xs].shape) xray positional indexingprint('xray1: ', xr_data.isel(y=ys, x=xs).shape) print('xray2: ', xr_data[:, ys, xs].shape) print('xray3: ', xr_ds.isel(y=ys, x=xs)) ```
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/411/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |