Skip to content

Can't collapse mesh #5377

@bblay

Description

@bblay

🐛 Bug Report

It's not possible to collapse a mesh cube.
There's an error as it tries to collapse the mesh coord.

    return newcube.collapsed(coords, aggregator, **aggkeys)
  File "/home/h02/bblay/.conda/envs/autoassess_new/lib/python3.10/site-packages/iris/cube.py", line 3904, in collapsed
    collapsed_cube.replace_coord(coord.collapsed(local_dims))
  File "/home/h02/bblay/.conda/envs/autoassess_new/lib/python3.10/site-packages/iris/coords.py", line 2284, in collapsed
    coord = self.copy(points=points, bounds=bounds)
  File "/home/h02/bblay/.conda/envs/autoassess_new/lib/python3.10/site-packages/iris/experimental/ugrid/mesh.py", line 2973, in copy
    raise ValueError(msg)
ValueError: Cannot change the content of a MeshCoord.

@pp-mo suggests, "I think this is probably a little bug introduced because MeshCoords are "like" AuxCoords but a bit different.", and also suggests a workaround is to remove the mesh coords, "You need to index the cube on the mesh dimension, with something other than ':' or 'slice(None)'." e.g with cube[..., 0:] or cube[tuple(slice(0, None) for _ in cube.shape)]).

Environment

  • Iris Version: 3.6

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions