@cpelley how about this slight refactor ...
```
import iris.coords
...
if scalar_coord == coord:
    # Ensure the scalar coordinate is a dimension coordinate.
    dim_coord = iris.coords.DimCoord.from_coord(coord)
    new_cube.add_dim_coord(dim_coord, 0)
else:
    coord_dims = np.array(src_cube.coord_dims(coord)) + 1
    new_cube.add_aux_coord(coord, coord_dims)
```