iris icon indicating copy to clipboard operation
iris copied to clipboard

MeshCoord should support a coordinate system

Open pp-mo opened this issue 1 year ago • 1 comments

On general principles, since a MeshCoord is designed to be a "window" on other data, it should probably "have" the coord-system of the underlying coordinates from which it takes its values + metadata.

context in UGRID

At present, there is no agreed way of attaching a coordinate-system (i.e. grid-mapping) to coordinates of a mesh, since in CF that may only occur via a data-variable.

context in Iris

However, Iris considers the coord-system to be part of a Coord. So, it should make perfectly good sense for a coordinate of a Mesh to have one (though there is currently an apparent bug preventing it). Likewise, it probably makes sense for the coord-system of a MeshCoord to always follow that of the associated node coordinates, as established for the other metadata.

Desired implementation:

Since a face- or edge-located MeshCoord takes its bounds from the (re-indexed) node_coordinates, and its points from the face_coordinates or edge_coordinates (which however are technically optional), it makes sense that the MeshCoord should inherit a coord_system from either of those -- and if different, that should probably be an error. For now, the coord_system of a MeshCoord is always None, and must always be so.

Related

  • https://github.com/SciTools/iris/issues/5557 : means that the node-coords of a mesh can't actually have a coord-system, at present.
  • the face- or edge-coordinates, though they are technically optional in UGRID, are currently required in Iris

pp-mo avatar Nov 01 '23 09:11 pp-mo

We expect that in many cases UGRID files will be loaded with no coordinate systems, since there is little detail about grid_mapping in relation to UGRID. There is some debate between Iris developers about whether we should assume a standard GeogCS coordinate system in these cases, since that appears to be UGRID's assumption.

However UGRID is flexible enough that coordinates could really be anything - XY / XYZ / spherical coordinates / S2 indices / ... - and we have already made Iris more rigid than it should be in this regard, so I am personally uncomfortable with baking in even more assumptions.

Therefore, in addition to MeshCoord inheriting the underlying coordinate system, I would also advocate for a new method: Mesh.add_default_coord_system(), which would modify all the Mesh's coordinates by adding GeogCS(iris.analysis.cartography.DEFAULT_SPHERICAL_EARTH_RADIUS). My reasoning being that it would be better for the user to opt-in, rather than obliging them to opt-out.

trexfeathers avatar Jun 06 '24 12:06 trexfeathers