iris.exceptions.NotYetImplementedError: Coord AuxCoord

Created on 12 Feb 2021  路  5Comments  路  Source: SciTools/iris

馃悰 Bug Report

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.

How To Reproduce

Steps to reproduce the behaviour:

  1. please see cube math documentation, section Combining Multiple Phenomena to Form a New One.
  2. first, load the pressure cube as it is explained.
  3. then, define P0 as it is explained.
  4. calculate the new pressure using the equation (pressure / p0): this works fine.
  5. now make a different equation by changing the order i.e. (p0 / pressure): this returns the error, mentioned above.
  6. replace the operator " / " with any operators of " + ", " - ", or " * " and repeat steps 3 and 4: the same things happen.

Environment

  • OS & Version: Ubuntu 20.04 LTS
  • Iris Version: 3.0.1
  • environment file is attached iris.txt.
Arithmetic ESMValTool Issue Bug

Most helpful comment

@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:

All 5 comments

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 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

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

thanks a lot for the explanations and update. Looking forward to v3.0.2 release :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rcomer picture rcomer  路  3Comments

cpelley picture cpelley  路  3Comments

pelson picture pelson  路  4Comments

BenMGeo picture BenMGeo  路  4Comments

nhsavage picture nhsavage  路  5Comments