Open
Description
🐛 Bug Report
Unable to perform a rolling window mean over a lazy year
auxiliary coordinate.
How to Reproduce
Steps to reproduce the behaviour:
>>> import iris
>>> iris.__version__
'3.12.0'
>>> import iris
>>> fname = "rnt_Eyeargm_HadGEM3-GC31-LL_piControl_r1i1p1f1_gn_18500101-30000101.nc"
>>> cube = iris.load_cube(fname)
>>> print(cube)
toa_net_downward_radiative_flux / (W m-2) (time: 1150)
Dimension coordinates:
time x
Auxiliary coordinates:
year x
Scalar coordinates:
latitude 0.0 degrees, bound=(-90.0, 90.0) degrees
longitude 180.0 degrees, bound=(0.0, 360.0) degrees
Cell methods:
0 longitude: latitude: mean
Attributes:
<snip>
>>> cube
<iris 'Cube' of toa_net_downward_radiative_flux / (W m-2) (time: 1150)>
>>> result = cube.rolling_window("year", iris.analysis.MEAN, 11)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<snip>/lib/python3.12/site-packages/iris/cube.py", line 4922, in rolling_window
new_bounds = new_bounds[:, (0, -1)]
~~~~~~~~~~^^^^^^^^^^^^
File "<snip>/lib/python3.12/site-packages/dask/array/core.py", line 2045, in __getitem__
index2 = normalize_index(index, self.shape)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<snip>/lib/python3.12/site-packages/dask/array/slicing.py", line 848, in normalize_index
check_index(axis, i, d)
File "<snip>/lib/python3.12/site-packages/dask/array/slicing.py", line 919, in check_index
elif ind >= dimension or ind < -dimension:
^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'tuple' and 'int'
>>>
Expected Behaviour
Making the year
coordinate points eager fixes the issue i.e.,
>>> import iris
>>> fname = "rnt_Eyeargm_HadGEM3-GC31-LL_piControl_r1i1p1f1_gn_18500101-30000101.nc"
>>> cube = iris.load_cube(fname)
>>> cube.coord("year").has_lazy_points()
True
>>> _ = cube.coord("year").points # <------ make the points eager
>>> cube.coord("year").has_lazy_points()
False
>>> result = cube.rolling_window("year", iris.analysis.MEAN, 11)
>>> print(result)
toa_net_downward_radiative_flux / (W m-2) (time: 1140)
Dimension coordinates:
time x
Auxiliary coordinates:
year x
Scalar coordinates:
latitude 0.0 degrees, bound=(-90.0, 90.0) degrees
longitude 180.0 degrees, bound=(0.0, 360.0) degrees
Cell methods:
0 longitude: latitude: mean
1 year: mean
Attributes:
<snip>
Environment
iris
3.12python
3.12
Metadata
Metadata
Assignees
Type
Projects
Status
No status