-
Notifications
You must be signed in to change notification settings - Fork 298
Closed
Description
Try the following:
import iris
import iris.cube
import numpy as np
cube = iris.cube.Cube(np.zeros((12, 2, 2)), standard_name='wind_speed', units='m s-1')
co_y = iris.coords.AuxCoord([1996, 1997, 1997, 1996, 1997, 1997, 1996, 1997, 1997, 1996, 1997, 1997], long_name='year')
co_m = iris.coords.AuxCoord(['Dec', 'Jan', 'Feb']*4, long_name='month')
co_r = iris.coords.AuxCoord([2, 2, 2, 3, 3, 3, 4, 4, 4, 1, 1, 1], standard_name=u'realization')
cube.add_aux_coord(co_y, 0)
cube.add_aux_coord(co_m, 0)
cube.add_aux_coord(co_r, 0)
print(cube)
means = cube.aggregated_by(['month','year'],iris.analysis.MEAN)
print('means.coord(\'realization\'):\n', means.coord('realization'))Result is:
>>> print cube
wind_speed / (m s-1) (-- : 12; -- : 2; -- : 2)
Auxiliary coordinates:
month x - -
realization x - -
year x - -
>>>
>>> means = cube.aggregated_by(['month','year'],iris.analysis.MEAN)
>>> print 'means.coord(\'realization\'):\n', means.coord('realization')
means.coord('realization'):
AuxCoord(array([ 1.5, 1.5, 1.5]), bounds=array([[2, 1],
[2, 1],
[2, 1]]), standard_name=u'realization', units=Unit('1'))
>>>
But we expected
- all points == 2 (instead of 1.5)
- all bounds == [1, 4] (instead of [2, 1])
Note:
Trying subsets of the data suggests that it is the last 3 realization values being out-of-order which triggers the problem...
>>> means = cube[:9].aggregated_by(['month','year'],iris.analysis.MEAN)
>>> print means.coord('realization')
AuxCoord(array([ 3., 3., 3.]), bounds=array([[2, 4],
[2, 4],
[2, 4]]), standard_name=u'realization', units=Unit('1'))
>>> means = cube[6:].aggregated_by(['month','year'],iris.analysis.MEAN)
>>> print means.coord('realization')
AuxCoord(array([ 2.5, 2.5, 2.5]), bounds=array([[4, 1],
[4, 1],
[4, 1]]), standard_name=u'realization', units=Unit('1'))
Metadata
Metadata
Assignees
Labels
No labels