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

Allow MeshCoord to have a coord-system #6016

Merged
merged 7 commits into from
Jul 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/iris/experimental/ugrid/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2781,6 +2781,11 @@ def fix_repr(val):
)
raise ValueError(msg)

# Don't use 'coord_system' as a constructor arg, since for
# MeshCoords it is deduced from the mesh.
# (Otherwise a non-None coord_system breaks the 'copy' operation)
use_metadict.pop("coord_system")
stephenworsley marked this conversation as resolved.
Show resolved Hide resolved

# Call parent constructor to handle the common constructor args.
super().__init__(points, bounds=bounds, **use_metadict)

Expand All @@ -2806,8 +2811,19 @@ def axis(self):

@property
def coord_system(self):
"""The coordinate-system of a MeshCoord is always 'None'."""
return None
"""The coordinate-system of a MeshCoord comes from its origin coords."""
select_kwargs = {
f"include_{self.location}s": True,
pp-mo marked this conversation as resolved.
Show resolved Hide resolved
"axis": self.axis,
}
try:
location_coord = self.mesh.coord(**select_kwargs)
coord_system = location_coord.coord_system
except CoordinateNotFoundError:
# No location coord : possible in UGRID but probably not Iris (at present).
coord_system = None

return coord_system

@coord_system.setter
def coord_system(self, value):
Expand Down
Loading