【发布时间】:2015-02-03 00:23:22
【问题描述】:
我是 Iris 库的新手,需要计算 heat index,它是温度和相对湿度的多元非线性函数,类似于 $HI = temp +rh + temp*rh + temp^ 2 *rh + rh^2*temp $ 。这里,temp 的单位是华氏度,rh 的单位是 1。
但是,虹膜立方体不会添加不同的单位:
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
如果我将数据调用为 numpy 数组,那么这是一种解决方法,例如: heatIndex = -42.379 + temp.data + rh.data + temp.data2 + rh.data2 但这似乎违背了最初使用 Iris 的目的,并且需要重新编写元数据。
这可能与虹膜立方体有关吗?是否有我缺少的无单位 udunit 允许这种情况发生?
注意:如果从错误中不清楚,我正在运行 Python 2.7(和 Iris 1.7)。
【问题讨论】:
标签: python python-2.7 python-iris