Skip to content

Commit

Permalink
Review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Jul 17, 2024
1 parent 5cc17b6 commit f8ef8e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/iris/experimental/ugrid/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2814,16 +2814,19 @@ def axis(self):

@property
def coord_system(self):
"""The coordinate-system of a MeshCoord comes from the related mesh coord."""
"""The coordinate-system of a MeshCoord.
It comes from the `related` location coordinate in the mesh.
"""
# This matches where the coord metadata is drawn from.
# See : https://github.com/SciTools/iris/issues/4860
select_kwargs = {
f"include_{self.location}s": True,
"axis": self.axis,
}
try:
# NOTE: at present, a MeshCoord *always* references a related mesh coord of
# its location, from which it's points are taken.
# NOTE: at present, a MeshCoord *always* references the relevant location
# coordinate in the mesh, from which its points are taken.
# However this might change in future ..
# see : https://github.com/SciTools/iris/discussions/4438#bounds-no-points
location_coord = self.mesh.coord(**select_kwargs)
Expand Down
17 changes: 17 additions & 0 deletions lib/iris/tests/integration/experimental/test_meshcoord_coordsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,20 @@ def test_assigned_mesh_cs(tmp_path):
# since there are no dim-coords, or any other coord with a c-s.
# TODO: this may be a mistake -- see https://github.com/SciTools/iris/issues/6051
assert cube.coord_system() is assigned_cs


def test_meshcoord_coordsys_copy(tmp_path):
# Check that copying a meshcoord with a coord system works properly.
nc_path = tmp_path / "test_temp.nc"
make_file(nc_path)
with PARSE_UGRID_ON_LOAD.context():
cube = iris.load_cube(nc_path, "node_data")
node_coord = cube.mesh.coord(include_nodes=True, axis="x")
assigned_cs = GeogCS(1.0)
node_coord.coord_system = assigned_cs
mesh_coord = cube.coord(axis="x")
assert mesh_coord.coord_system is assigned_cs
meshco_copy = mesh_coord.copy()
assert meshco_copy == mesh_coord
# Note: still the same object, because it is derived from the same node_coord
assert meshco_copy.coord_system is assigned_cs

0 comments on commit f8ef8e0

Please sign in to comment.