Example #1
0
def therm_calc(the_row):
    rT = cloud_vars['wt']
    S = the_row[-1]
    temp, press,height = the_row[-4:-1]
    esat = find_esat(temp)
    e = S*esat
    rv = c.eps*e/(press - e)  #Thompkins eqn 2.20
    Td = find_Td(rv,press)
    thetae = find_thetaet(Td,rT,temp,press)
    hm = c.cpd*temp + find_lv(temp)*rv + c.g0*height
    return (thetae, hm)
Example #2
0
def lift_sounding(rTotal,theThetae,press,):
  #
  # return temp,dewpoint and Tspeudo soundings for an rT,thetae sounding at pressure levels press
  #
  numPoints, = press.shape
  for i in range(0, numPoints):
    #find the actual temperature and dewpoint
    Temp[i], rv, rl = tinvert_thetae(theThetae[i], rTotal[i], press[i] * hPa2pa)
    Tdew[i] = find_Td(rv, press[i] * hPa2pa)
    Tpseudo[i] = find_Tmoist(theThetae[i], press[i] * hPa2pa)
  return Tdew,Temp,Tpseudo
Example #3
0
bot_z = 0
# bot_z = np.searchsorted(z,500.)

end_z = np.searchsorted(z, 1200.0)
bot_z = np.searchsorted(z, 1000.0)


qv_sound = qv.mean(axis=(1, 2))[bot_z:end_z] * 1.0e-3  # kg/kg
temp_sound = temp.mean(axis=(1, 2))[bot_z:end_z]
press_sound = np.squeeze(press)[bot_z:end_z]
z_sound = z[bot_z:end_z]
# print(qv_sound.shape,temp_sound.shape,z_sound.shape,press_sound.shape)
thetal_sound = [
    find_thetal(the_press, the_temp, the_qv) for the_press, the_temp, the_qv in zip(press_sound, temp_sound, qv_sound)
]
Td_sound = find_Td(qv_sound, press_sound)
thetae_sound = [
    find_thetaet(the_Td, the_qv, the_temp, the_press)
    for the_Td, the_press, the_temp, the_qv in zip(Td_sound, press_sound, temp_sound, qv_sound)
]
fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize=(16, 8))
ax1.plot(qv_sound * 1.0e3, z_sound)
ax2.plot(temp_sound, press_sound * 1.0e-2)
ax3.plot(thetal_sound, press_sound * 1.0e-2)
ax4.plot(thetae_sound, press_sound * 1.0e-2)
axes = [ax2, ax3, ax4]
[ax.invert_yaxis() for ax in axes]
p0 = press_sound[0] * 1.0e-2
[ax.set(ylim=(p0, 750)) for ax in axes]
axes = [ax1, ax2, ax3, ax4]
ax1.set(ylabel="heigth (m)")
Example #4
0
    rt:  {rt:6.3g} kg/kg
    enthalpy: {enthalpy: 8.3g}  J/kg
    """
    return the_string.format_map(the_tup._asdict())
    
   
get_ipython().magic('matplotlib inline')
pa2hPa = 1.e-2

A_press = 1.e5  #Pa
B_press = 4.e4  #Pa
A_temp = 300  #K
RH = 0.8
e = find_esat(A_temp)*RH
A_rv = c.eps*e/(A_press - e)
A_Td = find_Td(A_rv,A_press)
print('tropical surface dewpoint: {} K'.format(A_Td))
A_thetae=find_thetaet(A_Td,A_rv,A_temp,A_press)
print('tropical surface thetae: {} K'.format(A_thetae))
A_temp,A_rv,A_rl = tinvert_thetae(A_thetae,A_rv,A_press)
fields=['id','temp','rv','rl','press']
A_dict = dict(zip(fields,('A',A_temp,A_rv,A_rl,A_press)))
A_tup = calc_enthalpy(A_dict)
print(format_tup(A_tup))


# ### B. Lift to 400 hPa and remove 80% of the liquied water

# In[201]:

plt.close('all')
Example #5
0
#
# set the lcl for 900 hPa to 860 hPa and thetae to 338 K
#
press=860.e2
thetae_900=338.  #K
Temp_860=find_Tmoist(thetae_900,press)
rv_860=find_rsat(Temp_860,press)
rv_900 = rv_860  #vapor is conserved
Tdew_860=Temp_860
print("temp,Tdew,rv at LCL press:  {} hPa {} C {} C {} kg/kg"      .format(n(press*1.e-2),e(k2c(Temp_860)),e(k2c(Tdew_860)),e(rv_900)))
#
# now descend adiabatically to 900 hPa
#
press=900.e2
Temp_900,rv_900,rl_900=tinvert_thetae(thetae_900,rv_900,press)
Tdew_900=find_Td(rv_900,press)
print("temperature and dewpoint at {} hPa hPa = {} C {} C".format(n(press*1.e-2),e(k2c(Temp_900)), e(k2c(Tdew_900))))
#
#  draw these on the sounding at 900 hPa as a red circle and blue diamond
#
xplot=convertTempToSkew(Temp_900 - c.Tc,press*pa2hPa,skew)
bot=ax.plot(xplot, press*pa2hPa, 'ro', markersize=14, markerfacecolor='r')
xplot=convertTempToSkew(Tdew_900 - c.Tc,press*pa2hPa,skew)
bot=ax.plot(xplot, press*pa2hPa, 'bd', markersize=14, markerfacecolor='b')
#
#now look at an LCL of 700 hPa  -- with thetae = 332 K
#
press=700.e2
thetae_800=332.  #K
Temp_700=find_Tmoist(thetae_800,press)
Tdew_700 = Temp_700