Improving error messages in concatenate and merge

29 views
Skip to first unread message

Joshua Dorrington

unread,
May 29, 2019, 7:41:25 AM5/29/19
to Iris-dev
Hi,

I'm wondering if there are any plans to increase the amount of information returned by the error messages for concatenate, concatenate_cube, merge and merge_cube?
As a user I feel I spend a disproportionate amount of time trying to understand why cubes are incompatible with each other, often receiving only the slightly frustrating message:

ConcatenateError: failed to concatenate into a single cube.
  An unexpected problem prevented concatenation.
  Expected only a single cube, found 2.

I have resorted to filling my scripts with functions of the following type to try and find the cause of errors:


def check_cubes_concatenate(F0,F1):
   
   
assert F0.dtype==F1.dtype
   
assert F0.units==F1.units
   
assert F0.metadata==F1.metadata
   
assert F0.attributes==F1.attributes
   
   
for coord1,coord2 in zip(F0.coords(),F1.coords()):
       
assert coord1.standard_name==coord2.standard_name
       
assert coord1.var_name==coord2.var_name
       
assert coord1.long_name==coord2.long_name
       
assert coord1.dtype==coord2.dtype
       
assert coord1.units==coord2.units
       
assert coord1.attributes==coord2.attributes
       
assert coord1.has_bounds()==coord2.has_bounds()
       
if coord1.has_bounds():
           
assert coord1.bounds.dtype==coord2.bounds.dtype
       
assert coord1.is_compatible(coord2)  
     
   
#There should be one and only one concatenatable coordinate
    concat_coords
=0
   
for coord1,coord2 in zip(F0.dim_coords,F1.dim_coords):
       
assert coord1.circular==coord2.circular
        overlap
=np.isin(coord1.points,coord2.points).any()
        same
=np.isin(coord1.points,coord2.points).all()
       
if not (overlap or same):
            concat_coords
+=1
   
assert concat_coords==1
       
   
return True

I know that many users have this same frustration, and I am wondering whether there is a technical difficulty to improving the quality of the error messages that I am not appreciating? If it is simply an issue of someone getting round to doing it, I would be willing to work on doing so. 

RuthC

unread,
May 29, 2019, 10:29:08 AM5/29/19
to Iris-dev
Hi Joshua,

there are some related issues on the GitHub tracker, so the issue is understood:

From the first link, it seems there is not a simple fix, but there is a desire to improve the situation.  Others may be able to give details regarding any progress.

Ruth

Joshua Dorrington

unread,
May 31, 2019, 4:41:20 AM5/31/19
to Iris-dev
Hi Ruth,

I think these are two slightly different issues right? One is the complexity of having separate merge and concatenate functions, which I can see is not an easy thing to fix, while the other is the lack of informative error messages.
Presumably iris knows somewhere internally why it doesn't want to merge some cubes, and it would be good to share that information with the user.
Josh
Reply all
Reply to author
Forward
0 new messages