Changeset 1026 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 17, 2016, 9:22:22 AM (9 years ago)
Author:
lfita
Message:

Working version with figures shadcont2Dsfc' and shadconthovmsfc'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1025 r1026  
    11401140
    11411141def draw_plot(kplot, CFvplot, fplot, vplot, dplot, pplot, finame, tfig, kfig, mapval,\
    1142   tunits, od, pyH, fscr, db):
     1142  tvals, od, pyH, fscr, db):
    11431143    """ Function to draw a plot
    11441144      kplot= kind of plot
     
    11521152      kfig= kind of the figure
    11531153      mapval= value of the map
    1154       tunits= units of time
     1154      tvals= list with time values
     1155        tunits: units of time ('!' for spaces)
     1156        timekind: kind of time ticks in the plot
     1157        timefmt: format of time ticks in the plot
     1158        timelabel: label of time-axis in the plot
    11551159      od= output directory
    11561160      pyH= python HOME
     
    11691173    # Tracking file with all the figures
    11701174    trkobjf = open('all_figures.inf', 'a')
     1175
     1176    # Time-characteristics
     1177    tunits = tvals[0]
     1178    timekind = tvals[1]
     1179    timefmt = tvals[2]
     1180    timelabel = tvals[3]
    11711181
    11721182    if not os.path.isfile(finame):
     
    12011211            cntstdn = CFvplot[1]
    12021212            figfs = ','.join(fplot)
     1213
    12031214            shad = pplot[0]
    12041215            srange = str(shad[0]) + ',' + str(shad[1])
     
    12061217            cnt = pplot[1]
    12071218            crange = str(cnt[0]) + ',' + str(cnt[1])
    1208             cfmt = cnt[2]
    1209             cline = cnt[3]
     1219            cfmt = cnt[3]
     1220            cline = cnt[4]
    12101221
    12111222            graphvals = ','.join(CFvplot)
     
    12201231            try:
    12211232                with gen.Capturing() as output:
    1222                     sout = sub.call(plotins, shell=True)
     1233                    sout0 = sub.call(plotins, shell=True)
    12231234            except:
    12241235                print 'drawing.draw_2D_shad_cont(' + graphvals + ',' + figfs + ',' + \
    12251236                  fvarS + ')'
     1237                print sout0
    12261238                for sout in output: print sout
    12271239                quit(-1)
     
    12331245            trkobjf.write("#" + tfig.replace('!',' ') + '\n')
    12341246            trkobjf.write(plotins + '\n')
     1247
     1248        elif kplot == 'shadconthovmsfc':
     1249            figtit = tfig.replace('!','|')
     1250            shdstdn = CFvplot[0]
     1251            cntstdn = CFvplot[1]
     1252            figfs = ','.join(fplot)
     1253
     1254            shad = pplot[0]
     1255            srange = str(shad[0]) + ',' + str(shad[1])
     1256            cbar = shad[2]
     1257            cnt = pplot[1]
     1258            crange = str(cnt[0]) + ',' + str(cnt[1])
     1259            cfmt = cnt[3]
     1260            cline = cnt[4]
     1261            # It is assumed that if the space variable is 'lon': is desired a
     1262            #   (lon, time) plot it it is 'lat': then (time, lat) plot
     1263            if gen.searchInlist(dplot,'lon'):
     1264                spacedim ='lon'
     1265                figmid = 'longitudinal|evolution|of'
     1266                figtit = '|'.join(tfig.split('!')[0:2]) + '|' + figmid + '|' +       \
     1267                  '|'.join(tfig.split('!')[2:])
     1268                reverse= 'None'
     1269                dims= spacedim+'|-1,time|-1;'+spacedim+'|-1,time|-1;'+spacedim+';time'
     1270            else:
     1271                spacedim='lat'
     1272                figmid = 'meridional|evolution|of'
     1273                figtit = '|'.join(tfig.split('!')[0:2]) + '|' + figmid + '|' +       \
     1274                  '|'.join(tfig.split('!')[2:])
     1275                reverse='None'
     1276                dims= spacedim+'|-1,time|-1;'+spacedim+'|-1,time|-1;time;'+spacedim
     1277
     1278            graphvals = ','.join(CFvplot)
     1279            graphvals = graphvals + ';'+ dims +';'+ cbar +  \
     1280              ';fixsigc,' + cline + ';' + cfmt + ';' + srange + ';' + crange +',9;'+ \
     1281              figtit + ';' + kfig + ';' + reverse + ';' + 'time|' + tunits + '|'+ \
     1282              timekind + '|' + timefmt + '|' + timelabel
     1283
     1284            fvarS = ','.join(vplot)
     1285
     1286            drwins = 'draw_2D_shad_cont_time'
     1287            plotins = 'python ' + pyH + '/drawing.py -f ' + figfs +' -o ' + drwins + \
     1288              " -S '" + graphvals + "' -v " + fvarS
     1289
     1290            try:
     1291                with gen.Capturing() as output:
     1292                    sout0 = sub.call(plotins, shell=True)
     1293            except:
     1294                print 'draw_2D_shad_cont_time(' + graphvals + ',' + figfs + ',' +    \
     1295                  fvarS + ')'
     1296                print sout0
     1297                for sout in output: print sout
     1298                quit(-1)
     1299
     1300            sout = sub.call('mv 2Dfields_shadow-contour.'+kfig+' '+finame, shell=True)
     1301
     1302            # keeping all figures
     1303            trkobjf.write('\n')
     1304            trkobjf.write("#" + tfig.replace('!',' ') + '\n')
     1305            trkobjf.write(plotins + '\n')
     1306
    12351307        else:
    12361308            print errmsg
     
    12801352        opersurnames[opn] = vls
    12811353
     1354    # time values
    12821355    # Units time for the plots
    12831356    rd = config['CFreftime']
    1284     timeunits = config['CFunitstime'] + '!since!' + rd[0:4] + '-' + rd[4:6] + '-' +  \
     1357    tunits = config['CFunitstime'] + '!since!' + rd[0:4] + '-' + rd[4:6] + '-' +  \
    12851358      rd[6:8] + '!' + rd[8:10] + ':' + rd[10:12] + ':' + rd[12:14]
    1286 
    1287     # Dictinoary of plot specificities
     1359    # time ticks kind
     1360    tkind = config['timekind']
     1361    # time ticks format
     1362    tfmt = config['timefmt']
     1363    # time axis label
     1364    tlab = config['timelabel']
     1365    timevals = [tunits, tkind, tfmt, tlab]
     1366
     1367    # Dictionary of plot specificities
    12881368    #   [minval]: minimum value
    12891369    #   [maxval]: minimum value
     
    14051485                # Title of the figure:
    14061486                if ivp == 0:
    1407                     titfigure = mod + '!' + exp + '!' + vn
     1487                    titfigure = mod + '!' + exp + "!'" + vn + "'"
    14081488                else:
    1409                     titfigure = titfigure + '!&!' + vn
    1410                 for op1 in op.split('+'):
     1489                    titfigure = titfigure + "!&!'" + vn + "'"
     1490                opvals = op.split('+')
     1491                for op1 in opvals:
    14111492                    if not opexplained.has_key(op1):
    14121493                        print errormsg
     
    14141495                        print '    provided:', opexplained.keys()
    14151496                        quit(-1)
    1416                     titfigure = titfigure + '!' + opexplained[op1]
     1497                    if op1 == opvals[0]:
     1498                        titfigure = titfigure + '$_{[' + opexplained[op1]
     1499                        if len(opvals) == 1: titfigure = titfigure + ']}$'
     1500                    elif op1 == opvals[len(opvals)-1]:
     1501                        titfigure = titfigure + '\!' + opexplained[op1] + ']}$'
     1502                    else:
     1503                        titfigure = titfigure + '\!' + opexplained[op1]
    14171504
    14181505                ivp = ivp + 1
    14191506            # End of variable-operation
     1507            figname = figname + '.' + kindfigure
    14201508
    14211509            draw_plot(kplot, CFvarsplot, filesplot, varsplot, dimsplot, pictplot,    \
    1422               figname, titfigure, kindfigure, mapvalue, timeunits, odir, pyHOME,     \
     1510              figname, titfigure, kindfigure, mapvalue, timevals, odir, pyHOME,      \
    14231511              figscr, debug)
    14241512
  • trunk/tools/model_graphics_template.dat

    r1025 r1026  
    3333
    3434# Have new figures been added and do they need to be drawn?
    35 addfigures = true
     35addfigures = false
    3636
    3737# Debug
    38 debug = true
     38debug = false
    3939
    4040# Folder with the files
     
    112112# Text as title for each operation
    113113#   as ':' separated list of [op]|[explanation '!' as spaces]
    114 titleoperations = acc|temporal!accumulated:diff|difference:direct|!:last|last!temporal!value:Lmean|latitudinal!mean:Lsec|latitudinal!section:lmean|longitudinal!mean:lsec|longitudinal!section:pinterp|pressure!interpolation:tmean|temporal!mean:turb|Taylor's!turbulence:xmean|x-axis!mean:ymean|y-axis!mean:zsum|vertical!aggregated
     114titleoperations = acc|tacc:diff|diff:direct|!:last|last:Lmean|latmean:Lsec|latsec:lmean|lonmean:lsec|lonsec:pinterp|pressure!interpolation:tmean|temporal!mean:turb|turbulence:xmean|xmean:ymean|ymean:zsum|zsum
    115115
    116116# Pressure levels
     
    138138
    139139DIRPLT_shadcont2Dsfc = uas|last#vas|last:hfls|last#hfss|last:wss|last#tas|last
    140 #DIRPLT_shadconthovmsfc = wss|xmean#tas|xmean
     140DIRPLT_shadconthovmsfc = wss|xmean#tas|xmean
    141141#DIRPLT_shadcont2Dzsec = ua|pinterp+tmean+xmean#va|pinterp+tmean+xmean:hus|pinterp+tmean+xmean#ta|pinterp+tmean+xmean
    142142
     
    177177#  [timefmt]; desired format for the time ticks (combination of LaTeX and 'linux date formats')
    178178#  [timelabel]; label at the graph ('!' for spaces)
    179 
    180179timekind = exct,6,h
    181180timefmt = $%d^{%H}$
Note: See TracChangeset for help on using the changeset viewer.