-
Notifications
You must be signed in to change notification settings - Fork 297
Closed
Description
Suppose we have a set of cubes with matching dim coords but mismatched aux coords:
import iris
orig_cube = iris.cube.Cube(range(4), long_name='foo')
orig_cube.add_dim_coord(iris.coords.DimCoord(range(4), long_name='bar'), 0)
cubelist = iris.cube.CubeList()
for i in range(5):
new_cube = orig_cube.copy()
new_cube.add_aux_coord(
iris.coords.DimCoord(i + 1, standard_name='realization'))
new_cube.add_aux_coord(
iris.coords.DimCoord(range(i // 3, i // 3 + 4), long_name='baz'), 0)
cubelist.append(new_cube)These will merge into 2 cubes:
print(cubelist.merge())
0: foo / (unknown) (realization: 3; bar: 4)
1: foo / (unknown) (realization: 2; bar: 4)If I try to merge to a single cube, I get a useful error about the mismatched coord:
print(cubelist.merge_cube())
iris.exceptions.MergeError: failed to merge into a single cube.
Coordinates in cube.aux_coords (non-scalar) differ: baz.However, if each of these cubes is in its own file and I try to load them as one cube, I get a not so helpful error:
for i, cube in enumerate(cubelist):
iris.save(cube, 'test_{}.nc'.format(i))
iris.load_cube('test_?.nc')
iris.exceptions.ConstraintMismatchError: failed to merge into a single cube.
cube.shape differs: (3, 4) != (2, 4)It appears that iris.load_cube tries to re-merge a cubelist that has already been merged. Could the first merge be skipped?