{"action":"created","issue":{"url":"https://api.github.com/repos/xray/xray/issues/649","labels_url":"https://api.github.com/repos/xray/xray/issues/649/labels{/name}","comments_url":"https://api.github.com/repos/xray/xray/issues/649/comments","events_url":"https://api.github.com/repos/xray/xray/issues/649/events","html_url":"https://github.com/xray/xray/issues/649","id":115897556,"number":649,"title":"error when using broadcast_arrays with coordinates","user":{"login":"rabernat","id":1197350,"avatar_url":"https://avatars.githubusercontent.com/u/1197350?v=3","gravatar_id":"","url":"https://api.github.com/users/rabernat","html_url":"https://github.com/rabernat","followers_url":"https://api.github.com/users/rabernat/followers","following_url":"https://api.github.com/users/rabernat/following{/other_user}","gists_url":"https://api.github.com/users/rabernat/gists{/gist_id}","starred_url":"https://api.github.com/users/rabernat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rabernat/subscriptions","organizations_url":"https://api.github.com/users/rabernat/orgs","repos_url":"https://api.github.com/users/rabernat/repos","events_url":"https://api.github.com/users/rabernat/events{/privacy}","received_events_url":"https://api.github.com/users/rabernat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-09T15:16:32Z","updated_at":"2015-11-09T16:05:29Z","closed_at":null,"body":"I frequently use ``broadcast_arrays`` to to feed xray variables to non-xray libraries (e.g. [gsw](https://github.com/TEOS-10/python-gsw).) Often I need to broadcast the coordinates and variables in order to do call functions that take both as arguments.\r\n\r\nI have found that ``broadcast_arrays`` doesn't work as I expect with coordinates. For example\r\n\r\n```python\r\nimport xray\r\nimport numpy as np\r\nds = xray.Dataset({'a': (['y','x'], np.ones((20,10)))},\r\n                  coords={'x': (['x'], np.arange(10)),\r\n                          'y': (['y'], np.arange(20))})\r\nxbc, ybc, abc = xray.broadcast_arrays(ds.x, ds.y, ds.a)\r\n```\r\n\r\nThis raises ``ValueError: an index variable must be defined with 1-dimensional data``. \r\n\r\nIf I change the last line to\r\n```python\r\nxbc, ybc, abc = xray.broadcast_arrays(1*ds.x, 1*ds.y, ds.a)\r\n```\r\nit works fine.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/xray/xray/issues/comments/155107254","html_url":"https://github.com/xray/xray/issues/649#issuecomment-155107254","issue_url":"https://api.github.com/repos/xray/xray/issues/649","id":155107254,"user":{"login":"ocefpaf","id":950575,"avatar_url":"https://avatars.githubusercontent.com/u/950575?v=3","gravatar_id":"","url":"https://api.github.com/users/ocefpaf","html_url":"https://github.com/ocefpaf","followers_url":"https://api.github.com/users/ocefpaf/followers","following_url":"https://api.github.com/users/ocefpaf/following{/other_user}","gists_url":"https://api.github.com/users/ocefpaf/gists{/gist_id}","starred_url":"https://api.github.com/users/ocefpaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocefpaf/subscriptions","organizations_url":"https://api.github.com/users/ocefpaf/orgs","repos_url":"https://api.github.com/users/ocefpaf/repos","events_url":"https://api.github.com/users/ocefpaf/events{/privacy}","received_events_url":"https://api.github.com/users/ocefpaf/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T16:05:29Z","updated_at":"2015-11-09T16:05:29Z","body":"Hi @rabernat,\r\n\r\nMost `gsw` functions will call `np.broadcast_arrays` for you internally.  So you can pass `ds.a.values` instead.  It is ugly, I know. but consistent when using libraries that expect numpy array."}}