I'm new to the Iris library and need to compute a heat index, which is a multivariate non-linear function of temperature and relative humidity that goes something like $HI = temp +rh + temp*rh + temp^2 *rh + rh^2*temp $ . Here, temp has units of Fahrenheit and rh has units of 1.
However, Iris cubes won't add differing units:
In [147]: HI = temp + rh + temp*rh + temp**2*rh + rh**2*temp
---------------------------------------------------------------------------
NotYetImplementedError Traceback (most recent call last)
<ipython-input-147-675ea72a5d06> in <module>()
----> 1 HI = temp + rh + temp*rh + temp**2*rh + rh**2*temp
/Users/me/anaconda/lib/python2.7/site-packages/iris/cube.pyc in __add__(self, other)
2596
2597 def __add__(self, other):
-> 2598 return iris.analysis.maths.add(self, other, ignore=True)
2599 __radd__ = __add__
2600
/Users/me/anaconda/lib/python2.7/site-packages/iris/analysis/maths.pyc in add(cube, other, dim, ignore, in_place)
166 op = operator.iadd if in_place else operator.add
167 return _add_subtract_common(op, 'addition', 'added', cube, other, dim=dim,
--> 168 ignore=ignore, in_place=in_place)
169
170
/Users/me/anaconda/lib/python2.7/site-packages/iris/analysis/maths.pyc in _add_subtract_common(operation_function, operation_noun, operation_past_tense, cube, other, dim, ignore, in_place)
216 """
217 _assert_is_cube(cube)
--> 218 _assert_matching_units(cube, other, operation_noun)
219
220 if isinstance(other, iris.cube.Cube):
/Users/me/anaconda/lib/python2.7/site-packages/iris/analysis/maths.pyc in _assert_matching_units(cube, other, operation_noun)
132 raise iris.exceptions.NotYetImplementedError(
133 'Differing units (%s & %s) %s not implemented' %
--> 134 (cube.units, other.units, operation_noun))
135
136
NotYetImplementedError: Differing units (Fahrenheit & 1) addition not implemented
If I call the data instead as a numpy array then this is a workaround, e.g.: heatIndex = -42.379 + temp.data + rh.data + temp.data2 + rh.data2 but this seems to defeat the purpose of using Iris in the first place, and requires re-writing the meta-data.
Is this possible to do with iris cubes? Is there a unit-less udunit that I'm missing that would allow this to happen?
NB: if it wasn't clear from the error, I'm running Python 2.7 (and Iris 1.7).