- 积分
- 1461
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-9-12
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2023-6-18 20:23:19
|
显示全部楼层
代码没有显示出来:这是代码部分
新代码:
def Theta_se(T0, RH, P0):
Td = mpcalc.dewpoint_from_relative_humidity(T0, RH)
thera = mpcalc.equivalent_potential_temperature(P0*units('hPa'),T0,Td)
# q = mpcalc.mixing_ratio_from_relative_humidity(P0*units('hPa'), T0,RH)
LCL, lcl_temperature = mpcalc.lcl(P0*units('hPa'),T0, Td)
P0 = P0*100 # units: Pa
T0 = np.array(T0)
Td = np.array(Td)
LCL = np.array(LCL)
tc=T0-273.15
es = np.where(T0>=273.16,6.1078*np.exp(17.2693882*tc/(T0-35.86)),6.1078*np.exp(21.8745584*tc/(T0-7.66)))
q = RH*(0.622*es/(P0-es))/100.0
thse=thera*np.exp(((3376./LCL)-2.54)*q*(1.0+0.81*q))
return thse
之前论坛中提供的参考python程序:
def Theta_se(Rh,t,p,nx,ny):
nx,ny = len(nx),len(ny)
#计算假相当位温
#Rh:相对湿度(%)|t:温度(K)|p:气压值(hPa)|nx:经向格点数|ny:纬向格点数
t0 = 273.16
e0 = 6.1078
L0 = 2500.79
cl = 2.3697
cpd = 1.0048
Rd = 0.28704
Rw = 0.4615
#11个变量统一初始化成11个(ny,nx)二维数组
cttd,Ftd,tc,Lc,thetad,wc,thetase,Ltd,ttd,lew,ee = np.ones((11,ny,nx))
lew = 6.112*(np.e**((17.67*t)/(t+243.5)))
ee = ((lew*Rh)/100)/6.112
ttd = (243.5*(np.log(ee)))/(17.67-np.log(ee))
Ltd = L0-cl*(ttd-t0)
cttd = e0*((t0/ttd)**(cl/Rw))*(np.e**((L0+cl*t0)*(ttd-t0)/(Rw*ttd*t0)))
Ftd = (0.622*Ltd/(cpd*ttd))-1
tc = ttd*Ftd/(Ftd+np.log(ttd/t))
Lc = L0-cl*(tc-t0)
thetad = t*((1000.0/(p-cttd))**(Rd/cpd))
wc = 0.622*cttd/(p-cttd)
thetase = thetad*(np.e**(wc*Lc/(cpd*tc)))
thetase=thetase
return thetase
|
|