{"action":"opened","issue":{"url":"https://api.github.com/repos/SciTools/iris/issues/1530","labels_url":"https://api.github.com/repos/SciTools/iris/issues/1530/labels{/name}","comments_url":"https://api.github.com/repos/SciTools/iris/issues/1530/comments","events_url":"https://api.github.com/repos/SciTools/iris/issues/1530/events","html_url":"https://github.com/SciTools/iris/issues/1530","id":54776544,"number":1530,"title":"Cube.aggregated_by doesn't handle multi-dimensional AuxCoords","user":{"login":"rcomer","id":10599679,"avatar_url":"https://avatars.githubusercontent.com/u/10599679?v=3","gravatar_id":"","url":"https://api.github.com/users/rcomer","html_url":"https://github.com/rcomer","followers_url":"https://api.github.com/users/rcomer/followers","following_url":"https://api.github.com/users/rcomer/following{/other_user}","gists_url":"https://api.github.com/users/rcomer/gists{/gist_id}","starred_url":"https://api.github.com/users/rcomer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcomer/subscriptions","organizations_url":"https://api.github.com/users/rcomer/orgs","repos_url":"https://api.github.com/users/rcomer/repos","events_url":"https://api.github.com/users/rcomer/events{/privacy}","received_events_url":"https://api.github.com/users/rcomer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-19T15:23:44Z","updated_at":"2015-01-19T15:23:44Z","closed_at":null,"body":"This follows from a discussion on the [Google Group](https://groups.google.com/forum/?fromgroups=#!topic/scitools-iris/h2FVQ98YKn8).  If an AuxCoord spans more than one dimension, and Cube.aggregated_by is applies over one of those dimensions, the AuxCoord points are simply truncated.\r\n\r\nHere's a simple example:\r\n```python\r\nimport iris\r\nimport numpy as np\r\n\r\ndim_coord1 = iris.coords.DimCoord(range(3), long_name='first_dim')\r\ndim_coord2 = iris.coords.DimCoord(range(4), long_name='second_dim')\r\n\r\naux_coord2 = iris.coords.AuxCoord([0,0,1,1], long_name='aggregation_coord')\r\naux_coord_2d = iris.coords.AuxCoord(np.arange(12).reshape(3,4),\r\n                                                     long_name='spanning')\r\n                                    \r\ncube = iris.cube.Cube(np.ones((3,4)),\r\n                      dim_coords_and_dims=[(dim_coord1,0), (dim_coord2,1)],\r\n                      aux_coords_and_dims=[(aux_coord2, 1), (aux_coord_2d, (0,1))])\r\n\r\nnewcube = cube.aggregated_by('aggregation_coord', iris.analysis.SUM)\r\n\r\nprint newcube.coord('spanning')\r\n```\r\nThis gives:\r\n```python\r\nAuxCoord(array([[0, 1],\r\n       [4, 5],\r\n       [8, 9]]), standard_name=None, units=Unit('1'), long_name='spanning')\r\n```\r\nwhich is inconsistent with what we get when applying the aggregation to slices of the cube:\r\n\r\n```python\r\nfor i in range(3):\r\n    print cube[i].aggregated_by('aggregation_coord', iris.analysis.SUM).coord('spanning')\r\n\r\nAuxCoord(array([ 0.5,  2.5]), bounds=array([[0, 1],\r\n       [2, 3]]), standard_name=None, units=Unit('1'), long_name='spanning')\r\nAuxCoord(array([ 4.5,  6.5]), bounds=array([[4, 5],\r\n       [6, 7]]), standard_name=None, units=Unit('1'), long_name='spanning')\r\nAuxCoord(array([  8.5,  10.5]), bounds=array([[ 8,  9],\r\n       [10, 11]]), standard_name=None, units=Unit('1'), long_name='spanning')\r\n```"}}