Skip to content

Implement Cube.remesh #4751

@wjbenfold

Description

@wjbenfold

✨ Feature Request

Some operations on an iris.cube.Cube with an unstrcutured mesh attached cause this mesh to be lost and the MeshCoords to become normal AuxCoords. I propose that we add a remesh method to a Cube that can be used to recreate a mesh in this situation.

The remesh method would need to take an argument specifying the dimension the mesh coordinates should be taken from (or the actual coordinates) and could optionally clean the mesh up by reducing duplicated nodes down to a single node.

Motivation

Currently, the remeshing process requires the same five(ish) lines of code from the user whenever this occurs, or their own function. By offering this convenience we can make this easier. I wouldn't go as far as to remesh cubes automatically after an operation appears to have caused a user to inadvertently drop the mesh from a cube because I think that's too far towards making their decisions for them.

Example code for doing this job:

new_mesh = Mesh.from_coords(*region_cube.coords(dimensions=1))
new_mesh_coords = new_mesh.to_MeshCoords(conv_cube.location)
for coord in new_mesh_coords:
    region_cube.remove_coord(coord.name())
    region_cube.add_aux_coord(coord, 1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions