Example: when the upper bound of a point_x is at 0, the following code returns point_x, instead of wrapping the point to 360-point_x:
target_grid.intersection(iris.coords.CoordExtent('longitude', 0, 360))
we have noticed this too, here is a minimal example that reproduces the problem hassle-free:
import iris
import numpy as np
lon_points = np.array([-8.75, -6.25, -3.75, -1.25, 1.25, 3.75, 6.25, 8.75, 11.25,
13.75, 16.25, 18.75, 21.25, 23.75, 26.25, 28.75, 31.25, 33.75,
36.25, 38.75])
lon_bounds = np.array([[ -2.5, 0. ], [ 0. , 2.5],
[ 2.5, 5. ], [ 5. , 7.5],
[ 7.5, 10. ], [ 10. , 12.5],
[ 12.5, 15. ], [ 15. , 17.5],
[ 17.5, 20. ], [ 20. , 22.5],
[ 22.5, 25. ], [ 25. , 27.5],
[ 27.5, 30. ], [ 30. , 32.5],
[ 32.5, 35. ], [ 35. , 37.5],
[ 37.5, 40. ], [350. , 352.5],
[352.5, 355. ], [355. , 357.5]])
lons = iris.coords.DimCoord(lon_points, standard_name='longitude', bounds=lon_bounds,
units='degrees_east')
cube = iris.cube.Cube(np.zeros((20,)), dim_coords_and_dims=[(lons, 0)])
isect_with_bounds = cube.intersection(longitude=(0, 360))
print(isect_with_bounds.coord("longitude"))
cube.coord("longitude").bounds = None
isect_without_bounds = cube.intersection(longitude=(0, 360))
print(isect_without_bounds.coord("longitude"))
cube.coord("longitude").guess_bounds()
isect_guessbounds = cube.intersection(longitude=(0, 360))
print(isect_guessbounds.coord("longitude"))
@bjlittle @pelson @lbdreyer what you guys reckon? Muchos cheers :beer:
just a heads up that the behavior is exactly the same as described above for iris=3.0.1 too so the issue still stands, friendly ping to @bjlittle @lbdreyer :+1: :beer:
I think I can see how to fix this. Will unassign myself if I'm wrong!
cheers muchly @rcomer :beer:
Now fixed in v3.0.x by #4059