Changeset 470 in lmdz_wrf for trunk/tools/drawing.py


Ignore:
Timestamp:
Jun 10, 2015, 11:37:09 AM (9 years ago)
Author:
lfita
Message:

Adding multiple dimvar values on `draw_lines'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r446 r470  
    15151515      ncfilens= [filen] ',' separated list of netCDF files
    15161516      values= [dimvname]:[valuesaxis]:[dimtit]:[leglabels]:[vtit]:[title]:[locleg]:[graphk]
    1517         [dimvname]: name of the variable with he values of the common dimension
     1517        [dimvname]: ',' list of names of the variable with he values of the common dimension
    15181518        [valuesaxis]: which axis will be used for the values ('x', or 'y')
    15191519        [dimtit]: title for the common dimension
     
    15411541
    15421542    ncfiles = ncfilens.split(',')
    1543     dimvname = values.split(':')[0]
     1543    dimvnames = values.split(':')[0]
    15441544    valuesaxis = values.split(':')[1]
    15451545    dimtit = values.split(':')[2]
     
    15711571        objfile = NetCDFFile(filen, 'r')
    15721572
    1573         if not objfile.variables.has_key(dimvname):
     1573        if dimvnames.find(',') != -1:
     1574            dimvname = dimvnames.split(',')
     1575        else:
     1576            dimvname = [dimvnames]
     1577   
     1578        found = False
     1579        for dvn in dimvname:
     1580            if objfile.variables.has_key(dvn):
     1581                found = True
     1582                break
     1583   
     1584        if not found:
    15741585            print errormsg
    15751586            print '  ' + fname + ": netCDF file '" + filen +                         \
    1576               "' does not have variable '" + dimvname + "' !!"
     1587              "' does not have variables '" + dimvname + "' !!"
    15771588            quit(-1)
    15781589
     
    15901601            quit(-1)
    15911602
    1592         vdobj = objfile.variables[dimvname]
    1593         if len(vdobj.shape) != 1:
    1594             print errormsg
    1595             print '  ' + fname + ': wrong shape:',vdobj.shape," of variable '" +     \
    1596               dimvname +  "' !!"
    1597             quit(-1)
     1603        for dimvn in dimvname:
     1604            if searchInlist(objfile.variables, dimvn):
     1605                vdobj = objfile.variables[dimvname]
     1606                if len(vdobj.shape) != 1:
     1607                    print errormsg
     1608                    print '  ' + fname + ': wrong shape:',vdobj.shape,               \
     1609                      " of variable '" + dimvn +  "' !!"
     1610                    quit(-1)
     1611                break
    15981612
    15991613        varvalues.append(vvobj[:])
Note: See TracChangeset for help on using the changeset viewer.