The order in which a mathematical operation is applied on a 'iris.coords.AuxCoord' and 'iris.cube.Cube' makes a difference, i.e.
iris.cube.Cube / iris.coords.AuxCoord works fine whereas iris.coords.AuxCoord / iris.cube.Cube returns the error as:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sarah/anaconda3/envs/iris/lib/python3.8/site-packages/iris/coords.py", line 464, in __truediv__
return self.__binary_operator__(other, self._MODE_DIV)
File "/home/sarah/anaconda3/envs/iris/lib/python3.8/site-packages/iris/coords.py", line 425, in __binary_operator__
raise iris.exceptions.NotYetImplementedError(emsg)
iris.exceptions.NotYetImplementedError: Coord / AuxCoord
A workaround to avoid the error is that the user takes care of the order of "Cubes" and "Auxcoords". However, this can cause a problem in complicated equations including several terms.
Steps to reproduce the behaviour:
An alternative workaround would be to define p0 as a scalar cube:
p0 = iris.cube.Cube(1000.0, long_name='reference_pressure', units='hPa')
p0 / pressure
this has only worked since Iris 3.0.
If I keep p0 as an AuxCoord, I also get an error for p0 / pressure under Iris 2.4, so I'm curious about which Iris version ESMValTool used before.
Ah, I see Coord + Cube and Coord * Cube _did_ work at Iris 2.4, and those seem to be the cases you are addressing at https://github.com/ESMValGroup/ESMValTool/pull/2023.
@bjlittle almost completely rewrote arithmetic for Iris 3.0 (making it better in all sorts of ways) so he'll know how easy it would be to reinstate that functionality.
@SarahAlidoost Apologies for the delay in getting back to you... and thanks for taking the time to raise your very first iris issue :smile:
Okay, so you've given me everything I need to replicate this issue and investigate further. So leave it with me and I'll take it from here. I'll get back as soon as possible once I've figured out a way forward and a plan of action.
Thanks again :+1:
Hey @SarahAlidoost,
Just to let you know that I can easily recreate this issue on Iris master and the release feature branch v3.0.x.
We're going to make an Iris v3.0.2 patch release which will include the fix for this issue... it will also pull in at least one other bugfix in the patch release, which is another free win for the community :partying_face:
You can track our progress with the v3.0.2 release on this Iris GitHub project... but I'll also update you here.
I don't have an ETA of when v3.0.2 will be available, but I'm keen to resolve this ASAP. When tentative release dates do start to form, again I'll let you know here :+1:
Hey @SarahAlidoost,
Just to let you know that I can easily recreate this issue on Iris
masterand the release feature branchv3.0.x.We're going to make an Iris
v3.0.2patch release which will include the fix for this issue... it will also pull in at least one other bugfix in the patch release, which is another free win for the communityYou can track our progress with the
v3.0.2release on this Iris GitHub project... but I'll also update you here.I don't have an ETA of when
v3.0.2will be available, but I'm keen to resolve this ASAP. When tentative release dates do start to form, again I'll let you know here
thanks a lot for the explanations and update. Looking forward to v3.0.2 release :+1:
Most helpful comment
@SarahAlidoost Apologies for the delay in getting back to you... and thanks for taking the time to raise your very first
irisissue :smile:Okay, so you've given me everything I need to replicate this issue and investigate further. So leave it with me and I'll take it from here. I'll get back as soon as possible once I've figured out a way forward and a plan of action.
Thanks again :+1: