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') fig,ax = plt.subplots(1,1,figsize=[10,8]) ax,skew = makeSkewWet(ax,corners=[-15,35]) lcl_temp, lcl_press = find_lcl(A_Td,A_tup.temp,A_tup.press) xplot=convertTempToSkew(A_tup.temp - c.Tc,A_tup.press*pa2hPa,skew) bot=ax.plot(xplot, A_tup.press*pa2hPa-10., 'ko', markersize=14, markerfacecolor='k') ax.text(xplot,A_tup.press*pa2hPa-20.,'A',fontsize=30) pressrange=np.arange(1000,395.,-10.) trop_adiabat=[] for press in pressrange: temp,rv,rl = tinvert_thetae(A_thetae,A_tup.rt,press*1.e2) xtemp = convertTempToSkew(temp - c.Tc,press,skew) trop_adiabat.append(xtemp) ax.plot(trop_adiabat,pressrange,'r-',lw=10) B_press=400.e2 #Pa temp,rv,rl = tinvert_thetae(thetae_trop,A_tup.rt,B_press) rl = 0.2*rl #rain out 80% of liquid B_dict = dict(zip(fields,('B',temp,rv,rl,B_press))) ax.text(trop_adiabat[-1],B_press*pa2hPa,'B',fontsize=30)
#put on the top and bottom LCLs and the thetae sounding Tlcl = np.zeros_like(press) pLCL = np.zeros_like(press) theTheta = np.zeros_like(press) theThetae = np.zeros_like(press) 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)',
# Describe using python pseudocode how you would use these # routines, plus anything else you needed, to find the LCL (hPa) # given the $\theta_e$ and $r_T$ of the mixture at 800 hPa. # ### 3\. A: find the LCL temperature and pressure (cyan dot below) # In[3]: logmix= 0.5*np.log(thetae_900) + 0.5*np.log(thetae_800) thetae_mix=np.exp(logmix) print('50/50 mixture of the logthetas is {} K'.format(n(thetae_mix))) rt_mix = 0.5*rv_900 + 0.5*rv_800 print('50/50 mixture of the rTs is {} g/kg'.format(n(rt_mix*1.e3))) temp_1000,rvap_1000,rl_1000=tinvert_thetae(thetae_mix,rt_mix,1.e5) td_1000 = find_Td(rt_mix,1.e5) Tlcl,plcl = find_lcl(td_1000,temp_1000,1.e5) print('temperature and pressure of LCL (cyan dot) is {} C and {} hPa'.format(n(k2c(Tlcl)),n(plcl*1.e-2))) # # draw this as a cyan circle # xplot=convertTempToSkew(Tlcl - c.Tc,plcl*pa2hPa,skew) bot=ax.plot(xplot, plcl*pa2hPa, 'co', markersize=14, markerfacecolor='c') display(fig) # ### 3\.B program to find LCL of mixture # # Strategy -- The lcl is the pressure where the total mixing ratio $r_T$=$r_v$, the vapor mixing # ratio for the air. So use the rootfinder to zero this difference as a function of pressure, # keeping the thetae and rT of the mixture constant. The catch is that, # everywhere below cloudbase the difference is also zero, so below cloud base we want