Skip to content

Make modifying Cube CoordSystems easier #6030

@trexfeathers

Description

@trexfeathers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dragon Sub-Task 🦎https://github.com/orgs/SciTools/projects/19?pane=info

    Type

    No type

    Projects

    Status

    Done

    Status

    🏁 Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions