Changeset 1025 in lmdz_wrf


Ignore:
Timestamp:
Aug 16, 2016, 8:53:49 PM (9 years ago)
Author:
lfita
Message:

Getting almost there for the first figure!

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1022 r1025  
    77import nc_var_tools as ncvar
    88import generic_tools as gen
     9import drawing_tools as drw
    910import time as tim
    1011#  To avoid errors like: '/bin/sh: 1: Syntax error: Bad fd number'
     
    289290            #   [operation]: operation to compute
    290291            #   [fheader]: header of file with the required variables
    291             #   [vmodel]:
    292             #   [vdiag]:
     292            #   [vmodel]: Variable from model output
     293            #   [vdiag]: Varible as diagnostic from different variables of the model output
    293294            #   [globalP]: Wether vertical interpolation is:
    294295            #     'global': for all file
     
    320321
    321322    # Outwritting the varcompute to avoid next time (if it is not filescratch!)
    322     objf = open(owdir + '/varcompute.inf', 'w')
     323    objf = open(odir + '/varcompute.inf', 'w')
    323324    objf.write('files: ' + strfiles + '\n')
    324325    objf.write('testfiles: ' + strtestfiles + '\n')
    325326    objf.write('varcompute: ' + Svarcompute + '\n')
    326327    objf.write('itotv: ' + str(ivop) + '\n')
    327     objf.close()
     328    objf.close() 
    328329
    329330    return allvarcomp, ivop
     
    365366    return Files, TestFiles, allvarcomp, ivop
    366367
     368def pinterpS(gP):
     369    """ For that variables which require vertical interpolation 'p' suffix to the file header is added
     370      gP= kind of pinterp: 'global', 'local', 'none'
     371    """
     372    fname = 'pinterpS'
     373
     374    if gP != 'none':
     375        gPS = 'p'
     376    else:
     377        gPS = ''
     378
     379    return gPS
     380
    367381def compute_variable(minf, idir, usefiles, odir, cvar, gP, scr, pyH, Tref, Tunits, db):
    368382    """ Function to compute a variable
     
    401415    # For that variables which require vertical interpolation 'p' suffix to the
    402416    #   file header is added
    403     if gP != 'none':
    404         SgP = 'p'
    405     else:
    406         SgP = ''
     417    SgP = pinterpS(gP)
    407418
    408419    # Getting in working dir
     
    435446            if modvar is not None and diagvar is None:
    436447                # model variable
    437                 values = modvar + ',0,-1,-1'
    438                 vs = modvar + ',' + vdnx + ',' + vdny + ',' + vdnz + ',' + vdnt
     448                values = modvar[0] + ',0,-1,-1'
     449                vs = modvar[0] + ',' + vdnx + ',' + vdny + ',' + vdnz + ',' + vdnt
    439450                with gen.Capturing() as output:
    440451                    ncvar.DataSetSection_multivars(values, cf, vs)
     
    448459                  vs + " -S '" + values + "'"
    449460                otrackf.write('\n')
    450                 otrackf.write('# ' + CFvarn + " " + modvar + '\n')
     461                otrackf.write('# ' + CFvarn + " " + modvar[0] + '\n')
    451462                otrackf.write(pyins + '\n')
    452463
    453464                # CF renaming of variable
    454                 ncvar.chvarname(CFvarn,ifilen,modvar)
     465                ncvar.chvarname(CFvarn,ifilen,modvar[0])
    455466            else:
    456467                # diagnostic variable
     
    587598    Tunits = config['CFunitstime']
    588599    #  opsur = operation surnames
     600
    589601    opsur = gen.get_specdictionary_HMT(config, H='opsur_',M='',T='')
    590602    Opsurs = {}
     
    593605        vals = opsur[opk]
    594606        Opsurs[opn] = vals.split(':')
    595     if db:
    596         print '  ' + fname + ' operation surnames _______'
    597         gen.printing_dictionary(Opsurs)
     607#    if db:
     608#        print '  ' + fname + ' operation surnames _______'
     609#        gen.printing_dictionary(Opsurs)
    598610
    599611    # Getting in working dir
     
    976988    return
    977989
     990def get_plots_var(vc,pltk,db):
     991    """ Function to provide the plots to make for each variable from pltk ('DIRPLT_', or 'DIFFPLT_') dictionary
     992      vc= pltk dictionary, dictionary with all the parameters started with pltk
     993      pltk= kind of plots. Values started by 'DIRPLT_', or 'DIFFPLT_' in model configuration
     994    """
     995    fname = 'get_plots_var'
     996
     997    LH = len(pltk)
     998    # list of plots
     999    doplots = {}
     1000    # plots by variable
     1001    plotsvar = {}
     1002    # individual plots by variable (not repeated)
     1003    indivplotsvar = {}
     1004
     1005    # Variables with a plot which requires vertical interpolation
     1006    varplotp = []
     1007
     1008    ipl = 0
     1009    for plot in vc.keys():
     1010        Lplot = len(plot)
     1011        pln = plot[LH:Lplot+1]
     1012        varops = vc[plot].split(':')
     1013        for vn in varops:
     1014            VOn = vn.split('#')
     1015            # Variables and operations in plot
     1016            vplt = []
     1017            oplt = []
     1018            voplt = []
     1019            for vop in VOn:
     1020                vv = vop.split('|')[0]
     1021                oo = vop.split('|')[1]
     1022                vplt.append(vv)
     1023                oplt.append(oo)
     1024                if not gen.searchInlist(voplt,vop): voplt.append(vop)
     1025            vpltS = '#'.join(vplt)
     1026            opltS = '#'.join(oplt)
     1027           
     1028            if not doplots.has_key(pln):
     1029                doplots[pln] = [vn]
     1030            else:
     1031                plots = doplots[pln]
     1032                plots.append(vn)
     1033                doplots[pln] = plots
     1034
     1035            if not plotsvar.has_key(vn):
     1036                plotsvar[vn] = [pln]
     1037            else:
     1038                plots = plotsvar[vn]
     1039                plots.append(pln)
     1040                plotsvar[vn] = plots
     1041
     1042            for VOv in voplt:
     1043                if not indivplotsvar.has_key(VOv):
     1044                    indivplotsvar[VOv] = [pln]
     1045                else:
     1046                    plots = indivplotsvar[VOv]
     1047                    indivplots.append(pln)
     1048                    indivplotsvar[VOv] = plots
     1049
     1050        if vc[plot].find('pinterp') != -1:
     1051            if not gen.searchInlist(varplotp,vn): varplotp.append(pln)
     1052
     1053        ipl = ipl + 1
     1054
     1055    if db:
     1056        print '  plots to make _______'
     1057        gen.printing_dictionary(doplots)
     1058        print '  plots by variable|operation _______'
     1059        gen.printing_dictionary(plotsvar)
     1060        print '  individual plots by variable|operation _______'
     1061        gen.printing_dictionary(indivplotsvar)
     1062        print '  plots with the vertical interpolation _______'
     1063        print '    #', varplotp
     1064
     1065    return doplots, plotsvar, indivplotsvar, varplotp
     1066
     1067def plots_listconstruct(config, odir, debug):
     1068    """ Function to create the list of plots to draw
     1069      config= Configuration of the experiment
     1070      odir= output experiment folder
     1071    """
     1072    fname='plots_listconstruct'
     1073 
     1074    dirplot = gen.get_specdictionary_HMT(config, H='DIRPLT_')
     1075
     1076    if debug:
     1077        print '  direct plots to draw ________'
     1078        gen.printing_dictionary(dirplot)
     1079
     1080    # Getting plots by variable
     1081    plots, varplot, indivarplot, plotp = get_plots_var(dirplot,'DIRPLT_',debug)   
     1082
     1083    Svarplot = gen.dictKeysVals_stringList(plots,cV=':')
     1084
     1085    Nplots = 0
     1086    for pl in Svarplot.split(','):
     1087        Nplots = Nplots + len(pl.split(':'))
     1088
     1089    # Outwritting the varcompute to avoid next time (if it is not filescratch!)
     1090    objf = open(odir + '/directplotsdraw.inf', 'w')
     1091    objf.write('plots: ' + Svarplot + '\n')
     1092    objf.write('itotp: ' + str(Nplots) + '\n')
     1093    objf.close()
     1094
     1095    return plots, Nplots
     1096
     1097def read_plot_file(figfile):
     1098    """ Function to read the file with the information about the  plots to draw
     1099      figfile= file with the information
     1100    """
     1101    fname = 'read_plot_file'
     1102
     1103    if not os.path.isfile(figfile):
     1104        print errormsg
     1105        print '  ' + fname + ": figures file '" + figfile + "' does not exist !!"
     1106        quit(-1)
     1107
     1108    objf = open(figfile, 'r')
     1109    for line in objf:
     1110        if line[0:1] != '#' and len(line) > 1:
     1111            values = line.split(' ')
     1112            if values[0] == 'plots:':
     1113                plots = gen.stringList_dictKeysVals(values[1],cV=':')
     1114            elif values[0] == 'itotp:':
     1115                Nplots = int(values[1])
     1116
     1117    objf.close()
     1118
     1119    return plots, Nplots
     1120
     1121def varnoper(vn, oper, opsurdict):
     1122    """ Function to provide name of the variable after operation as result of addition of the 'surnames'
     1123      vn= variable name
     1124      oper= '+' separated list of operations
     1125      opsurdict= dictionary with the surname of operations
     1126    >>> OpSurDict = {'mean': ['tmean', 'xmean', 'ymean']}
     1127    >>> varnoper('tas', 'pinterp+tmean+xmean', OpSurDict)
     1128    tasmeanmean
     1129    """
     1130    fname = 'varnoper'
     1131
     1132    newvn = vn
     1133
     1134    for op in oper.split('+'):
     1135        surname = gen.dictionary_key_list(opsurdict,op)
     1136        if surname is not None:
     1137            newvn = newvn + surname
     1138
     1139    return newvn
     1140
     1141def draw_plot(kplot, CFvplot, fplot, vplot, dplot, pplot, finame, tfig, kfig, mapval,\
     1142  tunits, od, pyH, fscr, db):
     1143    """ Function to draw a plot
     1144      kplot= kind of plot
     1145      CFvplot= list of the CFnames of the variables
     1146      fplot= list with the files in the plot
     1147      vplot= list with the name of the variables in each file
     1148      dplot= list of the dimensions in each file
     1149      pplot= list of pictoric characteristics for each variable
     1150      finame= name of the figure
     1151      tfig= title of the figure
     1152      kfig= kind of the figure
     1153      mapval= value of the map
     1154      tunits= units of time
     1155      od= output directory
     1156      pyH= python HOME
     1157      fscr= whether figure should be done from scratch
     1158    """
     1159    fname = 'draw_plot'
     1160
     1161    if fscr:
     1162        sout = sub.call('rm ' + finame + ' >& /dev/null', shell=True)
     1163
     1164    os.chdir(od)
     1165
     1166    # CF variable-dimensions
     1167    CFvardims = {'lon':'lon', 'lat': 'lat', 'pres': 'pres', 'time': 'time'}
     1168
     1169    # Tracking file with all the figures
     1170    trkobjf = open('all_figures.inf', 'a')
     1171
     1172    if not os.path.isfile(finame):
     1173        if db:
     1174            print "    drawing '" + finame + "' ..."
     1175            print '      CFvars:', CFvplot
     1176            print '      files:', fplot
     1177            print '      in file vars:', vplot
     1178            print '      dims:', dplot
     1179            print '      pictoric values:', pplot
     1180            print '      figure name:', finame
     1181            print '      title:', tfig.replace('!',' ')
     1182            print '      kind:', kfig
     1183            print '      map:', mapval
     1184            print '      time units:', tunits
     1185
     1186        if kplot == 'diffmap2Dsfc':
     1187            print "  " + fname + ": kind of plot '" + kplot + "' not ready !!"
     1188            quit(-1)
     1189        elif kplot == 'diffmap2Dz':
     1190            print "  " + fname + ": kind of plot '" + kplot + "' not ready !!"
     1191            quit(-1)
     1192        elif kplot == 'map2Dsfc':
     1193            print "  " + fname + ": kind of plot '" + kplot + "' not ready !!"
     1194            quit(-1)
     1195        elif kplot == 'map3D':
     1196            print "  " + fname + ": kind of plot '" + kplot + "' not ready !!"
     1197            quit(-1)
     1198        elif kplot == 'shadcont2Dsfc':
     1199            figtit = tfig.replace('!','|')
     1200            shdstdn = CFvplot[0]
     1201            cntstdn = CFvplot[1]
     1202            figfs = ','.join(fplot)
     1203            shad = pplot[0]
     1204            srange = str(shad[0]) + ',' + str(shad[1])
     1205            cbar = shad[2]
     1206            cnt = pplot[1]
     1207            crange = str(cnt[0]) + ',' + str(cnt[1])
     1208            cfmt = cnt[2]
     1209            cline = cnt[3]
     1210
     1211            graphvals = ','.join(CFvplot)
     1212            graphvals = graphvals + ':lon|-1,lat|-1:lon|-1,lat|-1:lon:lat:' + cbar + \
     1213              ':fixc,' + cline + ':' + cfmt + ':' + srange + ':' + crange + ',9:' +  \
     1214              figtit + ':' + kfig + ':None:' + mapval
     1215
     1216            fvarS = ','.join(vplot)
     1217
     1218            plotins = "python "+pyH+"/drawing.py -f "+figfs+" -o draw_2D_shad_cont "+\
     1219              "-S '" + graphvals + "' -v " + fvarS
     1220            try:
     1221                with gen.Capturing() as output:
     1222                    sout = sub.call(plotins, shell=True)
     1223            except:
     1224                print 'drawing.draw_2D_shad_cont(' + graphvals + ',' + figfs + ',' + \
     1225                  fvarS + ')'
     1226                for sout in output: print sout
     1227                quit(-1)
     1228
     1229            sout = sub.call('mv 2Dfields_shadow-contour.'+kfig+' '+finame, shell=True)
     1230
     1231            # keeping all figures
     1232            trkobjf.write('\n')
     1233            trkobjf.write("#" + tfig.replace('!',' ') + '\n')
     1234            trkobjf.write(plotins + '\n')
     1235        else:
     1236            print errmsg
     1237            print "  " + fname + ": plot kind '" + kplot + "' not ready !!"
     1238            quit(-1)
     1239
     1240    trkobjf.close()
     1241
     1242    return
     1243
     1244def draw_plots(config, plots, mod, exp, odir, allvarcomp, figscr, debug):
     1245    """ Function to draw all plots
     1246      config= Configuration of the experiment
     1247      plots= dictionary with the plots
     1248      mod= model of the plots
     1249      exp= experiment of the plots
     1250      odir= output experiment folder
     1251      allvarcomp= dictionary with all the variables to compute and their information
     1252      figscr= whether figures should be done from the scratch or not
     1253
     1254    * Plot as
     1255      {[kplot]} = [varn1]|[op1]#[varn2]|[op2]#[...[varnN]|[opN]], ...
     1256        [kplot] ___
     1257          diffmap2Dsfc: 2D map of surface differences values of 1 variable
     1258          diffmap2Dz: 2D map of 3D differences values of 1 variable
     1259          map2Dsfc: 2D map of surface values of 1 variable
     1260          map3D: 2D map of 3D values of 1 variable
     1261          shadconthovmsfc: Hovmoeller diagrams of 2 variable at the surface in shadow and the other in contourn
     1262          shadcont2Dsfc: 2D map of shadow (1st variable) and countour (2nd variable) [stvar1]#[stvar2]
     1263          shadcont2Dzsec: 2D map of vertical section of 2 variables one in shadow and the other in contourn
     1264        [varn]
     1265          variable
     1266        [op]
     1267          '+' separated list of operations
     1268        in figures with more than 1 variable, use '#' to separate the [varn]|[op]
     1269    """
     1270    fname = 'draw_plots'
     1271
     1272    os.chdir(odir)
     1273
     1274    # Dictionary with the operations with surnames for the operated variable
     1275    opersurnames = {}
     1276    opsur = gen.get_specdictionary_HMT(config, H='opsur_',M='',T='')
     1277    for opsr in opsur.keys():
     1278        opn = opsr.split('_')[1]
     1279        vls = opsur[opsr].split(':')
     1280        opersurnames[opn] = vls
     1281
     1282    # Units time for the plots
     1283    rd = config['CFreftime']
     1284    timeunits = config['CFunitstime'] + '!since!' + rd[0:4] + '-' + rd[4:6] + '-' +  \
     1285      rd[6:8] + '!' + rd[8:10] + ':' + rd[10:12] + ':' + rd[12:14]
     1286
     1287    # Dictinoary of plot specificities
     1288    #   [minval]: minimum value
     1289    #   [maxval]: minimum value
     1290    #   [colorbar]: name of the colorbar (from matplotlib) to use
     1291    #   [cntformat]: format of the contour labels
     1292    #   [colorcnt]: color for the countor lines
     1293    plotspecifics = {}
     1294    plotspecs = config['specificvarplot'].split(':')
     1295    for pltspc in plotspecs:
     1296        pltvls = pltspc.split('|')
     1297        vn = pltvls[0]
     1298        op = pltvls[1]
     1299        fn = pltvls[2]
     1300        plotspecifics[fn + '_' + vn + '_' + op] = pltvls[3:]
     1301    if debug:
     1302        print 'Specific values for plots _______'
     1303        gen.printing_dictionary(plotspecifics)
     1304
     1305    # Kind of figures
     1306    kindfigure = config['kindfig']
     1307
     1308    # Map value
     1309    mapvalue = config['mapval']
     1310
     1311    # pythone scripts HOME
     1312    pyHOME = config['pyHOME']
     1313
     1314    # Title-text of operations
     1315    opexplained = {}
     1316    optits = config['titleoperations'].split(':')
     1317    for optit in optits:
     1318        opn = optit.split('|')[0]
     1319        opt = optit.split('|')[1]
     1320        opexplained[opn] = opt
     1321    if debug:
     1322        print 'Titles for operations  _______'
     1323        gen.printing_dictionary(opexplained)
     1324
     1325    for kplot in plots.keys():
     1326        varsplt = plots[kplot]
     1327        for varplt in varsplt:
     1328            if debug:
     1329                print "  printing '" + kplot + "' var ':" + varplt + "'..."
     1330            varops = varplt.split('#')
     1331
     1332            # CF variables in plot
     1333            CFvarsplot = []
     1334            # Files in plot
     1335            filesplot = []
     1336            # Variables in plot within the files
     1337            varsplot = []
     1338            # Dims in figure
     1339            dimsplot = []
     1340            # pictoric values in figure
     1341            pictplot = []
     1342            # Name of the figure
     1343            figname = ''
     1344            # Title of the figure
     1345            titfigure = ''
     1346
     1347            ivp = 0
     1348            for varop in varops:
     1349                vn = varop.split('|')[0]
     1350                op = varop.split('|')[1]
     1351
     1352                # CF variables in plot
     1353                CFvarsplot.append(vn)
     1354 
     1355                vnopS = vn + '_' + op
     1356                if not allvarcomp.has_key(vnopS):
     1357                    print errormsg
     1358                    print '  ' + fname + ": no entry for variable-operation '" +     \
     1359                      vnopS + "' !!"
     1360                vopvals = allvarcomp[vnopS]
     1361                headf = vopvals[0]
     1362                globalP = vopvals[3]
     1363                gP = pinterpS(globalP)
     1364
     1365                filen = vn + '_' + headf + gP + '_' + op + '.nc'
     1366                filesplot.append(filen)
     1367                # Do we have processed the given variable?
     1368                if not os.path.isfile(filen):
     1369                    print warnmsg
     1370                    print "  " + fname + ": there is no file for variable '" + varop \
     1371                      + "' skiping it !!"
     1372                    break
     1373
     1374                # Name of the variable inside the file
     1375                vnsur = varnoper(vn, op, opersurnames)
     1376                varsplot.append(vnsur)
     1377
     1378                # Dimensions in file
     1379                try:
     1380                    with gen.Capturing() as output:
     1381                        dims = ncvar.idims(filen)
     1382                except:
     1383                    print 'ncvar.idims('+filen+')'
     1384                    for sout in output: print sout
     1385                    quit(-1)
     1386
     1387                dimsplot.append(dims)
     1388
     1389                # pictoric values for the figure
     1390                Sfivaop = kplot + '_' + vn + '_' + op
     1391                if plotspecifics.has_key(Sfivaop):
     1392                    pictvals = plotspecifics[Sfivaop]
     1393                else:
     1394                    Vvals = gen.variables_values(vn)
     1395                    pictvals = [Vvals[2], Vvals[3], Vvals[6], '%g', 'black']
     1396
     1397                pictplot.append(pictvals)
     1398
     1399                # Header of the name of the figure
     1400                if ivp == 0:
     1401                    figname = kplot +'_'+ vn + '_' + headf + '_' + op.replace('+','-')
     1402                else:
     1403                    figname = figname + '-'+vn+'_'+headf+'_'+op.replace('+','-')
     1404
     1405                # Title of the figure:
     1406                if ivp == 0:
     1407                    titfigure = mod + '!' + exp + '!' + vn
     1408                else:
     1409                    titfigure = titfigure + '!&!' + vn
     1410                for op1 in op.split('+'):
     1411                    if not opexplained.has_key(op1):
     1412                        print errormsg
     1413                        print '  '+fname+": no explanation for operation '"+op1+"' !!"
     1414                        print '    provided:', opexplained.keys()
     1415                        quit(-1)
     1416                    titfigure = titfigure + '!' + opexplained[op1]
     1417
     1418                ivp = ivp + 1
     1419            # End of variable-operation
     1420
     1421            draw_plot(kplot, CFvarsplot, filesplot, varsplot, dimsplot, pictplot,    \
     1422              figname, titfigure, kindfigure, mapvalue, timeunits, odir, pyHOME,     \
     1423              figscr, debug)
     1424
     1425        # End of variables-operations
     1426
     1427    # End of kind of plots
     1428
     1429    return
     1430
    9781431# Files with information about the configuration of the script
    9791432inffiles = ['varcompute.inf', 'all_computevars.inf', 'all_statsvars.inf']
     
    9961449for mod in mods:
    9971450    print mod
     1451    if scratch:
     1452        sout = sub.call('rm -rf '+cnf['ofold']+'/'+mod+' > /dev/null', shell=True)
     1453
    9981454    # Get experiments and headers of model
    9991455    exps, fheaders = exp_headers(mod,cnf)
     
    10491505            objf.close()
    10501506
     1507        varcompf = owdir + '/varcompute.inf'
    10511508        if addfiles:
    1052             sub.call('rm ' + owdir +'/varcompute.inf >& /dev/null', shell=True)
    1053 
    1054         varcompf = owdir + '/varcompute.inf'
     1509            sub.call('rm ' + varcompf +' >& /dev/null', shell=True)
     1510
    10551511        if not os.path.isfile(varcompf):
    10561512            # Does input folder has header files?
     
    10651521                    ins = 'rm '+ owdir+'/*_' + fh + '*.nc >& /dev/null'
    10661522                    sout = sub.call(ins, shell=True)
    1067                     files1h = gen.files_folder(iwdir,fh)
    1068                     if len(files1h) < 1:
    1069                         print errmsg
    1070                         print '  ' + main + ": folder '" + iwdir + "' does not " +   \
    1071                           "contain files '" + fh + "*' !!"
    1072                         quit(-1)
    1073                     files[fh] = files1h
    1074                     testfiles[fh] = files1h[0]
     1523                files1h = gen.files_folder(iwdir,fh)
     1524                if len(files1h) < 1:
     1525                    print errmsg
     1526                    print '  ' + main + ": folder '" + iwdir + "' does not " +   \
     1527                      "contain files '" + fh + "*' !!"
     1528                    quit(-1)
     1529                files[fh] = files1h
     1530                testfiles[fh] = files1h[0]
    10751531
    10761532            if dbg:
     
    10861542            print warnmsg
    10871543            print '  ' + main + ": getting variables to compute already from file !!"
    1088             files, testfiles, allcompvar, Nvar = read_varcomp_file(owdir +           \
    1089               '/varcompute.inf')
     1544            files, testfiles, allcompvar, Nvar = read_varcomp_file(varcompf)
    10901545
    10911546        # End of avoiding to repeat all the experiment search
     
    10941549
    10951550        if dbg:
    1096             print 'Variables to compute _______', type(allcompvar)
     1551            print 'Variables to compute _______'
    10971552            gen.printing_dictionary(allcompvar)
    10981553
     
    11031558        compute_vars(cnf, Modinf, iwdir, owdir, files, allcompvar, filescratch, dbg)
    11041559
     1560##
     1561# Figures of variables direct from files
     1562##
     1563        print "  " + main + ": Plotting direct figures ..."
     1564        dirfigf = owdir + '/directplotsdraw.inf'
     1565        if figscratch:
     1566            sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True)
     1567
     1568            objf = open(owdir+'/all_figures.inf','w')
     1569            objf.write("## Drawing of all figures \n")
     1570            objf.close()
     1571
     1572        if addfigures:
     1573            sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True)
     1574
     1575        if not os.path.isfile(dirfigf):
     1576            listplots, Nplt = plots_listconstruct(cnf, owdir, dbg)
     1577        else:
     1578            print warnmsg
     1579            print '  ' + main + ": getting plots to draw already from file !!"
     1580            listplots, Nplt = read_plot_file(dirfigf)
     1581
     1582        # End of avoiding to repeat all the plots search
     1583
     1584        print "  For experiment '"+exp+"' is required to plot:", Nplt, "plots"
     1585
     1586        if dbg:
     1587            print 'Plots to draw _______'
     1588            gen.printing_dictionary(listplots)
     1589
     1590        draw_plots(cnf, listplots, mod, exp, owdir, allcompvar, figscratch, dbg)
     1591
    11051592        quit()
    1106 
    11071593    # end of experiments loop
     1594
    11081595# end of mods loop
    11091596
  • trunk/tools/model_graphics_template.dat

    r1022 r1025  
    3030
    3131# Have new files been added and do they need to be processed?
    32 addfiles = true
     32addfiles = false
    3333
    3434# Have new figures been added and do they need to be drawn?
    35 addfigures = false
     35addfigures = true
    3636
    3737# Debug
     
    8686#   in foudre values from: ${HOME}/UNSW-CCRC-WRF/tools/postprocess/GMS-UC/WRF4G/util/postprocess/wrfncxnj/wrfncxnj.table
    8787#   must exist on the table $pyHOME/variables_values.dat
    88 #   varcombo = [varn];[vark1]@...@[varkN]: variable as consecutive kinds of operation
     88#
    8989# Variables to compute (as possible multiple consecutive combination of operations must start by 'VAR_' separated by '+'
    9090#   VAR_[calc1]+[calc2] = tas:wss
     
    108108#    opsur_mean = tmean:xmean
    109109#      once 'tmean', or 'xmean' are computed, variable [varn] will become [varn]mean
    110 #   NOTE: surnames are attaced only once
    111110opsur_mean = Lmean:lmean:tmean:xmean:ymean
     111
     112# Text as title for each operation
     113#   as ':' separated list of [op]|[explanation '!' as spaces]
     114titleoperations = 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
    112115
    113116# Pressure levels
     
    130133#   shadcont2Dzsec: 2D map of vertical section of 2 variables one in shadow and the other in contourn
    131134#
    132 #   ':' separated list of statitsics variable values are given as: [var]|[kind(including combo values)]
     135#   ':' separated list of statitsics variable values are given as: [var]|['+' separated list of operations]
    133136#     in figures with more than 1 variable, use '#' to separate them
    134 #drawplots = shadcont2Dsfc:shadconthovmsfc:sahdcont2Dzsec
    135 drawplots = shadcont2Dzsec
    136 drawdiffplots = shadcont2Dsfc:shadconthovmsfc:sahdcont2Dzsec
     137# DIRPLT_: Figures which can be made directly without another model/experiment output
    137138
    138 # Figures which can be made directly without another model/experiment output
    139 directplots = shadconthovmsfc:shadcont2Dsfc:shadcont2Dzsec
     139DIRPLT_shadcont2Dsfc = uas|last#vas|last:hfls|last#hfss|last:wss|last#tas|last
     140#DIRPLT_shadconthovmsfc = wss|xmean#tas|xmean
     141#DIRPLT_shadcont2Dzsec = ua|pinterp+tmean+xmean#va|pinterp+tmean+xmean:hus|pinterp+tmean+xmean#ta|pinterp+tmean+xmean
    140142
    141 pltshadcont2Dsfc = huss|tmean#tas|tmean:vas|tmean#uas|tmean:ps|tmean#wss|tmean:pr|tmean#rsds|tmean:prw|tmean#clt|tmean:hfls|tmean#hfss|tmean:evspsbl|tmean#bils|tmean:zmaxth|tmean#stherm|tmean:wakeh|tmean#wakes|tmean:zmaxth|tmean#stherm|tmean:prls|tmean#prc|tmean:clt|tmean#cll|tmean:clm|tmean#clh|tmean:hurs|tmean#zmla|tmean:huss|last#tas|last:vas|last#uas|last:ps|last#wss|tmean:pr|last#rsds|last:prw|last#clt|last:hfls|last#hfss|last:evspsbl|last#bils|last:zmaxth|last#stherm|last:wakeh|last#wakes|last:zmaxth|last#stherm|last:prls|last#prc|last:clt|last#cll|last:clm|last#clh|last:hurs|last#zmla|last
    142 pltshadconthovmsfc = hurs|xmean#tas|xmean:wss|xmean#ps|xmean
    143 pltshadcont2Dzsec = ua|pinterp@last@xmean#va|pinterp@last@xmean:hur|pinterp@last@xmean#ta|pinterp@last@xmean:ws|pinterp@turb@xmean#hus|pinterp@turb@xmean
     143#pltshadcont2Dsfc = huss|tmean#tas|tmean:vas|tmean#uas|tmean:ps|tmean#wss|tmean:pr|tmean#rsds|tmean:prw|tmean#clt|tmean:hfls|tmean#hfss|tmean:evspsbl|tmean#bils|tmean:zmaxth|tmean#stherm|tmean:wakeh|tmean#wakes|tmean:zmaxth|tmean#stherm|tmean:prls|tmean#prc|tmean:clt|tmean#cll|tmean:clm|tmean#clh|tmean:hurs|tmean#zmla|tmean:huss|last#tas|last:vas|last#uas|last:ps|last#wss|tmean:pr|last#rsds|last:prw|last#clt|last:hfls|last#hfss|last:evspsbl|last#bils|last:zmaxth|last#stherm|last:wakeh|last#wakes|last:zmaxth|last#stherm|last:prls|last#prc|last:clt|last#cll|last:clm|last#clh|last:hurs|last#zmla|last
     144#pltshadconthovmsfc = hurs|xmean#tas|xmean:wss|xmean#ps|xmean
     145#pltshadcont2Dzsec = ua|pinterp@last@xmean#va|pinterp@last@xmean:hur|pinterp@last@xmean#ta|pinterp@last@xmean:ws|pinterp@turb@xmean#hus|pinterp@turb@xmean
    144146
    145147pltdiffshadcont2Dsfc = tas|tmean#wss|tmean:wss|last#tas|last
     
    149151# Specific variable-statistisc graphic parameters (if no value is given, they will be retrieved from 'variables_values.dat')
    150152#  ':' separated list of specific parameters for plotting as:
    151 #      [varname]|[statistics]|[minval]|[maxval]|[colorbar]|[cntformat]|[colorcnt]
     153#      [varname]|[operation]|[minval]|[maxval]|[colorbar]|[cntformat]|[colorcnt]
    152154#        [varname]: name of the variable
    153 #        [statistics]: statistics (also combo)
     155#        [operation]: '+' separated list of operations
    154156#        [figure]: figure to be used
    155157#        [minval]: minimum value
Note: See TracChangeset for help on using the changeset viewer.