- Timestamp:
- Sep 20, 2018, 4:47:43 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r2127 r2151 8999 8999 return 9000 9000 9001 #filen='/home/lluis/estudios/ChemGBsAs/tests/199807/obs/snd/UWyoming_snd_87576.nc' 9002 #values='time|0:auto:auto:Sounding!at!Ezeiza!airport!on!3rd!July!1998:png:yes' 9003 #varn='ta,tda,pres' 9004 #draw_SkewT(filen, values, varn) 9001 filen='/home/lluis/estudios/ChemGBsAs/tests/199807/obs/snd/UWyoming_snd_87576.nc' 9002 values='time|0:auto:auto:Sounding!at!Ezeiza!airport!on!3rd!July!1998:png:yes' 9003 varn='ta,tda,pres' 9004 draw_SkewT(filen, values, varn) 9005 9005 9006 9006 9007 def draw_multi_SkewT(ncfiles, values): -
trunk/tools/drawing_tools.py
r2119 r2151 11697 11697 return 11698 11698 11699 def SaturationPressure(temp):11699 def es(temp): 11700 11700 """ Provides de saturation pressure [hPa] at a given temperature following The 11701 11701 August-Roche-Magnus equation … … 11704 11704 23.334406231 11705 11705 """ 11706 fname = ' SaturationPressure'11706 fname = 'es' 11707 11707 11708 11708 ARM1 = 6.1094 # hPa … … 11711 11711 11712 11712 tempC = temp - 273.15 11713 satpres= ARM1*exp(ARM2*tempC/(tempC+ARM3))11714 11715 return satpres11713 esv = ARM1*exp(ARM2*tempC/(tempC+ARM3)) 11714 11715 return esv 11716 11716 11717 11717 #print 'satpres:', SaturationPressure(293.15) 11718 11718 11719 def SatMixingRatio(ta,pres):11719 def qs(ta,pres): 11720 11720 """ Provides de saturation mixing ratio [kgkg-1] 11721 11721 ta: temperature [K] … … 11724 11724 0.014531424608 11725 11725 """ 11726 fname = 'SatMixingRatio' 11727 11728 es = SaturationPressure(ta) 11729 rs = (0.6222*es)/(0.01*pres-es) 11730 11731 return rs 11732 11733 #print 'saturation mixing ratio:', SatMixingRatio(293.,101300.) 11726 fname = 'qs' 11727 11728 esv = es(ta) 11729 qsv = (0.6222*es)/(0.01*pres-es) 11730 11731 return qsv 11732 11733 #for t in range(260,310): 11734 # print t, 'qs:', SatMixingRatio(t*1.,101300.) 11735 #quit() 11736 11737 def e(ta, pres): 11738 """ Function to compute water vapour pressure [hPa] 11739 ta: air temperature [K] 11740 pres: pressure [Pa] 11741 """ 11742 fname = 'e' 11743 tk = ta 11744 data1 = 10.*0.6112*np.exp(17.67*(tk-273.16)/(tk-29.65)) 11745 ev = 0.622*data1/(0.01*pres-(1.-0.622)*data1) 11746 11747 return ev 11748 11749 def hur(ta, pres, hus): 11750 """ Function to compute relative humidtiy [1] 11751 ta: air temperature [K] 11752 pres: pressure [Pa] 11753 hus: water vapor mixing ratio [kgkg-1] 11754 """ 11755 fname = 'hur' 11756 11757 ev = e(ta,pres) 11758 hurv = hus/ev 11759 11760 return hurv 11761 11762 def td(ta,pres,hus): 11763 """ Function to compute dew-point temperature [C] 11764 ta: air temperature [K] 11765 pres: pressure [Pa] 11766 hus: water vapor mixing ratio [kgkg-1] 11767 """ 11768 fname = 'td' 11769 11770 hurv = hur(ta,pres,hus) 11771 esv = es(ta) 11772 11773 pa = hurv*esv 11774 tdv = 257.44*np.log(pa/6.1121)/(18.678-np.log(pa/6.1121)) 11775 11776 return tdv 11777 11778 def tl(ta, pres, hus): 11779 """ Temperature at the Lifted condensation Level [C] 11780 ta: air temperature [K] 11781 pres: pressure [Pa] 11782 hus: water vapor mixing ratio [kgkg-1] 11783 """ 11784 fname = 'tl' 11785 11786 tdv = td(ta, pres, hus) 11787 11788 tC= ta- 273.15 11789 11790 frac = 1./(tdv-56.) + np.log(tC/tdv)/800. 11791 11792 tlv = 1./frac + 56. 11793 11794 return tlv 11795 11796 def equivpot(ta, pres, hus): 11797 """ Equivalent potenatial temperature as in WikiPedia 11798 https://en.wikipedia.org/wiki/Equivalent_potential_temperature 11799 ta: temperature of the air [K] 11800 pres: pressure of the air [Pa] 11801 hus: mixing ratio of the air [kgkg-1] 11802 """ 11803 fname = 'equivpot' 11804 11805 ev = e(ta, pres) 11806 tlv = tl(ta,pres,hus) + 273.15 11807 11808 # Dry potential temperature at LCL 11809 thetal_1 = ta*(pres-ev)**0.2854 11810 thetal_2 = (ta/tlv)**(0.28*hus) 11811 thetal = thetal_1*thetal_2 11812 11813 ethetav_exp = (3036./tlv-1.78)*hus*(1.+0.448*hus) 11814 ethetav = thetal*np.exp(ethetav_exp) 11815 11816 return ethetav 11817 11818 print equivpot(300., 98000., 0.02) 11819 quit() 11734 11820 11735 11821 def ethetapotct(tsfc, dz=50, pmin=5000.): … … 11758 11844 dp = (psfc-pmin)/(dz-1) 11759 11845 11760 ws = SatMixingRatio(tsfc+273.15,psfc)11846 wsv = ws(tsfc+273.15,psfc) 11761 11847 thetasfc = (tsfc+273.15)*(psfc/p0)**(R/Cp) 11762 11848 for iz in range(dz): 11763 11849 ethetapotv[iz,0] = psfc-dp*iz 11764 thetapotv = (tsfc+273.15)*((psfc-dp*iz)/p0)**(R/Cp) 11765 tfromthetasfc = thetasfc*(p0/(psfc-dp*iz))**(-R/Cp) 11766 wstfromthetasfc = SatMixingRatio(tfromthetasfc,psfc-dp*iz) 11767 #ethetapotv[iz,1] = thetapotv*np.exp(L*1000.*ws/(Cp*(tsfc+273.15))) -273.15 11768 ethetapotsfcv = thetapotv*np.exp(L*1000.*wstfromthetasfc/(Cp*(tsfc+273.15))) -273.15 11769 ethetapotv[iz,1] = ethetapotsfcv 11770 print iz,psfc-dp*iz,thetapotv-273.15,tfromthetasfc-273.15,':',ethetapotv[iz,1],wstfromthetasfc,ethetapotsfcv 11850 thetav = (tsfc+273.15)*((psfc-dp*iz)/p0)**(R/Cp) 11851 temp = thetav*(p0/(psfc-dp*iz))**(-R/Cp) 11852 wsv = ws(temp,psfc-dp*iz) 11853 ethetapotval = thetav*np.exp(L*1000.*wsv/(Cp*(tsfc+273.15)))-273.15 11854 ethetapotv[iz,1] = ethetapotval 11855 print iz,psfc-dp*iz,thetav-273.15,temp-273.15,':',ethetapotv[iz,1],ws 11771 11856 11772 11857 print thetasfc,ws 11773 #quit()11858 quit() 11774 11859 return ethetapotv 11775 11860 … … 11809 11894 """ 11810 11895 import skewt 11896 11897 lbck = 1. 11811 11898 11812 11899 fname = 'plot_SkewT' … … 11832 11919 ax = fig.add_subplot(111, projection='skewx') 11833 11920 11834 plt.grid(True )11921 plt.grid(True, linewidth=lbck) 11835 11922 11836 11923 # Quantity of dryadiabats 11837 xmax = taxtrm[1]11924 xmax = 150. 11838 11925 xmin = taxtrm[0] 11839 11926 if len(np.arange(xmin,xmax,10.)) < 10: xfrqtk = 10. … … 11844 11931 for itt in range(ddt): 11845 11932 dryt = thetapotct(xmin+itt*xfrqtk, pmin=10000.) 11846 ax.semilogy(dryt[:,1], dryt[:,0]/100., color='#FFCCCC', linewidth=0.75)11933 ax.semilogy(dryt[:,1], dryt[:,0]/100., '-.', color='#FFCCCC', linewidth=lbck) 11847 11934 11848 11935 # Including moist- adiabats 11849 #for itt in range(ddt):11850 #moist = ethetapotct(xmin+itt*xfrqtk, pmin=10000.)11851 #if xmin+itt*xfrqtk == 10.: print moist[:,1], moist[:,0]/100.11852 # ax.semilogy(moist[:,1], moist[:,0]/100., color='#CCFFCC', linewidth=0.75)11936 for itt in range(ddt): 11937 moist = ethetapotct(xmin+itt*xfrqtk, pmin=10000.) 11938 if xmin+itt*xfrqtk == 10.: print moist[:,1], moist[:,0]/100. 11939 ax.semilogy(moist[:,1], moist[:,0]/100., '--', color='#CCFFCC', linewidth=lbck) 11853 11940 11854 11941 # Plot the data using normal plotting functions, in this case using
Note: See TracChangeset
for help on using the changeset viewer.