iris icon indicating copy to clipboard operation
iris copied to clipboard

Concatenate in load_cube?

Open PAGWatson opened this issue 7 years ago • 4 comments

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?

PAGWatson avatar May 30 '17 09:05 PAGWatson

I've just come across the same issue. Each of my NetCDF files contain one month of daily data. They won't load into a single cube but the cubes for each month will concatenate fine after loading.

So I just want to add a +1 to @PAGWatson's suggestion.

rcomer avatar Jul 04 '17 10:07 rcomer

As it stands, the proposed implementation would be sub-optimal performance wise, but at least it would be better than getting an error all the time...

In the long term, we'd like to unify the merge and concatenate codebase (in fact, I think we are quite a long way down that road already).

pelson avatar Jan 03 '18 20:01 pelson

@davidSextonWork: fancy taking this on?

trexfeathers avatar Jun 09 '21 09:06 trexfeathers

In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.

If this issue is still important to you, then please comment on this issue and the stale label will be removed.

Otherwise this issue will be automatically closed in 28 days time.

github-actions[bot] avatar Jan 29 '24 00:01 github-actions[bot]

This stale issue has been automatically closed due to a lack of community activity.

If you still care about this issue, then please either:

  • Re-open this issue, if you have sufficient permissions, or
  • Add a comment stating that this is still relevant and someone will re-open it on your behalf.

github-actions[bot] avatar Feb 26 '24 00:02 github-actions[bot]