-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cube.intersection out of bounds point #3391
Comments
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 🍺 |
I think I can see how to fix this. Will unassign myself if I'm wrong! |
cheers muchly @rcomer 🍺 |
Now fixed in v3.0.x by #4059 |
thank you very much @rcomer - just tested it and with |
Thanks for the feedback @valeriupredoi 🍻 |
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))
The text was updated successfully, but these errors were encountered: