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

Make modifying Cube CoordSystems easier #6030

Open
Tracked by #3796
trexfeathers opened this issue Jul 1, 2024 · 5 comments
Open
Tracked by #3796

Make modifying Cube CoordSystems easier #6030

trexfeathers opened this issue Jul 1, 2024 · 5 comments
Labels
Dragon Sub-Task 🦎 https://github.com/orgs/SciTools/projects/19?pane=info

Comments

@trexfeathers
Copy link
Contributor

trexfeathers commented Jul 1, 2024

From conversations on #4719:

The proposal in Step 2 will often give rise to code like this:

for cube in my_cube_list:
   for coord in cube.coords():
   	coord.coord_system.encode_axis_order = True
my_cube_list.save("tmp.nc")

Which is quite clunky. We also regularly find user confusion about the difference between Coord.coord_system and Cube.coord_system(), and adding the need to do the above will only increase the frequency of confusion.

So: it would be good to provide more convenience for modifying coord_system at the Cube level - i.e. automatically modify the coord_system of all Coords attached to the Cube, assuming they are identical.

If sensible, we think it should take the form of Cube.coord_system - a @property that can be set - rather than the current method (coord_system()), which just invites confusion. The method would have to stay until the next major release of course.


suggestion is going to be clunky; coordinate_system objects aren't shared across coordinates, so would either need a rehaul of how it works, or more effort on the user's side.
Instead, we would offer a docstring tutorial in the new code. This seems to be the more sensible option.

@trexfeathers trexfeathers added the Dragon Sub-Task 🦎 https://github.com/orgs/SciTools/projects/19?pane=info label Jul 1, 2024
@larsbarring
Copy link
Contributor

This might be a naive question, but is there a use case for having different grid mappings for different coordinates?

@trexfeathers
Copy link
Contributor Author

This might be a naive question, but is there a use case for having different grid mappings for different coordinates?

The CF data model actually attaches grid mappings to the data variables, which has often seemed odd to us. Following CF would force us to NOT have different grid mappings for different coordinates.

Of course Iris has done the more 'sensible' thing of storing coordinate systems on the coordinates themselves, since that is where they have meaning, so this allows coordinates to 'move around' and be used in different Cubes. And it already allows for different grid mappings on different coordinates - they just can't be saved.

Whatever we do with this issue will need to account for different coordinates having different CoordSystems.

@pp-mo
Copy link
Member

pp-mo commented Jul 2, 2024

This might be a naive question, but is there a use case for having different grid mappings for different coordinates?

The CF data model actually attaches grid mappings to the data variables, which has often seemed odd to us. Following CF would force us to NOT have different grid mappings for different coordinates.

Of course Iris has done the more 'sensible' thing of storing coordinate systems on the coordinates themselves, since that is where they have meaning, so this allows coordinates to 'move around' and be used in different Cubes. And it already allows for different grid mappings on different coordinates - they just can't be saved.

Whatever we do with this issue will need to account for different coordinates having different CoordSystems.

Well, that's only the case for the "classic" grid-mapping syntax.
There is provision in CF for different coord systems applying to different coordinates.
.. but it's outstanding work for us to support it
See : #3388

This might be on its way now, since we are hoping to make #4719 work

@larsbarring
Copy link
Contributor

Probably I was misunderstanding the comment

... coordinate_system objects aren't shared across coordinates ...

as meaning that e.g. x and y coordinates could have different gridmappings attached to them. But, as was noted in #3388, referring to CF Example 5.10, a data variable, Cube, may have several gridmappings, but each one is attached to the coordinates (plural) that define the grid.

@ESadek-MO
Copy link
Contributor

@SciTools/peloton Sorry for any confusion, here's what we know:

We can't think of a use-case for different coord systems on x and y, although there might be one we don't know about. Iris can store this situation now, but all of Iris' operations assume that they will be identical. The CF extended grid mapping makes it possible to load and save different coord systems, see #3388 for making this possible in Iris.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dragon Sub-Task 🦎 https://github.com/orgs/SciTools/projects/19?pane=info
Projects
Status: No status
Development

No branches or pull requests

4 participants