尝试使用包裹资料的问题

新手用户在这里。

尝试使用parcel_profile时遇到问题,它不断抛出错误,指出该变量没有与之关联的单元:

回溯(最近通话最近): 文件“ Advanced_Sounding_3Dnetcdf2.py”,第165行,在 prof = mpcalc.parcel_profile(p,T [0],Td [0])。to('degC')

有问题的代码段:

p = phPa * units.hPa
T = TdegC* units.degC
Td = TddegC* units.degC

lcl_pressure,lcl_temperature = mpcalc.lcl(p[0],T[0],Td[0])
skew.plot(lcl_pressure,lcl_temperature,'ko',markerfacecolor='black')

print(p)

prof = mpcalc.parcel_profile(p,Td[0]).to('degC')

当我打印'p'时,它看起来如下:

[<Quantity(965.2435302734375,'hectopascal')>
 <Quantity(959.7489624023438,'hectopascal')>
 <Quantity(954.278564453125,'hectopascal')>
...

数据读取为:

file = 'cm1out_000001.nc'
figname = 'control'
figtime = '1'

f = Dataset(file,'r')

[deleted for brevity]

th = f.variables['th'][0,0:zfl,yfl,xfl] #Read in potential temperature
p0=f.variables['prs0'][0,xfl] #Read in base state pressure
p = f.variables['prs'][0,xfl] #Read in pressure

[deleted for brevity]

phPA = p/100

[deleted for brevity]

p = phPa * units.hPa

这里是否还有其他编码错误?

谢谢。

iCMS 回答:尝试使用包裹资料的问题

netCDF4-python默认为您提供掩码数组,这些数组在Pint的单元支持方面存在一些奇怪的问题。在左边乘以单位应该可以解决此问题:

p = units.hPa * phPa
T = units.degC * TdegC
Td = units.degC * TddegC
本文链接:https://www.f2er.com/2294518.html

大家都在问