From 6c6100e04d8aee9d84903ef01c65575c069c7c20 Mon Sep 17 00:00:00 2001 From: James Frost Date: Wed, 28 Jan 2026 16:57:03 +0000 Subject: [PATCH] Handle converting multiple wind cubes to point to true north This avoids crashing when loading data with more than one of each wind component, such as an instantaneous and an aggregation cube. This was especially problematic as it runs in the callback stage, so it will crash even recipes that don't use the wind. --- src/CSET/operators/read.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CSET/operators/read.py b/src/CSET/operators/read.py index 26601b2e5..241de9db5 100644 --- a/src/CSET/operators/read.py +++ b/src/CSET/operators/read.py @@ -888,11 +888,12 @@ def _convert_wind_true_dirn_um(cubes: iris.cube.CubeList): Convert from the components relative to the grid to true directions. This functionality only handles the simplest case. """ - u_grid = cubes.extract_cube(iris.AttributeConstraint(STASH="m01s03i225")) - v_grid = cubes.extract_cube(iris.AttributeConstraint(STASH="m01s03i226")) - true_u, true_v = rotate_winds(u_grid, v_grid, iris.coord_systems.GeogCS(6371229.0)) - u_grid.data = true_u.data - v_grid.data = true_v.data + u_grids = cubes.extract(iris.AttributeConstraint(STASH="m01s03i225")) + v_grids = cubes.extract(iris.AttributeConstraint(STASH="m01s03i226")) + for u, v in zip(u_grids, v_grids, strict=True): + true_u, true_v = rotate_winds(u, v, iris.coord_systems.GeogCS(6371229.0)) + u.data = true_u.data + v.data = true_v.data def _normalise_var0_varname(cube: iris.cube.Cube):