Beispiel #1
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
Beispiel #2
0
def calcBuoy(height, thetae0, interpTenv, interpTdEnv, interpPress):
    """function to calculate buoyant acceleration for an ascending saturated parcel
       this version neglects liquid water loading
    
    Parameters
    ----------
    
    height: float
            parcel height (m)
    thetae0: float
            parcel thetae (K)

    interpTenv: func
                interp1d function for environmental temperature T(z) 
    interpTdEnv: func
                interp1d function for environmental dewpoint temperature Td(z)
    interpPress: func
                interp1d function for presusure  p(z)

    Returns
    -------

    buoy: float
          buoyancy (m/s/s)
    """
    #input: height (m), thetae0 (K), plus function handles for
    #T,Td, press soundings
    #output: Bout = buoyant acceleration in m/s^2
    #neglect liquid water loading in the virtual temperature
    
    press=interpPress(height)*100.#%Pa
    Tcloud=find_Tmoist(thetae0,press) #K
    rvcloud=find_rsat(Tcloud,press); #kg/kg
    Tvcloud=Tcloud*(1. + c.eps*rvcloud)
    Tenv=interpTenv(height) + c.Tc
    Tdenv=interpTdEnv(height) + c.Tc
    rvenv=find_rsat(Tdenv,press); #kg/kg
    Tvenv=Tenv*(1. + c.eps*rvenv)
    TvDiff=Tvcloud - Tvenv
    buoy = c.g0*(TvDiff/Tvenv)
    return buoy
Beispiel #3
0
sfc_press,sfc_temp,sfc_td = sfc_press*100.,sfc_temp+c.Tc,sfc_td+c.Tc
sfc_rvap = find_rsat(sfc_temp,sfc_press)
sfc_thetae=find_thetaep(sfc_td,sfc_temp,sfc_press)
press=sounding['pres'].values*100.
#
# find the index for 200 hPa pressure -- searchsorted requires
# the pressure array to be increasing, so flip it for the search,
# then flip the index.  Above 200 hPa thetae goes bananas, so
# so trim so we only have 
#
toplim=len(press) - np.searchsorted(press[::-1],2.e4)
press=press[:toplim]
#
# find temps along that adiabat
#
adia_temps= np.array([find_Tmoist(sfc_thetae,the_press) for the_press in press])
adia_rvaps = find_rsat(adia_temps,press)
adia_rls = sfc_rvap - adia_rvaps
env_temps = (sounding['temp'].values + c.Tc)[:toplim]
env_Td = (sounding['dwpt'].values + c.Tc)[:toplim]
height = sounding['hght'].values[:toplim]
pairs = zip(env_Td,press)
env_rvaps= np.array([find_rsat(td,the_press) for td,the_press in pairs])
env_Tv = find_Tv(env_temps,env_rvaps)
adia_Tv = find_Tv(adia_temps,adia_rvaps,adia_rls)
xcoord_thetae=[]
press_hPa = press*1.e-2
for a_temp,a_press in zip(adia_temps - c.Tc,press_hPa):
    out=convertTempToSkew(a_temp,a_press,skew)
    xcoord_thetae.append(out)
ax.plot(xcoord_thetae,press_hPa,color='r',label='rsat',linewidth=3.)
Beispiel #4
0
  Tpseudo = np.zeros_like(press)
  rTotal = np.zeros_like(press)

  #
  # calculate the rTotal,thetae sounding from the original dewpoint and temperture
  #

  numPoints, = press.shape
  for i in range(0, numPoints):
      rTotal[i] = find_rsat(Tdew[i] + c.Tc, press[i] * hPa2pa)
      Tlcl[i], pLCL[i] = find_lcl(Tdew[i] + c.Tc, Temp[i] + c.Tc,
                                  press[i] * hPa2pa)
      theThetae[i] = find_thetaep(Tdew[i] + c.Tc, Temp[i] + c.Tc,
                                  press[i] * hPa2pa)
      #find the temperature along the pseudo adiabat at press[i]
      Tpseudo[i] = find_Tmoist(theThetae[i], press[i] * hPa2pa)


  #
  # given the total water and thetae, calcultate temp,dewpoint for pressure vector press
  #
  Tdew, Temp, Tpseudo = lift_sounding(rTotal,theThetae,press)

  fig, ax = plt.subplots(1, 1, figsize=(10, 10))
  ax, skew = makeSkewWet(ax,corners=[5,25])

  fig_dict=dict(press=press,Tpseudo=Tpseudo,Temp=Temp,Tdew=Tdew,Tlcl=Tlcl,pLCL=pLCL,botLabel='LCL bot (835 hPa)',
                topLabel='LCL top (768 hPa)')
  ax = makePlot(ax,**fig_dict)   

  fig.savefig('base900_thetae.png')
Beispiel #5
0
pa2hPa=1.e-2
from importlib import reload
import a405skewT.makeSkewII
reload(a405skewT.makeSkewII)
from a405skewT.makeSkewII import makeSkewWet
fig, ax = plt.subplots(1, 1, figsize=(12, 8))
ax, skew = makeSkewWet(ax,corners=[10,30])
ax.set(ylim=[1000,700])
from a405thermo.thermlib import find_Tmoist,find_rsat,find_Td,tinvert_thetae,convertTempToSkew,              find_lcl
import a405thermo.thermlib as tl
#
# 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)
Beispiel #6
0
from a405skewT.makeSkewII import makeSkewWet,find_corners
plt.close('all')
fig,ax =plt.subplots(1,1,figsize=(8,8))
corners=[-15,35]
ax,skew = makeSkewWet(ax,corners=corners,skew=skew)
ax.plot(xcoord_T,sounding['pres'],color='k',label='temp')
ax.plot(xcoord_Td,sounding['pres'],color='g',label='dew')
ax.set(ylim=[1000,190])
[line.set(linewidth=3) for line in ax.lines[-2:]]
out=ax.set(title=title)


# In[9]:

from a405thermo.thermlib import find_Tmoist
thetae=335.
temps= np.array([find_Tmoist(thetae,press*100.) for press in sounding['pres']])
temps = temps - c.Tc
xcoord_thetae=[]
for a_temp,a_press in zip(temps,sounding['pres']):
    out=convertTempToSkew(a_temp,a_press,skew)
    xcoord_thetae.append(out)
ax.plot(xcoord_thetae,sounding['pres'],color='r',label='rsat',linewidth=3.)
display(fig)                                   


# In[ ]: