我创建了一组等压压力水平来绘制横截面:
vertical, = cross['isobaric'].metpy.coordinates('vertical')
但是,该数组的值以 Pa 为单位。为了转换为 hPa,我创建了一个新数组:
vert_hpa = (vertical/100)*units.hPa
然后我想用它来计算潜在的温度:
temperature, pressure, relative_humidity = xr.broadcast(cross['temperature'], vert_hpa, cross['relative_humidity'])
theta = mpcalc.potential_temperature(pressure, temperature)
当我尝试运行它时,我收到一个错误,表明我创建并分配给变量“压力”的数组没有任何关联的单位:
ValueError: `potential_temperature` given arguments with incorrect units: `pressure` requires "[pressure]" but given "dimensionless".
MetPy 单位文档建议可以使用语法 array_name*units.unit将单位添加到数组中。为什么我尝试这样做没有成功?