Changeset 1078 in lmdz_wrf for trunk


Ignore:
Timestamp:
Sep 1, 2016, 6:48:08 PM (9 years ago)
Author:
lfita
Message:

Working version with 2lines', 2linesTime'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1072 r1078  
    791791        tvar: temporal variance values (Taylor's turbulence)
    792792        xmean: x-axis mean values
     793        xvar: x-axis variance values
    793794        ymean: y-axis mean values
    794795        zsum: vertical aggregated values
     
    11521153            varkeep.append('lonstats')
    11531154
     1155        elif op == 'xvar':
     1156            # x-axis variance values
     1157            vals='lon|-1,lon,var,' + ':'.join(varnCFs) + ':' + vdnz
     1158            dims = gen.dictvar_listS(varnCFs,CFdimvardict,',','@') + dnz+'@'+vdnz
     1159            if dofile:
     1160                try:
     1161                    with gen.Capturing() as output:
     1162                        ncvar.file_oper_alongdims(vals,prevfile,CFvarnp)
     1163                except:
     1164                    print errmsg
     1165                    print 'file_oper_alongdims('+vals+',', prevfile, ','+CFvarnp+')'
     1166                    for s1out in output: print s1out
     1167                    quit(-1)
     1168
     1169                if db:
     1170                    for s1out in output: print s1out
     1171
     1172                sout = sub.call('mv file_oper_alongdims_var.nc '+fileon, shell=True)
     1173
     1174                # Keeping the operations
     1175                pyins=pyH + "/nc_var.py -o file_oper_alongdims -S '" + vals +        \
     1176                  "' -f " + prevfile + " -v " + CFvarnp
     1177                otrackf.write("\n")
     1178                otrackf.write("# " + CFvarn + " " + Fopers + "\n")
     1179                otrackf.write(pyins + "\n")
     1180
     1181            # removing dimension variable-dimension 'lon'
     1182            varnCFs.remove('lon')
     1183
     1184            varkeep.append('lonstats')
     1185
    11541186        elif op == 'ymean':
    11551187            # y-axis mean values
     
    15701602            if gen.searchInlist(dplot,'lon'):
    15711603                spacedim ='lon'
    1572                 figmid = 'longitudinal|evolution|of'
    1573                 figtit = '|'.join(tfig.split('!')[0:2]) + '|' + figmid + '|' +       \
    1574                   '|'.join(tfig.split('!')[2:])
    1575                 reverse= 'None'
    1576                 dims= spacedim+'|-1,time|-1;'+spacedim+'|-1,time|-1;'+spacedim+';time'
     1604                axisvals = 'y'
     1605                figmid = 'longitudinal'
     1606            elif gen.searchInlist(dplot,'lat'):
     1607                spacedim = 'lat'
     1608                axisvals = 'x'
     1609                figmid = 'meridional'
     1610            elif gen.searchInlist(dplot,'pres'):
     1611                spacedim = 'pres'
     1612                axisvals = 'x'
     1613                figmid = 'vertical'
    15771614            else:
    1578                 spacedim='lat'
    1579                 figmid = 'meridional|evolution|of'
    1580                 figtit = '|'.join(tfig.split('!')[0:2]) + '|' + figmid + '|' +       \
    1581                   '|'.join(tfig.split('!')[2:])
    1582                 reverse='None'
    1583                 dims= spacedim+'|-1,time|-1;'+spacedim+'|-1,time|-1;time;'+spacedim
    1584 
    1585             graphvals = ','.join(CFvplot)
    1586             graphvals = graphvals + ';'+ dims +';'+ cbar +  \
    1587               ';' + ckind + ',' + cline + ';' + cfmt + ';' + srange + ';' + crange + \
    1588               ',9;' + figtit + ';' + kfig + ';' + reverse + ';' + 'time|' + tunits + \
    1589               '|'+ timekind + '|' + timefmt + '|' + timelabel
     1615                print errmsg
     1616                print '  ' + fname + ": in '2lines' only ready for: 'lon', 'lat'," + \
     1617                 " 'pres' as common dimension !!"
     1618                print '  dimensions in plot:', dplot
     1619                quit(-1)
     1620
     1621            figtit = '|'.join(tfig.split('!')[0:2]) + '|' + figmid + '|' +           \
     1622              '|'.join(tfig.split('!')[2:])
     1623
     1624            graphvals = spacedim + ':' + Arange + ':' + Brange + ':Extrs:' +         \
     1625              axisvals + ':' + ','.join(CFvplot) + ':' + Aline + ',' + Bline +       \
     1626              ':2.,2.:' + Akind + ',' + Bkind + ':,:' + figtit + ':' + spacedim +    \
     1627              ':0:' +  finame + ':' + kfig
    15901628
    15911629            fvarS = ','.join(vplot)
    15921630
    1593             drwins = 'draw_2D_shad_cont_time'
     1631            drwins = 'draw_2lines'
    15941632            plotins = 'python ' + pyH + '/drawing.py -f ' + figfs +' -o ' + drwins + \
    15951633              " -S '" + graphvals + "' -v " + fvarS
    1596 
    1597 
    1598       values= [dimvname]:[valuesaxis]:[dimtit]:[leglabels]:[vtit]:[title]:[locleg]:[colns]:[lines]
    1599        [points]:[lwdths]:[psizes]:[freqv]:[figname][graphk]
    1600         [dimvname]: ',' list of names of the variable with he values of the common dimension
    1601         [valuesaxis]: which axis will be used for the values ('x', or 'y')
    1602         [dimtit]: title for the common dimension
    1603         [leglabels]: ',' separated list of names for the legend
    1604         [vartit]: name of the variable in the graph
    1605         [title]: title of the plot ('|' for spaces)
    1606         [locleg]: location of the legend (0, autmoatic)
    1607           1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    1608           5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
    1609           9: 'upper center', 10: 'center'
    1610         [colns]= ',' list of color names ('None' for automatic, single value for all the same)
    1611         [lines]= ',' list of style of lines ('None' for automatic, single value for all the same)
    1612         [points]= ',' list of style of points ('None' for automatic, single value for all the same)
    1613         [lwdths]= ',' list of withs of lines ('None' for automatic, single value for all the same)
    1614         [psizes]= ',' list of size of points ('None' for automatic, single value for all the same)
    1615         [freqv]= frequency of values ('all' for all values)
    1616         [figname]= name of the figure
    1617         [graphk]: kind of the graphic
    1618       varname= variable to plot
    1619  
    16201634
    16211635            try:
     
    16291643                quit(-1)
    16301644
    1631             sout = sub.call('mv 2Dfields_shadow-contour.'+kfig+' '+finame, shell=True)
    1632 
    16331645            # keeping all figures
    16341646            trkobjf.write('\n')
    16351647            trkobjf.write("#" + tfig.replace('!',' ') + '\n')
    16361648            trkobjf.write(plotins + '\n')
     1649
     1650        elif kplot == '2linesTime':
     1651            figtit = tfig.replace('!','|')
     1652
     1653            lineAstdn = CFvplot[0]
     1654            lineBstdn = CFvplot[1]
     1655            figfs = ','.join(fplot)
     1656
     1657            lineA = pplot[0]
     1658            Arange = str(lineA[0]) + ',' + str(lineA[1])
     1659            # Values are changed from specific values in `model_graphics.dat'
     1660            if lineA[3].find('%') == -1:
     1661                Aline = lineA[2]
     1662                Akind = lineA[3]
     1663                Amark = lineA[4]
     1664                Asize = lineA[5]
     1665            else:
     1666                Aline = 'red'
     1667                Akind = '-'
     1668                Amark = ','
     1669                Asize = 2.
     1670
     1671            lineB = pplot[1]
     1672            Brange = str(lineB[0]) + ',' + str(lineB[1])
     1673            # Values are changed from specific values in `model_graphics.dat'
     1674            if lineB[3].find('%') == -1:
     1675                Bline = lineB[2]
     1676                Bkind = lineB[3]
     1677                Bmark = lineB[4]
     1678                Bsize = lineB[5]
     1679            else:
     1680                Bline = 'red'
     1681                Bkind = '-'
     1682                Bmark = ','
     1683                Bsize = 2.
     1684
     1685            timeaxis = 'x'
     1686            figmid = 'evolution'
     1687
     1688            figtit = '!'.join(tfig.split('!')[0:2]) + '!' + figmid + '!' +           \
     1689              '!'.join(tfig.split('!')[2:])
     1690
     1691            graphvals = 'time:' + Arange + ':' + Brange + ':' + timekind + ';' +     \
     1692              timefmt + ':' + timeaxis + ':' + ','.join(CFvplot) + ':' + Aline + ',' \
     1693              + Bline + ':2.,2.:' + Akind + ',' + Bkind + ':2.,2.:,:' + figtit + ':' \
     1694              + timelabel + ':0:' +  finame + ':' + kfig
     1695
     1696            fvarS = ','.join(vplot)
     1697
     1698            drwins = 'draw_2lines_time'
     1699            plotins = 'python ' + pyH + '/drawing.py -f ' + figfs +' -o ' + drwins + \
     1700              " -S '" + graphvals + "' -v " + fvarS
     1701
     1702            try:
     1703                with gen.Capturing() as output:
     1704                    sout = sub.call(plotins, shell=True)
     1705            except:
     1706                print errmsg
     1707                print drwins + '(' + graphvals + ',' + figfs + ',' + fvarS + ')'
     1708                print sout
     1709                for s1out in output: print s1out
     1710                quit(-1)
     1711
     1712            # keeping all figures
     1713            trkobjf.write('\n')
     1714            trkobjf.write("#" + tfig.replace('!',' ') + '\n')
     1715            trkobjf.write(plotins + '\n')
     1716
    16371717        elif kplot == 'shadcont2Dsfc':
    16381718            figtit = tfig.replace('!','|')
     
    19852065                for op1 in opvals:
    19862066                    if not opexplained.has_key(op1):
    1987                         print errormsg
     2067                        print errmsg
    19882068                        print '  '+fname+": no explanation for operation '"+op1+"' !!"
    19892069                        print '    provided:', opexplained.keys()
     
    23442424        tvar: temporal variance values (Taylor's turbulence)
    23452425        xmean: x-axis mean values
     2426        xvar: x-axis variance values
    23462427        ymean: y-axis mean values
    23472428        zsum: vertical aggregated values
     
    26102691            varkeep.append('lonstats')
    26112692
     2693        elif op == 'xvar':
     2694            # x-axis variance values
     2695            vals='lon|-1,lon,var,' + ':'.join(varnCFs) + ':' + vdnz
     2696            dims = gen.dictvar_listS(varnCFs,CFdimvardict,',','@') + dnz+'@'+vdnz
     2697            if dofile:
     2698                try:
     2699                    with gen.Capturing() as output:
     2700                        ncvar.file_oper_alongdims(vals,prevfile,CFvarnp)
     2701                except:
     2702                    print errmsg
     2703                    print 'file_oper_alongdims('+vals+',', prevfile, ','+CFvarnp+')'
     2704                    for s1out in output: print s1out
     2705                    quit(-1)
     2706
     2707                if db:
     2708                    for s1out in output: print s1out
     2709
     2710                sout = sub.call('mv file_oper_alongdims_var.nc '+fileon, shell=True)
     2711
     2712                # Keeping the operations
     2713                pyins=pyH + "/nc_var.py -o file_oper_alongdims -S '" + vals +        \
     2714                  "' -f " + prevfile + " -v " + CFvarnp
     2715                otrackf.write("\n")
     2716                otrackf.write("# " + CFvarn + " " + Fopers + "\n")
     2717                otrackf.write(pyins + "\n")
     2718
     2719            # removing dimension variable-dimension 'lon'
     2720            varnCFs.remove('lon')
     2721
     2722            varkeep.append('lonstats')
     2723
    26122724        elif op == 'ymean':
    26132725            # y-axis mean values
Note: See TracChangeset for help on using the changeset viewer.