Skip to content

Concatenate in load_cube? #2587

@PAGWatson

Description

@PAGWatson

Hello, I got a bit confused when using iris.load_cube to load data from a set of NetCDF files containing data for one variable but in separate decades of a climate model run. This gave an error saying the cubes could not be merged because the time coordinates differ. I realised this is because load_cube attempts a cube merge but not a concatenate. In my view, it would be natural for it to attempt to concatenate the loaded cubes if the merge fails, to deal with data separated into different files for different time periods, which is fairly common i.e. have code like the following at the end of iris.load_cube in place of what is there currently:

try:
    cube = cubes.merge_cube()
except iris.exceptions.MergeError as e:
    try:                                                             #added line
        cube = cubes.concatenate_cube()                              #added line
    except:                                                          #added line
        raise iris.exceptions.ConstraintMismatchError(str(e))
except ValueError:
    raise iris.exceptions.ConstraintMismatchError('no cubes found')

I think this would return a valid cube if cubes can be concatenated and return the same error as is produced currently if they can't. Is there a reason why this couldn't be done?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions