diff --git a/src/CSET/operators/read.py b/src/CSET/operators/read.py index e4b7ce487..b9f6e9a74 100644 --- a/src/CSET/operators/read.py +++ b/src/CSET/operators/read.py @@ -94,8 +94,7 @@ def read_cubes( """Read cubes from files. Read operator that takes a path string (can include wildcards), and uses - iris to load_cube all the cubes matching the constraint and return a - CubeList object. + iris to load the minimal set of cubes matching the constraint. If the loaded data is split across multiple files, a filename_pattern can be specified to select the read files using Unix shell-style wildcards. In this @@ -124,7 +123,7 @@ def read_cubes( Returns ------- cubes: iris.cube.CubeList - Cubes loaded + Cubes loaded after being merged and concatenated. Raises ------ @@ -141,8 +140,9 @@ def read_cubes( callback = _create_callback(is_ensemble=True) cubes = iris.load(input_files, constraint, callback=callback) - # Merge cubes now metadata has been fixed. - cubes.merge() + # Merge and concatenate cubes now metadata has been fixed. + cubes = cubes.merge() + cubes = cubes.concatenate() logging.debug("Loaded cubes: %s", cubes) if len(cubes) == 0: diff --git a/tests/operators/test_read.py b/tests/operators/test_read.py index 8c38e83fe..8ad284451 100644 --- a/tests/operators/test_read.py +++ b/tests/operators/test_read.py @@ -92,6 +92,12 @@ def test_read_cube_unconstrained(): read.read_cube("tests/test_data/air_temp.nc") +def test_read_cube_merge_concatenate(): + """Cubes are combined after callbacks have been applied.""" + cube = read.read_cube("tests/test_data/concat_after_fix_[12].nc") + assert isinstance(cube, iris.cube.Cube) + + def test_check_input_files_direct_path(tmp_path): """Get a iterable of a single file from a direct path.""" file_path = tmp_path / "file" diff --git a/tests/test_data/concat_after_fix_1.nc b/tests/test_data/concat_after_fix_1.nc new file mode 100644 index 000000000..d80d00c20 Binary files /dev/null and b/tests/test_data/concat_after_fix_1.nc differ diff --git a/tests/test_data/concat_after_fix_2.nc b/tests/test_data/concat_after_fix_2.nc new file mode 100644 index 000000000..ee5da58c3 Binary files /dev/null and b/tests/test_data/concat_after_fix_2.nc differ