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

MeshCoord cannot compare with an 'equivalent' ordinary AuxCoord #4671

Open
pp-mo opened this issue Mar 29, 2022 · 2 comments
Open

MeshCoord cannot compare with an 'equivalent' ordinary AuxCoord #4671

pp-mo opened this issue Mar 29, 2022 · 2 comments

Comments

@pp-mo
Copy link
Member

pp-mo commented Mar 29, 2022

The definitive metadata of a MeshCoord is just mesh, location + axis.

These can be leniently compared with another one, e.g. to fetch the matching coord from a cube on a different mesh :
For example...

>>> import  iris.tests.stock.mesh as ism
>>> cube1 = ism.sample_mesh_cube(mesh=ism.sample_mesh(n_nodes=10, n_faces=3, n_edges=0))
>>> cube2 = ism.sample_mesh_cube(mesh=ism.sample_mesh(n_nodes=10, n_faces=4, n_edges=0))
>>> co = cube1.coord('latitude')
>>> co
<MeshCoord: latitude / (unknown)  mesh(<Mesh object at 0x7ff8906fc580>) location(face)  [...]+bounds  shape(3,)>
>>> cube2.coord(co)
<MeshCoord: latitude / (unknown)  mesh(<Mesh object at 0x7ff8906cbdf0>) location(face)  [...]+bounds  shape(4,)>
>>> 

However, a MeshCoord can be "reduced" to an equivalent AuxCoord (i.e. with same names, units, points + bounds).
This happens automatically when a cube is sub-indexed, e.g. "meshcube[..., 2]" or just "meshcube[..., 0:]".
However, the AuxCoord can never "compare with" the original, since the metadata structure is too different.
Hence, code analagous to the above won't work...

>>> import  iris.tests.stock.mesh as ism
>>> cube = ism.sample_mesh_cube()
>>> cube1 = ism.sample_mesh_cube()
>>> cube2 = cube1[..., 0:]
>>> co1 = cube1.coord('latitude')
>>> co1
<MeshCoord: latitude / (unknown)  mesh(<Mesh object at 0x7ff8906590a0>) location(face)  [...]+bounds  shape(3,)>
>>> co2 = cube2.coord('latitude')
>>> co2
<AuxCoord: latitude / (unknown)  [3200, 3201, 3202]+bounds  shape(3,)>
>>> cube2.coord(co1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/h05/itpp/git/iris/iris_main/lib/iris/cube.py", line 1919, in coord
    raise iris.exceptions.CoordinateNotFoundError(emsg)
iris.exceptions.CoordinateNotFoundError: "Expected to find exactly 1 'latitude' coordinate, but found none."
>>> 

I.E. you cannot find the "equivalent" coord in this way, when one is a MeshCoord and the other a 'normal' Coord.
However, that does work for a "normal" cube, including finding matching coords of a different type i.e. DimCoord <-> AuxCoord.

This is likely to cause problems in some generic operations, e.g. regridding.

@github-actions
Copy link
Contributor

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

@github-actions github-actions bot added the Stale A stale issue/pull-request label Aug 20, 2023
@pp-mo pp-mo added Feature: UGRID Status: Decision Required and removed Stale A stale issue/pull-request labels Aug 30, 2023
@scitools-ci scitools-ci bot removed this from 🚴 Peloton Dec 15, 2023
@trexfeathers
Copy link
Contributor

See #4751 and #5991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants