Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core _io.concatenate() may fail due to case when one of the cubes is scalar - this fixes that #1715

Merged
merged 3 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions esmvalcore/preprocessor/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def load(file, callback=None, ignore_warnings=None):
------
ValueError
Cubes are empty.

"""
logger.debug("Loading:\n%s", file)
if ignore_warnings is None:
Expand Down Expand Up @@ -501,9 +500,10 @@ def _concatenate_overlapping_cubes(cubes):
data_start_1.month, data_start_1.day,
start_overlap.year, start_overlap.month,
start_overlap.day)
# convert c1_delta scalar cube to vector cube, if needed
if c1_delta.data.shape == ():
c1_delta = iris.util.new_axis(c1_delta, scalar_coord="time")
cubes = iris.cube.CubeList([c1_delta, cubes[1]])
logger.debug("Attempting concatenatenation of %s with %s",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to remove this?

Copy link
Contributor Author

@valeriupredoi valeriupredoi Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not at all, I was being silly - cheers for pointing it out, bud, will reinstate 👍

c1_delta, cubes[1])
try:
cubes = [iris.cube.CubeList(cubes).concatenate_cube()]
except iris.exceptions.ConcatenateError as ex:
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/preprocessor/_io/test_concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
)
from iris.coords import AuxCoord, DimCoord
from iris.cube import Cube, CubeList
from iris.exceptions import ConcatenateError

from esmvalcore.preprocessor import _io

Expand Down Expand Up @@ -375,8 +374,10 @@ def test_concatenate_with_iris_exception(self):
var_name='sample',
dim_coords_and_dims=((time_coord_2, 0), ))
cubes_single_ovlp = [cube2, cube1]
with self.assertRaises(ConcatenateError):
_io.concatenate(cubes_single_ovlp)
cubess = _io.concatenate(cubes_single_ovlp)
# this tests the scalar to vector cube conversion too
time_points = cubess.coord("time").core_points()
np.testing.assert_array_equal(time_points, [1., 1.5, 5., 7.])

def test_concatenate_no_time_coords(self):
"""Test a more generic case."""
Expand Down