Skip to content
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

iris.util.reverse does not flip coordinate bounds correctly #3756

Closed
schlunma opened this issue Jul 16, 2020 · 2 comments · Fixed by #4466
Closed

iris.util.reverse does not flip coordinate bounds correctly #3756

schlunma opened this issue Jul 16, 2020 · 2 comments · Fixed by #4466

Comments

@schlunma
Copy link
Contributor

I found an issue in iris.util.reverse:

import iris
print(iris.__version__)
print()

lat_coord = iris.coords.DimCoord([10, 20], bounds=[[5, 15], [15, 25]],
                                 standard_name='latitude')
cube = iris.cube.Cube([0.0, 1.0], dim_coords_and_dims=[(lat_coord, 0)])
reversed_cube = iris.util.reverse(cube, lat_coord)

print("Old lat coord:", cube.coord('latitude'))
print("Reversed lat coord:", reversed_cube.coord('latitude'))
print()
print("Old lat contiguous:", cube.coord('latitude').is_contiguous())
print("Reversed lat contiguous:", reversed_cube.coord('latitude').is_contiguous())

gives

2.4.0

Old lat coord: DimCoord(array([10, 20]), bounds=array([[ 5, 15],
       [15, 25]]), standard_name='latitude', units=Unit('1'))
Reversed lat coord: DimCoord(array([20, 10]), bounds=array([[15, 25],
       [ 5, 15]]), standard_name='latitude', units=Unit('1'))

Old lat contiguous: True
Reversed lat contiguous: False

As you can see, the bounds of the coordinate have not been reversed correctly: Instead of [[15, 25], [5, 15]], they should be [[25, 15], [15, 5]]. As a side effect, coord.is_contiguous() fails now (that's how I discovered this issue).

@ajdawson
Copy link
Member

I think this is a duplicate of #3249 and there is prior discussion from years ago in #423. In short, this does look incorrect according to the CF specifications and should be fixed. @pp-mo do you know if this work is planned?

@trexfeathers trexfeathers added this to the v3.1.0 milestone Aug 21, 2020
@trexfeathers
Copy link
Contributor

We're hoping to take a look at this for Iris v3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants