Changeset 1945 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jul 17, 2018, 11:45:19 PM (7 years ago)
Author:
lfita
Message:

Fixing `draw_multi_SkewT'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r1937 r1945  
    90789078            quit(-1)
    90799079
     9080        if  not os.path.isfile(ncfile):
     9081            print errormsg
     9082            print '  ' + fname + ": file '" + ncfile + "' does not exist !!"
     9083            quit(-1)
     9084
    90809085        onc = NetCDFFile(ncfile, 'r')
     9086        print '  ' + fname + ": getting from file '" + ncfile + "' variables:" ,     \
     9087          varns, 'with slice:', dimvals
    90819088        for varn in varns:
    90829089            if not onc.variables.has_key(varn):
     
    90899096        ov = onc.variables[varns[0]]
    90909097        opres = onc.variables[varns[1]]
     9098        otime = onc.variables['time']
    90919099
    90929100        # Getting values
    90939101        vals, valdims = drw.slice_variable(ov, dimvals.replace(',','|'))
    90949102        pvals, presdims = drw.slice_variable(opres, dimvals.replace(',','|'))
     9103        tvals, tdims = drw.slice_variable(otime, dimvals.replace(',','|'))
    90959104
    90969105        # Expected masked values
  • trunk/tools/drawing_tools.py

    r1937 r1945  
    1140611406
    1140711407def SaturationPressure(temp):
    11408     """ Provides de saturation pressure at a given temperature following The August-Roche-Magnus equation
     11408    """ Provides de saturation pressure [hPa] at a given temperature following The
     11409      August-Roche-Magnus equation
    1140911410      temp: temperature [K]
     11411    >>> SaturationPressure(293.15)
     11412    23.334406231
    1141011413    """
    1141111414    fname = 'SaturationPressure'
     
    1141611419   
    1141711420    tempC = temp - 273.15 
    11418     satpres = 100.*ARM1*(ARM2*tempC)/(tempC+ARM3)
     11421    satpres = ARM1*exp(ARM2*tempC/(tempC+ARM3))
    1141911422
    1142011423    return satpres
     
    1142311426
    1142411427def SatMixingRatio(ta,pres):
    11425     """ Provides de saturation mixing ratio
     11428    """ Provides de saturation mixing ratio [kgkg-1]
    1142611429      ta: temperature [K]
    1142711430      pres: pressure [Pa]
     11431    >>> SatMixingRatio(293.,101300.)
     11432    0.014531424608
    1142811433    """
    1142911434    fname = 'SatMixingRatio'
    1143011435
    1143111436    es = SaturationPressure(ta)
    11432     rs = (0.6222*es)/(pres-es)
     11437    rs = (0.6222*es)/(0.01*pres-es)
    1143311438
    1143411439    return rs
     
    1146311468    for iz in range(dz):
    1146411469        ethetapotv[iz,0] = psfc-dp*iz
    11465         thetapotv = (tsfc+273.15)*((psfc-dp*iz)/p0)**(R/Cp)
    11466 #        print iz,psfc-dp*iz,thetapotv,SatMixingRatio(tsfc+273.15,psfc),np.exp(L*1000.*SatMixingRatio(tsfc+273.15,psfc)/Cp*(tsfc+273.15))
    11467         ethetapotv[iz,1] = thetapotv*np.exp(L*1000.*SatMixingRatio(tsfc+273.15,psfc)/(Cp*(tsfc+273.15))) - 273.15
    11468 
    11469 #    quit()
     11470        thetapotv = (tsfc+273.15)*((psfc-dp*iz)/p0)**(R/Cp)
     11471        ws = SatMixingRatio(tsfc+273.15,psfc)
     11472        ethetapotv[iz,1] = thetapotv*np.exp(L*1000.*ws/(Cp*(tsfc+273.15))) -273.15
     11473        print iz,psfc-dp*iz,thetapotv-273.15,ethetapotv[iz,1]
     11474
     11475    #quit()
    1147011476    return ethetapotv
    1147111477
     
    1153311539    xmax = taxtrm[1]
    1153411540    xmin = taxtrm[0]
    11535     print 'len:', np.arange(xmin,xmax,10.)
    1153611541    if len(np.arange(xmin,xmax,10.)) < 10: xfrqtk = 10.
    1153711542    else: xfrqtk = 20.
     
    1162011625    xmax = taxtrm[1]
    1162111626    xmin = taxtrm[0]
    11622     print 'len:', np.arange(xmin,xmax,10.)
    1162311627    if len(np.arange(xmin,xmax,10.)) < 10: xfrqtk = 10.
    1162411628    else: xfrqtk = 20.
     
    1163911643    l = ax.axvline(0, color='C0')
    1164011644
    11641     Nlines = len(kindgv['labels'])
     11645    Nlines = len(tvals)
     11646    NLlines = len(kindgv['labels'])
     11647    if Nlines != NLlines:
     11648        print errormsg
     11649        print '  ' + fname + ': number of lines:', Nlines,                           \
     11650          ' and number of labels:', NLlines, 'do not coincide !!'
     11651        print '    provided labels:', kindgv['labels']
     11652        quit(-1)
     11653
     11654    print '  ' + fname + ': plotting ', Nlines, 'lines ...'
    1164211655
    1164311656    for iline in range(Nlines):
     
    1169411707    plt.legend(loc=legv[0], prop={'size':legv[1]})
    1169511708
     11709    ax.set_xlabel('t ($^{\circ}$C)')
     11710    ax.set_ylabel('pres (hPa)')
     11711
    1169611712    ax.set_title(gen.latex_text(figtitle))
    1169711713
Note: See TracChangeset for help on using the changeset viewer.