Changeset 2151 in lmdz_wrf for trunk


Ignore:
Timestamp:
Sep 20, 2018, 4:47:43 PM (7 years ago)
Author:
lfita
Message:

Trying to fix moist-adiabts in `SkewT_Plog'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r2127 r2151  
    89998999    return
    90009000
    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)
     9001filen='/home/lluis/estudios/ChemGBsAs/tests/199807/obs/snd/UWyoming_snd_87576.nc'
     9002values='time|0:auto:auto:Sounding!at!Ezeiza!airport!on!3rd!July!1998:png:yes'
     9003varn='ta,tda,pres'
     9004draw_SkewT(filen, values, varn)
     9005
    90059006
    90069007def draw_multi_SkewT(ncfiles, values):
  • trunk/tools/drawing_tools.py

    r2119 r2151  
    1169711697    return
    1169811698
    11699 def SaturationPressure(temp):
     11699def es(temp):
    1170011700    """ Provides de saturation pressure [hPa] at a given temperature following The
    1170111701      August-Roche-Magnus equation
     
    1170411704    23.334406231
    1170511705    """
    11706     fname = 'SaturationPressure'
     11706    fname = 'es'
    1170711707
    1170811708    ARM1 = 6.1094 # hPa
     
    1171111711   
    1171211712    tempC = temp - 273.15 
    11713     satpres = ARM1*exp(ARM2*tempC/(tempC+ARM3))
    11714 
    11715     return satpres
     11713    esv = ARM1*exp(ARM2*tempC/(tempC+ARM3))
     11714
     11715    return esv
    1171611716
    1171711717#print 'satpres:', SaturationPressure(293.15)
    1171811718
    11719 def SatMixingRatio(ta,pres):
     11719def qs(ta,pres):
    1172011720    """ Provides de saturation mixing ratio [kgkg-1]
    1172111721      ta: temperature [K]
     
    1172411724    0.014531424608
    1172511725    """
    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
     11737def 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
     11749def 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
     11762def 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
     11778def 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
     11796def 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
     11818print equivpot(300., 98000., 0.02)
     11819quit()
    1173411820
    1173511821def ethetapotct(tsfc, dz=50, pmin=5000.):
     
    1175811844    dp = (psfc-pmin)/(dz-1)
    1175911845   
    11760     ws = SatMixingRatio(tsfc+273.15,psfc)
     11846    wsv = ws(tsfc+273.15,psfc)
    1176111847    thetasfc = (tsfc+273.15)*(psfc/p0)**(R/Cp)
    1176211848    for iz in range(dz):
    1176311849        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
    1177111856
    1177211857    print thetasfc,ws
    11773     #quit()
     11858    quit()
    1177411859    return ethetapotv
    1177511860
     
    1180911894    """
    1181011895    import skewt
     11896
     11897    lbck = 1.
    1181111898
    1181211899    fname = 'plot_SkewT'
     
    1183211919    ax = fig.add_subplot(111, projection='skewx')
    1183311920
    11834     plt.grid(True)
     11921    plt.grid(True, linewidth=lbck)
    1183511922
    1183611923    # Quantity of dryadiabats
    11837     xmax = taxtrm[1]
     11924    xmax = 150.
    1183811925    xmin = taxtrm[0]
    1183911926    if len(np.arange(xmin,xmax,10.)) < 10: xfrqtk = 10.
     
    1184411931    for itt in range(ddt):
    1184511932        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)
    1184711934
    1184811935    # 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)
    1185311940
    1185411941    # Plot the data using normal plotting functions, in this case using
Note: See TracChangeset for help on using the changeset viewer.