{"action":"opened","issue":{"url":"https://api.github.com/repos/UV-CDAT/uvcdat/issues/1288","labels_url":"https://api.github.com/repos/UV-CDAT/uvcdat/issues/1288/labels{/name}","comments_url":"https://api.github.com/repos/UV-CDAT/uvcdat/issues/1288/comments","events_url":"https://api.github.com/repos/UV-CDAT/uvcdat/issues/1288/events","html_url":"https://github.com/UV-CDAT/uvcdat/issues/1288","id":73684350,"number":1288,"title":"Subsetting cdms2 variables using arbitrary indices","user":{"login":"durack1","id":3229632,"avatar_url":"https://avatars.githubusercontent.com/u/3229632?v=3","gravatar_id":"","url":"https://api.github.com/users/durack1","html_url":"https://github.com/durack1","followers_url":"https://api.github.com/users/durack1/followers","following_url":"https://api.github.com/users/durack1/following{/other_user}","gists_url":"https://api.github.com/users/durack1/gists{/gist_id}","starred_url":"https://api.github.com/users/durack1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durack1/subscriptions","organizations_url":"https://api.github.com/users/durack1/orgs","repos_url":"https://api.github.com/users/durack1/repos","events_url":"https://api.github.com/users/durack1/events{/privacy}","received_events_url":"https://api.github.com/users/durack1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-06T17:27:32Z","updated_at":"2015-05-06T17:27:32Z","closed_at":null,"body":"It would be great to be able to subset a cdms2 transientVariable using arbitrary indices - similar to the numpy.take function but applicable to multiple dimensions concurrently, so the 14 or so lines below could be condensed into something much more compact:\r\n```\r\nclimInfile = '/work/durack1/Shared/obs_data/WOA13/141027_woa/woa13_decav_t00_01.nc'\r\ncF = cdm.open(climInfile)\r\nclimDepths = cF.getAxis('depth').getData()\r\nanomDepths = uF.getAxis('level').getData()\r\ncommonLevels = np.intersect1d(climDepths,anomDepths)\r\nclim = cF('t_an') ; #,level=commonLevels)\r\ninds = []\r\nfor x,val in enumerate(commonLevels):\r\n    inds.append(np.where(climDepths==commonLevels[x])[0][0])\r\nclimTrim = np.take(clim,inds,axis=1)\r\nclimTrim = cdm.createVariable(climTrim,id='climTrim',missing_value=1e20)\r\nclimTrim.setAxis(0,clim.getAxis(0))\r\nclimTrim.setAxis(1,uF.getAxis('level'))\r\nclimTrim.setAxis(2,uF.getAxis('latitude'))\r\nclimTrim.setAxis(3,uF.getAxis('longitude'))\r\ndel(clim,inds,x,val,commonLevels,anomDepths,climDepths,climInfile) ; gc.collect()\r\ncF.close()\r\n```\r\nIn the case above, `uF` contains a subset of the depths found in the `cF` file which is loaded above.\r\n\r\nIdeally it would be great if this worked not only in index space, but also in value/data space so for e.g. in the above target levels could be specified rather than the indices captured in the variable `inds`\r\n\r\n@doutriaux1 can you add the cdms2 and enhancement labels please - and a milestone linked to existing issue #885 and PR #915"}}