尝试使用包裹配置文件时出现问题
issue trying to use parcel profile
这里是新手。
我在尝试使用 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, T[0], 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,0:zfl,yfl,xfl] #Read in base state pressure
p = f.variables['prs'][0,0:zfl,yfl,xfl] #Read in pressure
[deleted for brevity]
phPA = p/100
[deleted for brevity]
p = phPa * units.hPa
我这里还有编码错误还是其他地方不对?
谢谢。
netCDF4-python 默认情况下为您提供屏蔽数组,这些数组在 Pint 的单位支持方面存在一些奇怪的问题。在左边乘以单位应该可以解决这个问题:
p = units.hPa * phPa
T = units.degC * TdegC
Td = units.degC * TddegC
这里是新手。
我在尝试使用 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, T[0], 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,0:zfl,yfl,xfl] #Read in base state pressure
p = f.variables['prs'][0,0:zfl,yfl,xfl] #Read in pressure
[deleted for brevity]
phPA = p/100
[deleted for brevity]
p = phPa * units.hPa
我这里还有编码错误还是其他地方不对?
谢谢。
netCDF4-python 默认情况下为您提供屏蔽数组,这些数组在 Pint 的单位支持方面存在一些奇怪的问题。在左边乘以单位应该可以解决这个问题:
p = units.hPa * phPa
T = units.degC * TdegC
Td = units.degC * TddegC